documentation.d.ts 3.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * 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.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * 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.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. 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>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. 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;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. 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;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. 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;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  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 Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Class representing a vector containing 2 coordinates
  1909. */
  1910. export class Vector2 {
  1911. /** defines the first coordinate */
  1912. x: number;
  1913. /** defines the second coordinate */
  1914. y: number;
  1915. /**
  1916. * Creates a new Vector2 from the given x and y coordinates
  1917. * @param x defines the first coordinate
  1918. * @param y defines the second coordinate
  1919. */
  1920. constructor(
  1921. /** defines the first coordinate */
  1922. x?: number,
  1923. /** defines the second coordinate */
  1924. y?: number);
  1925. /**
  1926. * Gets a string with the Vector2 coordinates
  1927. * @returns a string with the Vector2 coordinates
  1928. */
  1929. toString(): string;
  1930. /**
  1931. * Gets class name
  1932. * @returns the string "Vector2"
  1933. */
  1934. getClassName(): string;
  1935. /**
  1936. * Gets current vector hash code
  1937. * @returns the Vector2 hash code as a number
  1938. */
  1939. getHashCode(): number;
  1940. /**
  1941. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1942. * @param array defines the source array
  1943. * @param index defines the offset in source array
  1944. * @returns the current Vector2
  1945. */
  1946. toArray(array: FloatArray, index?: number): Vector2;
  1947. /**
  1948. * Copy the current vector to an array
  1949. * @returns a new array with 2 elements: the Vector2 coordinates.
  1950. */
  1951. asArray(): number[];
  1952. /**
  1953. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1954. * @param source defines the source Vector2
  1955. * @returns the current updated Vector2
  1956. */
  1957. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the Vector2 coordinates with the given floats
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. * @returns the current updated Vector2
  1963. */
  1964. copyFromFloats(x: number, y: number): Vector2;
  1965. /**
  1966. * Sets the Vector2 coordinates with the given floats
  1967. * @param x defines the first coordinate
  1968. * @param y defines the second coordinate
  1969. * @returns the current updated Vector2
  1970. */
  1971. set(x: number, y: number): Vector2;
  1972. /**
  1973. * Add another vector with the current one
  1974. * @param otherVector defines the other vector
  1975. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1976. */
  1977. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1980. * @param otherVector defines the other vector
  1981. * @param result defines the target vector
  1982. * @returns the unmodified current Vector2
  1983. */
  1984. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1985. /**
  1986. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1987. * @param otherVector defines the other vector
  1988. * @returns the current updated Vector2
  1989. */
  1990. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1993. * @param otherVector defines the other vector
  1994. * @returns a new Vector2
  1995. */
  1996. addVector3(otherVector: Vector3): Vector2;
  1997. /**
  1998. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2
  2001. */
  2002. subtract(otherVector: Vector2): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Multiplies in place the current Vector2 coordinates by the given ones
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2028. /**
  2029. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2037. * @param x defines the first coordinate
  2038. * @param y defines the second coordinate
  2039. * @returns a new Vector2
  2040. */
  2041. multiplyByFloats(x: number, y: number): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. divide(otherVector: Vector2): Vector2;
  2048. /**
  2049. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Divides the current Vector2 coordinates by the given ones
  2057. * @param otherVector defines the other vector
  2058. * @returns the current updated Vector2
  2059. */
  2060. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Gets a new Vector2 with current Vector2 negated coordinates
  2063. * @returns a new Vector2
  2064. */
  2065. negate(): Vector2;
  2066. /**
  2067. * Negate this vector in place
  2068. * @returns this
  2069. */
  2070. negateInPlace(): Vector2;
  2071. /**
  2072. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2073. * @param result defines the Vector3 object where to store the result
  2074. * @returns the current Vector2
  2075. */
  2076. negateToRef(result: Vector2): Vector2;
  2077. /**
  2078. * Multiply the Vector2 coordinates by scale
  2079. * @param scale defines the scaling factor
  2080. * @returns the current updated Vector2
  2081. */
  2082. scaleInPlace(scale: number): Vector2;
  2083. /**
  2084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2085. * @param scale defines the scaling factor
  2086. * @returns a new Vector2
  2087. */
  2088. scale(scale: number): Vector2;
  2089. /**
  2090. * Scale the current Vector2 values by a factor to a given Vector2
  2091. * @param scale defines the scale factor
  2092. * @param result defines the Vector2 object where to store the result
  2093. * @returns the unmodified current Vector2
  2094. */
  2095. scaleToRef(scale: number, result: Vector2): Vector2;
  2096. /**
  2097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2098. * @param scale defines the scale factor
  2099. * @param result defines the Vector2 object where to store the result
  2100. * @returns the unmodified current Vector2
  2101. */
  2102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2103. /**
  2104. * Gets a boolean if two vectors are equals
  2105. * @param otherVector defines the other vector
  2106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2107. */
  2108. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2109. /**
  2110. * Gets a boolean if two vectors are equals (using an epsilon value)
  2111. * @param otherVector defines the other vector
  2112. * @param epsilon defines the minimal distance to consider equality
  2113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2114. */
  2115. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. floor(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 from current Vector2 floored values
  2123. * @returns a new Vector2
  2124. */
  2125. fract(): Vector2;
  2126. /**
  2127. * Gets the length of the vector
  2128. * @returns the vector length (float)
  2129. */
  2130. length(): number;
  2131. /**
  2132. * Gets the vector squared length
  2133. * @returns the vector squared length (float)
  2134. */
  2135. lengthSquared(): number;
  2136. /**
  2137. * Normalize the vector
  2138. * @returns the current updated Vector2
  2139. */
  2140. normalize(): Vector2;
  2141. /**
  2142. * Gets a new Vector2 copied from the Vector2
  2143. * @returns a new Vector2
  2144. */
  2145. clone(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(0, 0)
  2148. * @returns a new Vector2
  2149. */
  2150. static Zero(): Vector2;
  2151. /**
  2152. * Gets a new Vector2(1, 1)
  2153. * @returns a new Vector2
  2154. */
  2155. static One(): Vector2;
  2156. /**
  2157. * Gets a new Vector2 set from the given index element of the given array
  2158. * @param array defines the data source
  2159. * @param offset defines the offset in the data source
  2160. * @returns a new Vector2
  2161. */
  2162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2163. /**
  2164. * Sets "result" from the given index element of the given array
  2165. * @param array defines the data source
  2166. * @param offset defines the offset in the data source
  2167. * @param result defines the target vector
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2170. /**
  2171. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2172. * @param value1 defines 1st point of control
  2173. * @param value2 defines 2nd point of control
  2174. * @param value3 defines 3rd point of control
  2175. * @param value4 defines 4th point of control
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * 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".
  2182. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2183. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2184. * @param value defines the value to clamp
  2185. * @param min defines the lower limit
  2186. * @param max defines the upper limit
  2187. * @returns a new Vector2
  2188. */
  2189. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2192. * @param value1 defines the 1st control point
  2193. * @param tangent1 defines the outgoing tangent
  2194. * @param value2 defines the 2nd control point
  2195. * @param tangent2 defines the incoming tangent
  2196. * @param amount defines the interpolation factor
  2197. * @returns a new Vector2
  2198. */
  2199. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2200. /**
  2201. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2202. * @param start defines the start vector
  2203. * @param end defines the end vector
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * Gets the dot product of the vector "left" and the vector "right"
  2210. * @param left defines first vector
  2211. * @param right defines second vector
  2212. * @returns the dot product (float)
  2213. */
  2214. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2215. /**
  2216. * Returns a new Vector2 equal to the normalized given vector
  2217. * @param vector defines the vector to normalize
  2218. * @returns a new Vector2
  2219. */
  2220. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2223. * @param left defines 1st vector
  2224. * @param right defines 2nd vector
  2225. * @returns a new Vector2
  2226. */
  2227. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2228. /**
  2229. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2230. * @param left defines 1st vector
  2231. * @param right defines 2nd vector
  2232. * @returns a new Vector2
  2233. */
  2234. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2237. * @param vector defines the vector to transform
  2238. * @param transformation defines the matrix to apply
  2239. * @returns a new Vector2
  2240. */
  2241. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2242. /**
  2243. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2244. * @param vector defines the vector to transform
  2245. * @param transformation defines the matrix to apply
  2246. * @param result defines the target vector
  2247. */
  2248. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2249. /**
  2250. * Determines if a given vector is included in a triangle
  2251. * @param p defines the vector to test
  2252. * @param p0 defines 1st triangle point
  2253. * @param p1 defines 2nd triangle point
  2254. * @param p2 defines 3rd triangle point
  2255. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2256. */
  2257. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2258. /**
  2259. * Gets the distance between the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns the distance between vectors
  2263. */
  2264. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2265. /**
  2266. * Returns the squared distance between the vectors "value1" and "value2"
  2267. * @param value1 defines first vector
  2268. * @param value2 defines second vector
  2269. * @returns the squared distance between vectors
  2270. */
  2271. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2272. /**
  2273. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns a new Vector2
  2277. */
  2278. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2279. /**
  2280. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2281. * @param p defines the middle point
  2282. * @param segA defines one point of the segment
  2283. * @param segB defines the other point of the segment
  2284. * @returns the shortest distance
  2285. */
  2286. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2287. }
  2288. /**
  2289. * Class used to store (x,y,z) vector representation
  2290. * A Vector3 is the main object used in 3D geometry
  2291. * It can represent etiher the coordinates of a point the space, either a direction
  2292. * Reminder: js uses a left handed forward facing system
  2293. */
  2294. export class Vector3 {
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x: number;
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y: number;
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z: number;
  2307. private static _UpReadOnly;
  2308. private static _ZeroReadOnly;
  2309. /**
  2310. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2311. * @param x defines the first coordinates (on X axis)
  2312. * @param y defines the second coordinates (on Y axis)
  2313. * @param z defines the third coordinates (on Z axis)
  2314. */
  2315. constructor(
  2316. /**
  2317. * Defines the first coordinates (on X axis)
  2318. */
  2319. x?: number,
  2320. /**
  2321. * Defines the second coordinates (on Y axis)
  2322. */
  2323. y?: number,
  2324. /**
  2325. * Defines the third coordinates (on Z axis)
  2326. */
  2327. z?: number);
  2328. /**
  2329. * Creates a string representation of the Vector3
  2330. * @returns a string with the Vector3 coordinates.
  2331. */
  2332. toString(): string;
  2333. /**
  2334. * Gets the class name
  2335. * @returns the string "Vector3"
  2336. */
  2337. getClassName(): string;
  2338. /**
  2339. * Creates the Vector3 hash code
  2340. * @returns a number which tends to be unique between Vector3 instances
  2341. */
  2342. getHashCode(): number;
  2343. /**
  2344. * Creates an array containing three elements : the coordinates of the Vector3
  2345. * @returns a new array of numbers
  2346. */
  2347. asArray(): number[];
  2348. /**
  2349. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2350. * @param array defines the destination array
  2351. * @param index defines the offset in the destination array
  2352. * @returns the current Vector3
  2353. */
  2354. toArray(array: FloatArray, index?: number): Vector3;
  2355. /**
  2356. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2357. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2358. */
  2359. toQuaternion(): Quaternion;
  2360. /**
  2361. * Adds the given vector to the current Vector3
  2362. * @param otherVector defines the second operand
  2363. * @returns the current updated Vector3
  2364. */
  2365. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the given coordinates to the current Vector3
  2368. * @param x defines the x coordinate of the operand
  2369. * @param y defines the y coordinate of the operand
  2370. * @param z defines the z coordinate of the operand
  2371. * @returns the current updated Vector3
  2372. */
  2373. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2374. /**
  2375. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2376. * @param otherVector defines the second operand
  2377. * @returns the resulting Vector3
  2378. */
  2379. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2382. * @param otherVector defines the second operand
  2383. * @param result defines the Vector3 object where to store the result
  2384. * @returns the current Vector3
  2385. */
  2386. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2387. /**
  2388. * Subtract the given vector from the current Vector3
  2389. * @param otherVector defines the second operand
  2390. * @returns the current updated Vector3
  2391. */
  2392. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the resulting Vector3
  2397. */
  2398. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2401. * @param otherVector defines the second operand
  2402. * @param result defines the Vector3 object where to store the result
  2403. * @returns the current Vector3
  2404. */
  2405. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2406. /**
  2407. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2408. * @param x defines the x coordinate of the operand
  2409. * @param y defines the y coordinate of the operand
  2410. * @param z defines the z coordinate of the operand
  2411. * @returns the resulting Vector3
  2412. */
  2413. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2414. /**
  2415. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2416. * @param x defines the x coordinate of the operand
  2417. * @param y defines the y coordinate of the operand
  2418. * @param z defines the z coordinate of the operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2423. /**
  2424. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2425. * @returns a new Vector3
  2426. */
  2427. negate(): Vector3;
  2428. /**
  2429. * Negate this vector in place
  2430. * @returns this
  2431. */
  2432. negateInPlace(): Vector3;
  2433. /**
  2434. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. negateToRef(result: Vector3): Vector3;
  2439. /**
  2440. * Multiplies the Vector3 coordinates by the float "scale"
  2441. * @param scale defines the multiplier factor
  2442. * @returns the current updated Vector3
  2443. */
  2444. scaleInPlace(scale: number): Vector3;
  2445. /**
  2446. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2447. * @param scale defines the multiplier factor
  2448. * @returns a new Vector3
  2449. */
  2450. scale(scale: number): Vector3;
  2451. /**
  2452. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2453. * @param scale defines the multiplier factor
  2454. * @param result defines the Vector3 object where to store the result
  2455. * @returns the current Vector3
  2456. */
  2457. scaleToRef(scale: number, result: Vector3): Vector3;
  2458. /**
  2459. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2460. * @param scale defines the scale factor
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the unmodified current Vector3
  2463. */
  2464. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2465. /**
  2466. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2467. * @param otherVector defines the second operand
  2468. * @returns true if both vectors are equals
  2469. */
  2470. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2471. /**
  2472. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2473. * @param otherVector defines the second operand
  2474. * @param epsilon defines the minimal distance to define values as equals
  2475. * @returns true if both vectors are distant less than epsilon
  2476. */
  2477. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2478. /**
  2479. * Returns true if the current Vector3 coordinates equals the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns true if both vectors are equals
  2484. */
  2485. equalsToFloats(x: number, y: number, z: number): boolean;
  2486. /**
  2487. * Multiplies the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2494. * @param otherVector defines the second operand
  2495. * @returns the new Vector3
  2496. */
  2497. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2500. * @param otherVector defines the second operand
  2501. * @param result defines the Vector3 object where to store the result
  2502. * @returns the current Vector3
  2503. */
  2504. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2507. * @param x defines the x coordinate of the operand
  2508. * @param y defines the y coordinate of the operand
  2509. * @param z defines the z coordinate of the operand
  2510. * @returns the new Vector3
  2511. */
  2512. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2513. /**
  2514. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2515. * @param otherVector defines the second operand
  2516. * @returns the new Vector3
  2517. */
  2518. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2521. * @param otherVector defines the second operand
  2522. * @param result defines the Vector3 object where to store the result
  2523. * @returns the current Vector3
  2524. */
  2525. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2526. /**
  2527. * Divides the current Vector3 coordinates by the given ones.
  2528. * @param otherVector defines the second operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. divideInPlace(otherVector: Vector3): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2534. * @param other defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2540. * @param other defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2562. * Check if is non uniform within a certain amount of decimal places to account for this
  2563. * @param epsilon the amount the values can differ
  2564. * @returns if the the vector is non uniform to a certain number of decimal places
  2565. */
  2566. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2567. /**
  2568. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2569. */
  2570. get isNonUniform(): boolean;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. floor(): Vector3;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. fract(): Vector3;
  2581. /**
  2582. * Gets the length of the Vector3
  2583. * @returns the length of the Vector3
  2584. */
  2585. length(): number;
  2586. /**
  2587. * Gets the squared length of the Vector3
  2588. * @returns squared length of the Vector3
  2589. */
  2590. lengthSquared(): number;
  2591. /**
  2592. * Normalize the current Vector3.
  2593. * Please note that this is an in place operation.
  2594. * @returns the current updated Vector3
  2595. */
  2596. normalize(): Vector3;
  2597. /**
  2598. * Reorders the x y z properties of the vector in place
  2599. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2600. * @returns the current updated vector
  2601. */
  2602. reorderInPlace(order: string): this;
  2603. /**
  2604. * Rotates the vector around 0,0,0 by a quaternion
  2605. * @param quaternion the rotation quaternion
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2610. /**
  2611. * Rotates a vector around a given point
  2612. * @param quaternion the rotation quaternion
  2613. * @param point the point to rotate around
  2614. * @param result vector to store the result
  2615. * @returns the resulting vector
  2616. */
  2617. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2618. /**
  2619. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2620. * The cross product is then orthogonal to both current and "other"
  2621. * @param other defines the right operand
  2622. * @returns the cross product
  2623. */
  2624. cross(other: Vector3): Vector3;
  2625. /**
  2626. * Normalize the current Vector3 with the given input length.
  2627. * Please note that this is an in place operation.
  2628. * @param len the length of the vector
  2629. * @returns the current updated Vector3
  2630. */
  2631. normalizeFromLength(len: number): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to a new vector
  2634. * @returns the new Vector3
  2635. */
  2636. normalizeToNew(): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to the reference
  2639. * @param reference define the Vector3 to update
  2640. * @returns the updated Vector3
  2641. */
  2642. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2643. /**
  2644. * Creates a new Vector3 copied from the current Vector3
  2645. * @returns the new Vector3
  2646. */
  2647. clone(): Vector3;
  2648. /**
  2649. * Copies the given vector coordinates to the current Vector3 ones
  2650. * @param source defines the source Vector3
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. copyFromFloats(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given floats to the current Vector3 coordinates
  2664. * @param x defines the x coordinate of the operand
  2665. * @param y defines the y coordinate of the operand
  2666. * @param z defines the z coordinate of the operand
  2667. * @returns the current updated Vector3
  2668. */
  2669. set(x: number, y: number, z: number): Vector3;
  2670. /**
  2671. * Copies the given float to the current Vector3 coordinates
  2672. * @param v defines the x, y and z coordinates of the operand
  2673. * @returns the current updated Vector3
  2674. */
  2675. setAll(v: number): Vector3;
  2676. /**
  2677. * Get the clip factor between two vectors
  2678. * @param vector0 defines the first operand
  2679. * @param vector1 defines the second operand
  2680. * @param axis defines the axis to use
  2681. * @param size defines the size along the axis
  2682. * @returns the clip factor
  2683. */
  2684. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2685. /**
  2686. * Get angle between two vectors
  2687. * @param vector0 angle between vector0 and vector1
  2688. * @param vector1 angle between vector0 and vector1
  2689. * @param normal direction of the normal
  2690. * @return the angle between vector0 and vector1
  2691. */
  2692. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2693. /**
  2694. * Returns a new Vector3 set from the index "offset" of the given array
  2695. * @param array defines the source array
  2696. * @param offset defines the offset in the source array
  2697. * @returns the new Vector3
  2698. */
  2699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2700. /**
  2701. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @returns the new Vector3
  2705. * @deprecated Please use FromArray instead.
  2706. */
  2707. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2708. /**
  2709. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2710. * @param array defines the source array
  2711. * @param offset defines the offset in the source array
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2717. * @param array defines the source array
  2718. * @param offset defines the offset in the source array
  2719. * @param result defines the Vector3 where to store the result
  2720. * @deprecated Please use FromArrayToRef instead.
  2721. */
  2722. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2723. /**
  2724. * Sets the given vector "result" with the given floats.
  2725. * @param x defines the x coordinate of the source
  2726. * @param y defines the y coordinate of the source
  2727. * @param z defines the z coordinate of the source
  2728. * @param result defines the Vector3 where to store the result
  2729. */
  2730. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2731. /**
  2732. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2733. * @returns a new empty Vector3
  2734. */
  2735. static Zero(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2738. * @returns a new unit Vector3
  2739. */
  2740. static One(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2743. * @returns a new up Vector3
  2744. */
  2745. static Up(): Vector3;
  2746. /**
  2747. * Gets a up Vector3 that must not be updated
  2748. */
  2749. static get UpReadOnly(): DeepImmutable<Vector3>;
  2750. /**
  2751. * Gets a zero Vector3 that must not be updated
  2752. */
  2753. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2756. * @returns a new down Vector3
  2757. */
  2758. static Down(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2761. * @param rightHandedSystem is the scene right-handed (negative z)
  2762. * @returns a new forward Vector3
  2763. */
  2764. static Forward(rightHandedSystem?: boolean): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2767. * @param rightHandedSystem is the scene right-handed (negative-z)
  2768. * @returns a new forward Vector3
  2769. */
  2770. static Backward(rightHandedSystem?: boolean): Vector3;
  2771. /**
  2772. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2773. * @returns a new right Vector3
  2774. */
  2775. static Right(): Vector3;
  2776. /**
  2777. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2778. * @returns a new left Vector3
  2779. */
  2780. static Left(): Vector3;
  2781. /**
  2782. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2783. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2784. * @param vector defines the Vector3 to transform
  2785. * @param transformation defines the transformation matrix
  2786. * @returns the transformed Vector3
  2787. */
  2788. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2789. /**
  2790. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2791. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2792. * @param vector defines the Vector3 to transform
  2793. * @param transformation defines the transformation matrix
  2794. * @param result defines the Vector3 where to store the result
  2795. */
  2796. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2797. /**
  2798. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2799. * This method computes tranformed coordinates only, not transformed direction vectors
  2800. * @param x define the x coordinate of the source vector
  2801. * @param y define the y coordinate of the source vector
  2802. * @param z define the z coordinate of the source vector
  2803. * @param transformation defines the transformation matrix
  2804. * @param result defines the Vector3 where to store the result
  2805. */
  2806. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2807. /**
  2808. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2809. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2810. * @param vector defines the Vector3 to transform
  2811. * @param transformation defines the transformation matrix
  2812. * @returns the new Vector3
  2813. */
  2814. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2815. /**
  2816. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2817. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2818. * @param vector defines the Vector3 to transform
  2819. * @param transformation defines the transformation matrix
  2820. * @param result defines the Vector3 where to store the result
  2821. */
  2822. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2823. /**
  2824. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2825. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2826. * @param x define the x coordinate of the source vector
  2827. * @param y define the y coordinate of the source vector
  2828. * @param z define the z coordinate of the source vector
  2829. * @param transformation defines the transformation matrix
  2830. * @param result defines the Vector3 where to store the result
  2831. */
  2832. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2833. /**
  2834. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2835. * @param value1 defines the first control point
  2836. * @param value2 defines the second control point
  2837. * @param value3 defines the third control point
  2838. * @param value4 defines the fourth control point
  2839. * @param amount defines the amount on the spline to use
  2840. * @returns the new Vector3
  2841. */
  2842. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2843. /**
  2844. * 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"
  2845. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2846. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2847. * @param value defines the current value
  2848. * @param min defines the lower range value
  2849. * @param max defines the upper range value
  2850. * @returns the new Vector3
  2851. */
  2852. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2853. /**
  2854. * 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"
  2855. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2856. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2857. * @param value defines the current value
  2858. * @param min defines the lower range value
  2859. * @param max defines the upper range value
  2860. * @param result defines the Vector3 where to store the result
  2861. */
  2862. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2863. /**
  2864. * Checks if a given vector is inside a specific range
  2865. * @param v defines the vector to test
  2866. * @param min defines the minimum range
  2867. * @param max defines the maximum range
  2868. */
  2869. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2870. /**
  2871. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2872. * @param value1 defines the first control point
  2873. * @param tangent1 defines the first tangent vector
  2874. * @param value2 defines the second control point
  2875. * @param tangent2 defines the second tangent vector
  2876. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2877. * @returns the new Vector3
  2878. */
  2879. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2880. /**
  2881. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2882. * @param start defines the start value
  2883. * @param end defines the end value
  2884. * @param amount max defines amount between both (between 0 and 1)
  2885. * @returns the new Vector3
  2886. */
  2887. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2888. /**
  2889. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2890. * @param start defines the start value
  2891. * @param end defines the end value
  2892. * @param amount max defines amount between both (between 0 and 1)
  2893. * @param result defines the Vector3 where to store the result
  2894. */
  2895. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2896. /**
  2897. * Returns the dot product (float) between the vectors "left" and "right"
  2898. * @param left defines the left operand
  2899. * @param right defines the right operand
  2900. * @returns the dot product
  2901. */
  2902. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2903. /**
  2904. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2905. * The cross product is then orthogonal to both "left" and "right"
  2906. * @param left defines the left operand
  2907. * @param right defines the right operand
  2908. * @returns the cross product
  2909. */
  2910. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2911. /**
  2912. * Sets the given vector "result" with the cross product of "left" and "right"
  2913. * The cross product is then orthogonal to both "left" and "right"
  2914. * @param left defines the left operand
  2915. * @param right defines the right operand
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2919. /**
  2920. * Returns a new Vector3 as the normalization of the given vector
  2921. * @param vector defines the Vector3 to normalize
  2922. * @returns the new Vector3
  2923. */
  2924. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2925. /**
  2926. * Sets the given vector "result" with the normalization of the given first vector
  2927. * @param vector defines the Vector3 to normalize
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2931. /**
  2932. * Project a Vector3 onto screen space
  2933. * @param vector defines the Vector3 to project
  2934. * @param world defines the world matrix to use
  2935. * @param transform defines the transform (view x projection) matrix to use
  2936. * @param viewport defines the screen viewport to use
  2937. * @returns the new Vector3
  2938. */
  2939. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2940. /** @hidden */
  2941. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2942. /**
  2943. * Unproject from screen space to object space
  2944. * @param source defines the screen space Vector3 to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param transform defines the transform (view x projection) matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: 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. * @returns the new Vector3
  2961. */
  2962. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param source defines the screen space Vector3 to use
  2966. * @param viewportWidth defines the current width of the viewport
  2967. * @param viewportHeight defines the current height of the viewport
  2968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2969. * @param view defines the view matrix to use
  2970. * @param projection defines the projection matrix to use
  2971. * @param result defines the Vector3 where to store the result
  2972. */
  2973. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param sourceX defines the screen space x coordinate to use
  2977. * @param sourceY defines the screen space y coordinate to use
  2978. * @param sourceZ defines the screen space z coordinate to use
  2979. * @param viewportWidth defines the current width of the viewport
  2980. * @param viewportHeight defines the current height of the viewport
  2981. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2982. * @param view defines the view matrix to use
  2983. * @param projection defines the projection matrix to use
  2984. * @param result defines the Vector3 where to store the result
  2985. */
  2986. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2987. /**
  2988. * Gets the minimal coordinate values between two Vector3
  2989. * @param left defines the first operand
  2990. * @param right defines the second operand
  2991. * @returns the new Vector3
  2992. */
  2993. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2994. /**
  2995. * Gets the maximal coordinate values between two Vector3
  2996. * @param left defines the first operand
  2997. * @param right defines the second operand
  2998. * @returns the new Vector3
  2999. */
  3000. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3001. /**
  3002. * Returns the distance between the vectors "value1" and "value2"
  3003. * @param value1 defines the first operand
  3004. * @param value2 defines the second operand
  3005. * @returns the distance
  3006. */
  3007. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3008. /**
  3009. * Returns the squared distance between the vectors "value1" and "value2"
  3010. * @param value1 defines the first operand
  3011. * @param value2 defines the second operand
  3012. * @returns the squared distance
  3013. */
  3014. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3015. /**
  3016. * Returns a new Vector3 located at the center between "value1" and "value2"
  3017. * @param value1 defines the first operand
  3018. * @param value2 defines the second operand
  3019. * @returns the new Vector3
  3020. */
  3021. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3024. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3025. * to something in order to rotate it from its local system to the given target system
  3026. * Note: axis1, axis2 and axis3 are normalized during this operation
  3027. * @param axis1 defines the first axis
  3028. * @param axis2 defines the second axis
  3029. * @param axis3 defines the third axis
  3030. * @returns a new Vector3
  3031. */
  3032. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3035. * @param axis1 defines the first axis
  3036. * @param axis2 defines the second axis
  3037. * @param axis3 defines the third axis
  3038. * @param ref defines the Vector3 where to store the result
  3039. */
  3040. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3041. }
  3042. /**
  3043. * Vector4 class created for EulerAngle class conversion to Quaternion
  3044. */
  3045. export class Vector4 {
  3046. /** x value of the vector */
  3047. x: number;
  3048. /** y value of the vector */
  3049. y: number;
  3050. /** z value of the vector */
  3051. z: number;
  3052. /** w value of the vector */
  3053. w: number;
  3054. /**
  3055. * Creates a Vector4 object from the given floats.
  3056. * @param x x value of the vector
  3057. * @param y y value of the vector
  3058. * @param z z value of the vector
  3059. * @param w w value of the vector
  3060. */
  3061. constructor(
  3062. /** x value of the vector */
  3063. x: number,
  3064. /** y value of the vector */
  3065. y: number,
  3066. /** z value of the vector */
  3067. z: number,
  3068. /** w value of the vector */
  3069. w: number);
  3070. /**
  3071. * Returns the string with the Vector4 coordinates.
  3072. * @returns a string containing all the vector values
  3073. */
  3074. toString(): string;
  3075. /**
  3076. * Returns the string "Vector4".
  3077. * @returns "Vector4"
  3078. */
  3079. getClassName(): string;
  3080. /**
  3081. * Returns the Vector4 hash code.
  3082. * @returns a unique hash code
  3083. */
  3084. getHashCode(): number;
  3085. /**
  3086. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3087. * @returns the resulting array
  3088. */
  3089. asArray(): number[];
  3090. /**
  3091. * Populates the given array from the given index with the Vector4 coordinates.
  3092. * @param array array to populate
  3093. * @param index index of the array to start at (default: 0)
  3094. * @returns the Vector4.
  3095. */
  3096. toArray(array: FloatArray, index?: number): Vector4;
  3097. /**
  3098. * Adds the given vector to the current Vector4.
  3099. * @param otherVector the vector to add
  3100. * @returns the updated Vector4.
  3101. */
  3102. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3103. /**
  3104. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3105. * @param otherVector the vector to add
  3106. * @returns the resulting vector
  3107. */
  3108. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3109. /**
  3110. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3111. * @param otherVector the vector to add
  3112. * @param result the vector to store the result
  3113. * @returns the current Vector4.
  3114. */
  3115. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3116. /**
  3117. * Subtract in place the given vector from the current Vector4.
  3118. * @param otherVector the vector to subtract
  3119. * @returns the updated Vector4.
  3120. */
  3121. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3122. /**
  3123. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3124. * @param otherVector the vector to add
  3125. * @returns the new vector with the result
  3126. */
  3127. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3128. /**
  3129. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3130. * @param otherVector the vector to subtract
  3131. * @param result the vector to store the result
  3132. * @returns the current Vector4.
  3133. */
  3134. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3135. /**
  3136. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3137. */
  3138. /**
  3139. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3140. * @param x value to subtract
  3141. * @param y value to subtract
  3142. * @param z value to subtract
  3143. * @param w value to subtract
  3144. * @returns new vector containing the result
  3145. */
  3146. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3147. /**
  3148. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3149. * @param x value to subtract
  3150. * @param y value to subtract
  3151. * @param z value to subtract
  3152. * @param w value to subtract
  3153. * @param result the vector to store the result in
  3154. * @returns the current Vector4.
  3155. */
  3156. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3159. * @returns a new vector with the negated values
  3160. */
  3161. negate(): Vector4;
  3162. /**
  3163. * Negate this vector in place
  3164. * @returns this
  3165. */
  3166. negateInPlace(): Vector4;
  3167. /**
  3168. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3169. * @param result defines the Vector3 object where to store the result
  3170. * @returns the current Vector4
  3171. */
  3172. negateToRef(result: Vector4): Vector4;
  3173. /**
  3174. * Multiplies the current Vector4 coordinates by scale (float).
  3175. * @param scale the number to scale with
  3176. * @returns the updated Vector4.
  3177. */
  3178. scaleInPlace(scale: number): Vector4;
  3179. /**
  3180. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3181. * @param scale the number to scale with
  3182. * @returns a new vector with the result
  3183. */
  3184. scale(scale: number): Vector4;
  3185. /**
  3186. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3187. * @param scale the number to scale with
  3188. * @param result a vector to store the result in
  3189. * @returns the current Vector4.
  3190. */
  3191. scaleToRef(scale: number, result: Vector4): Vector4;
  3192. /**
  3193. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3194. * @param scale defines the scale factor
  3195. * @param result defines the Vector4 object where to store the result
  3196. * @returns the unmodified current Vector4
  3197. */
  3198. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3199. /**
  3200. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3201. * @param otherVector the vector to compare against
  3202. * @returns true if they are equal
  3203. */
  3204. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3205. /**
  3206. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3207. * @param otherVector vector to compare against
  3208. * @param epsilon (Default: very small number)
  3209. * @returns true if they are equal
  3210. */
  3211. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3212. /**
  3213. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3214. * @param x x value to compare against
  3215. * @param y y value to compare against
  3216. * @param z z value to compare against
  3217. * @param w w value to compare against
  3218. * @returns true if equal
  3219. */
  3220. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3221. /**
  3222. * Multiplies in place the current Vector4 by the given one.
  3223. * @param otherVector vector to multiple with
  3224. * @returns the updated Vector4.
  3225. */
  3226. multiplyInPlace(otherVector: Vector4): Vector4;
  3227. /**
  3228. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3229. * @param otherVector vector to multiple with
  3230. * @returns resulting new vector
  3231. */
  3232. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3235. * @param otherVector vector to multiple with
  3236. * @param result vector to store the result
  3237. * @returns the current Vector4.
  3238. */
  3239. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3240. /**
  3241. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3242. * @param x x value multiply with
  3243. * @param y y value multiply with
  3244. * @param z z value multiply with
  3245. * @param w w value multiply with
  3246. * @returns resulting new vector
  3247. */
  3248. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3249. /**
  3250. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3251. * @param otherVector vector to devide with
  3252. * @returns resulting new vector
  3253. */
  3254. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3255. /**
  3256. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3257. * @param otherVector vector to devide with
  3258. * @param result vector to store the result
  3259. * @returns the current Vector4.
  3260. */
  3261. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3262. /**
  3263. * Divides the current Vector3 coordinates by the given ones.
  3264. * @param otherVector vector to devide with
  3265. * @returns the updated Vector3.
  3266. */
  3267. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3270. * @param other defines the second operand
  3271. * @returns the current updated Vector4
  3272. */
  3273. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3274. /**
  3275. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3276. * @param other defines the second operand
  3277. * @returns the current updated Vector4
  3278. */
  3279. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3280. /**
  3281. * Gets a new Vector4 from current Vector4 floored values
  3282. * @returns a new Vector4
  3283. */
  3284. floor(): Vector4;
  3285. /**
  3286. * Gets a new Vector4 from current Vector3 floored values
  3287. * @returns a new Vector4
  3288. */
  3289. fract(): Vector4;
  3290. /**
  3291. * Returns the Vector4 length (float).
  3292. * @returns the length
  3293. */
  3294. length(): number;
  3295. /**
  3296. * Returns the Vector4 squared length (float).
  3297. * @returns the length squared
  3298. */
  3299. lengthSquared(): number;
  3300. /**
  3301. * Normalizes in place the Vector4.
  3302. * @returns the updated Vector4.
  3303. */
  3304. normalize(): Vector4;
  3305. /**
  3306. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3307. * @returns this converted to a new vector3
  3308. */
  3309. toVector3(): Vector3;
  3310. /**
  3311. * Returns a new Vector4 copied from the current one.
  3312. * @returns the new cloned vector
  3313. */
  3314. clone(): Vector4;
  3315. /**
  3316. * Updates the current Vector4 with the given one coordinates.
  3317. * @param source the source vector to copy from
  3318. * @returns the updated Vector4.
  3319. */
  3320. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the current Vector4 coordinates with the given floats.
  3323. * @param x float to copy from
  3324. * @param y float to copy from
  3325. * @param z float to copy from
  3326. * @param w float to copy from
  3327. * @returns the updated Vector4.
  3328. */
  3329. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3330. /**
  3331. * Updates the current Vector4 coordinates with the given floats.
  3332. * @param x float to set from
  3333. * @param y float to set from
  3334. * @param z float to set from
  3335. * @param w float to set from
  3336. * @returns the updated Vector4.
  3337. */
  3338. set(x: number, y: number, z: number, w: number): Vector4;
  3339. /**
  3340. * Copies the given float to the current Vector3 coordinates
  3341. * @param v defines the x, y, z and w coordinates of the operand
  3342. * @returns the current updated Vector3
  3343. */
  3344. setAll(v: number): Vector4;
  3345. /**
  3346. * Returns a new Vector4 set from the starting index of the given array.
  3347. * @param array the array to pull values from
  3348. * @param offset the offset into the array to start at
  3349. * @returns the new vector
  3350. */
  3351. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3352. /**
  3353. * Updates the given vector "result" from the starting index of the given array.
  3354. * @param array the array to pull values from
  3355. * @param offset the offset into the array to start at
  3356. * @param result the vector to store the result in
  3357. */
  3358. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3359. /**
  3360. * Updates the given vector "result" from the starting index of the given Float32Array.
  3361. * @param array the array to pull values from
  3362. * @param offset the offset into the array to start at
  3363. * @param result the vector to store the result in
  3364. */
  3365. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3366. /**
  3367. * Updates the given vector "result" coordinates from the given floats.
  3368. * @param x float to set from
  3369. * @param y float to set from
  3370. * @param z float to set from
  3371. * @param w float to set from
  3372. * @param result the vector to the floats in
  3373. */
  3374. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3375. /**
  3376. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3377. * @returns the new vector
  3378. */
  3379. static Zero(): Vector4;
  3380. /**
  3381. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3382. * @returns the new vector
  3383. */
  3384. static One(): Vector4;
  3385. /**
  3386. * Returns a new normalized Vector4 from the given one.
  3387. * @param vector the vector to normalize
  3388. * @returns the vector
  3389. */
  3390. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the given vector "result" from the normalization of the given one.
  3393. * @param vector the vector to normalize
  3394. * @param result the vector to store the result in
  3395. */
  3396. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3397. /**
  3398. * Returns a vector with the minimum values from the left and right vectors
  3399. * @param left left vector to minimize
  3400. * @param right right vector to minimize
  3401. * @returns a new vector with the minimum of the left and right vector values
  3402. */
  3403. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Returns a vector with the maximum values from the left and right vectors
  3406. * @param left left vector to maximize
  3407. * @param right right vector to maximize
  3408. * @returns a new vector with the maximum of the left and right vector values
  3409. */
  3410. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3411. /**
  3412. * Returns the distance (float) between the vectors "value1" and "value2".
  3413. * @param value1 value to calulate the distance between
  3414. * @param value2 value to calulate the distance between
  3415. * @return the distance between the two vectors
  3416. */
  3417. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3418. /**
  3419. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3420. * @param value1 value to calulate the distance between
  3421. * @param value2 value to calulate the distance between
  3422. * @return the distance between the two vectors squared
  3423. */
  3424. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3425. /**
  3426. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3427. * @param value1 value to calulate the center between
  3428. * @param value2 value to calulate the center between
  3429. * @return the center between the two vectors
  3430. */
  3431. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3434. * This methods computes transformed normalized direction vectors only.
  3435. * @param vector the vector to transform
  3436. * @param transformation the transformation matrix to apply
  3437. * @returns the new vector
  3438. */
  3439. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3440. /**
  3441. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3442. * This methods computes transformed normalized direction vectors only.
  3443. * @param vector the vector to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the result in
  3446. */
  3447. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3450. * This methods computes transformed normalized direction vectors only.
  3451. * @param x value to transform
  3452. * @param y value to transform
  3453. * @param z value to transform
  3454. * @param w value to transform
  3455. * @param transformation the transformation matrix to apply
  3456. * @param result the vector to store the results in
  3457. */
  3458. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3459. /**
  3460. * Creates a new Vector4 from a Vector3
  3461. * @param source defines the source data
  3462. * @param w defines the 4th component (default is 0)
  3463. * @returns a new Vector4
  3464. */
  3465. static FromVector3(source: Vector3, w?: number): Vector4;
  3466. }
  3467. /**
  3468. * Class used to store quaternion data
  3469. * @see https://en.wikipedia.org/wiki/Quaternion
  3470. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3471. */
  3472. export class Quaternion {
  3473. /** defines the first component (0 by default) */
  3474. x: number;
  3475. /** defines the second component (0 by default) */
  3476. y: number;
  3477. /** defines the third component (0 by default) */
  3478. z: number;
  3479. /** defines the fourth component (1.0 by default) */
  3480. w: number;
  3481. /**
  3482. * Creates a new Quaternion from the given floats
  3483. * @param x defines the first component (0 by default)
  3484. * @param y defines the second component (0 by default)
  3485. * @param z defines the third component (0 by default)
  3486. * @param w defines the fourth component (1.0 by default)
  3487. */
  3488. constructor(
  3489. /** defines the first component (0 by default) */
  3490. x?: number,
  3491. /** defines the second component (0 by default) */
  3492. y?: number,
  3493. /** defines the third component (0 by default) */
  3494. z?: number,
  3495. /** defines the fourth component (1.0 by default) */
  3496. w?: number);
  3497. /**
  3498. * Gets a string representation for the current quaternion
  3499. * @returns a string with the Quaternion coordinates
  3500. */
  3501. toString(): string;
  3502. /**
  3503. * Gets the class name of the quaternion
  3504. * @returns the string "Quaternion"
  3505. */
  3506. getClassName(): string;
  3507. /**
  3508. * Gets a hash code for this quaternion
  3509. * @returns the quaternion hash code
  3510. */
  3511. getHashCode(): number;
  3512. /**
  3513. * Copy the quaternion to an array
  3514. * @returns a new array populated with 4 elements from the quaternion coordinates
  3515. */
  3516. asArray(): number[];
  3517. /**
  3518. * Check if two quaternions are equals
  3519. * @param otherQuaternion defines the second operand
  3520. * @return true if the current quaternion and the given one coordinates are strictly equals
  3521. */
  3522. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3523. /**
  3524. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3525. * @param otherQuaternion defines the other quaternion
  3526. * @param epsilon defines the minimal distance to consider equality
  3527. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3528. */
  3529. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3530. /**
  3531. * Clone the current quaternion
  3532. * @returns a new quaternion copied from the current one
  3533. */
  3534. clone(): Quaternion;
  3535. /**
  3536. * Copy a quaternion to the current one
  3537. * @param other defines the other quaternion
  3538. * @returns the updated current quaternion
  3539. */
  3540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3541. /**
  3542. * Updates the current quaternion with the given float coordinates
  3543. * @param x defines the x coordinate
  3544. * @param y defines the y coordinate
  3545. * @param z defines the z coordinate
  3546. * @param w defines the w coordinate
  3547. * @returns the updated current quaternion
  3548. */
  3549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3550. /**
  3551. * Updates the current quaternion from the given float coordinates
  3552. * @param x defines the x coordinate
  3553. * @param y defines the y coordinate
  3554. * @param z defines the z coordinate
  3555. * @param w defines the w coordinate
  3556. * @returns the updated current quaternion
  3557. */
  3558. set(x: number, y: number, z: number, w: number): Quaternion;
  3559. /**
  3560. * Adds two quaternions
  3561. * @param other defines the second operand
  3562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3563. */
  3564. add(other: DeepImmutable<Quaternion>): Quaternion;
  3565. /**
  3566. * Add a quaternion to the current one
  3567. * @param other defines the quaternion to add
  3568. * @returns the current quaternion
  3569. */
  3570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3571. /**
  3572. * Subtract two quaternions
  3573. * @param other defines the second operand
  3574. * @returns a new quaternion as the subtraction result of the given one from the current one
  3575. */
  3576. subtract(other: Quaternion): Quaternion;
  3577. /**
  3578. * Multiplies the current quaternion by a scale factor
  3579. * @param value defines the scale factor
  3580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3581. */
  3582. scale(value: number): Quaternion;
  3583. /**
  3584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3585. * @param scale defines the scale factor
  3586. * @param result defines the Quaternion object where to store the result
  3587. * @returns the unmodified current quaternion
  3588. */
  3589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3590. /**
  3591. * Multiplies in place the current quaternion by a scale factor
  3592. * @param value defines the scale factor
  3593. * @returns the current modified quaternion
  3594. */
  3595. scaleInPlace(value: number): Quaternion;
  3596. /**
  3597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3598. * @param scale defines the scale factor
  3599. * @param result defines the Quaternion object where to store the result
  3600. * @returns the unmodified current quaternion
  3601. */
  3602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies two quaternions
  3605. * @param q1 defines the second operand
  3606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3607. */
  3608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3609. /**
  3610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3611. * @param q1 defines the second operand
  3612. * @param result defines the target quaternion
  3613. * @returns the current quaternion
  3614. */
  3615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3616. /**
  3617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3618. * @param q1 defines the second operand
  3619. * @returns the currentupdated quaternion
  3620. */
  3621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3622. /**
  3623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3624. * @param ref defines the target quaternion
  3625. * @returns the current quaternion
  3626. */
  3627. conjugateToRef(ref: Quaternion): Quaternion;
  3628. /**
  3629. * Conjugates in place (1-q) the current quaternion
  3630. * @returns the current updated quaternion
  3631. */
  3632. conjugateInPlace(): Quaternion;
  3633. /**
  3634. * Conjugates in place (1-q) the current quaternion
  3635. * @returns a new quaternion
  3636. */
  3637. conjugate(): Quaternion;
  3638. /**
  3639. * Gets length of current quaternion
  3640. * @returns the quaternion length (float)
  3641. */
  3642. length(): number;
  3643. /**
  3644. * Normalize in place the current quaternion
  3645. * @returns the current updated quaternion
  3646. */
  3647. normalize(): Quaternion;
  3648. /**
  3649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3650. * @param order is a reserved parameter and is ignore for now
  3651. * @returns a new Vector3 containing the Euler angles
  3652. */
  3653. toEulerAngles(order?: string): Vector3;
  3654. /**
  3655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3656. * @param result defines the vector which will be filled with the Euler angles
  3657. * @param order is a reserved parameter and is ignore for now
  3658. * @returns the current unchanged quaternion
  3659. */
  3660. toEulerAnglesToRef(result: Vector3): Quaternion;
  3661. /**
  3662. * Updates the given rotation matrix with the current quaternion values
  3663. * @param result defines the target matrix
  3664. * @returns the current unchanged quaternion
  3665. */
  3666. toRotationMatrix(result: Matrix): Quaternion;
  3667. /**
  3668. * Updates the current quaternion from the given rotation matrix values
  3669. * @param matrix defines the source matrix
  3670. * @returns the current updated quaternion
  3671. */
  3672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3673. /**
  3674. * Creates a new quaternion from a rotation matrix
  3675. * @param matrix defines the source matrix
  3676. * @returns a new quaternion created from the given rotation matrix values
  3677. */
  3678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3679. /**
  3680. * Updates the given quaternion with the given rotation matrix values
  3681. * @param matrix defines the source matrix
  3682. * @param result defines the target quaternion
  3683. */
  3684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3685. /**
  3686. * Returns the dot product (float) between the quaternions "left" and "right"
  3687. * @param left defines the left operand
  3688. * @param right defines the right operand
  3689. * @returns the dot product
  3690. */
  3691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3692. /**
  3693. * Checks if the two quaternions are close to each other
  3694. * @param quat0 defines the first quaternion to check
  3695. * @param quat1 defines the second quaternion to check
  3696. * @returns true if the two quaternions are close to each other
  3697. */
  3698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3699. /**
  3700. * Creates an empty quaternion
  3701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3702. */
  3703. static Zero(): Quaternion;
  3704. /**
  3705. * Inverse a given quaternion
  3706. * @param q defines the source quaternion
  3707. * @returns a new quaternion as the inverted current quaternion
  3708. */
  3709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3710. /**
  3711. * Inverse a given quaternion
  3712. * @param q defines the source quaternion
  3713. * @param result the quaternion the result will be stored in
  3714. * @returns the result quaternion
  3715. */
  3716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3717. /**
  3718. * Creates an identity quaternion
  3719. * @returns the identity quaternion
  3720. */
  3721. static Identity(): Quaternion;
  3722. /**
  3723. * Gets a boolean indicating if the given quaternion is identity
  3724. * @param quaternion defines the quaternion to check
  3725. * @returns true if the quaternion is identity
  3726. */
  3727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3728. /**
  3729. * Creates a quaternion from a rotation around an axis
  3730. * @param axis defines the axis to use
  3731. * @param angle defines the angle to use
  3732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3733. */
  3734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3735. /**
  3736. * Creates a rotation around an axis and stores it into the given quaternion
  3737. * @param axis defines the axis to use
  3738. * @param angle defines the angle to use
  3739. * @param result defines the target quaternion
  3740. * @returns the target quaternion
  3741. */
  3742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3743. /**
  3744. * Creates a new quaternion from data stored into an array
  3745. * @param array defines the data source
  3746. * @param offset defines the offset in the source array where the data starts
  3747. * @returns a new quaternion
  3748. */
  3749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3750. /**
  3751. * Updates the given quaternion "result" from the starting index of the given array.
  3752. * @param array the array to pull values from
  3753. * @param offset the offset into the array to start at
  3754. * @param result the quaternion to store the result in
  3755. */
  3756. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3757. /**
  3758. * Create a quaternion from Euler rotation angles
  3759. * @param x Pitch
  3760. * @param y Yaw
  3761. * @param z Roll
  3762. * @returns the new Quaternion
  3763. */
  3764. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3765. /**
  3766. * Updates a quaternion from Euler rotation angles
  3767. * @param x Pitch
  3768. * @param y Yaw
  3769. * @param z Roll
  3770. * @param result the quaternion to store the result
  3771. * @returns the updated quaternion
  3772. */
  3773. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3774. /**
  3775. * Create a quaternion from Euler rotation vector
  3776. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3777. * @returns the new Quaternion
  3778. */
  3779. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3780. /**
  3781. * Updates a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @param result the quaternion to store the result
  3784. * @returns the updated quaternion
  3785. */
  3786. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3787. /**
  3788. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3789. * @param yaw defines the rotation around Y axis
  3790. * @param pitch defines the rotation around X axis
  3791. * @param roll defines the rotation around Z axis
  3792. * @returns the new quaternion
  3793. */
  3794. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3795. /**
  3796. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3797. * @param yaw defines the rotation around Y axis
  3798. * @param pitch defines the rotation around X axis
  3799. * @param roll defines the rotation around Z axis
  3800. * @param result defines the target quaternion
  3801. */
  3802. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3803. /**
  3804. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3805. * @param alpha defines the rotation around first axis
  3806. * @param beta defines the rotation around second axis
  3807. * @param gamma defines the rotation around third axis
  3808. * @returns the new quaternion
  3809. */
  3810. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3811. /**
  3812. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3813. * @param alpha defines the rotation around first axis
  3814. * @param beta defines the rotation around second axis
  3815. * @param gamma defines the rotation around third axis
  3816. * @param result defines the target quaternion
  3817. */
  3818. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3819. /**
  3820. * 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)
  3821. * @param axis1 defines the first axis
  3822. * @param axis2 defines the second axis
  3823. * @param axis3 defines the third axis
  3824. * @returns the new quaternion
  3825. */
  3826. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3827. /**
  3828. * 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
  3829. * @param axis1 defines the first axis
  3830. * @param axis2 defines the second axis
  3831. * @param axis3 defines the third axis
  3832. * @param ref defines the target quaternion
  3833. */
  3834. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3835. /**
  3836. * Interpolates between two quaternions
  3837. * @param left defines first quaternion
  3838. * @param right defines second quaternion
  3839. * @param amount defines the gradient to use
  3840. * @returns the new interpolated quaternion
  3841. */
  3842. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3843. /**
  3844. * Interpolates between two quaternions and stores it into a target quaternion
  3845. * @param left defines first quaternion
  3846. * @param right defines second quaternion
  3847. * @param amount defines the gradient to use
  3848. * @param result defines the target quaternion
  3849. */
  3850. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3851. /**
  3852. * Interpolate between two quaternions using Hermite interpolation
  3853. * @param value1 defines first quaternion
  3854. * @param tangent1 defines the incoming tangent
  3855. * @param value2 defines second quaternion
  3856. * @param tangent2 defines the outgoing tangent
  3857. * @param amount defines the target quaternion
  3858. * @returns the new interpolated quaternion
  3859. */
  3860. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3861. }
  3862. /**
  3863. * Class used to store matrix data (4x4)
  3864. */
  3865. export class Matrix {
  3866. private static _updateFlagSeed;
  3867. private static _identityReadOnly;
  3868. private _isIdentity;
  3869. private _isIdentityDirty;
  3870. private _isIdentity3x2;
  3871. private _isIdentity3x2Dirty;
  3872. /**
  3873. * Gets the update flag of the matrix which is an unique number for the matrix.
  3874. * It will be incremented every time the matrix data change.
  3875. * You can use it to speed the comparison between two versions of the same matrix.
  3876. */
  3877. updateFlag: number;
  3878. private readonly _m;
  3879. /**
  3880. * Gets the internal data of the matrix
  3881. */
  3882. get m(): DeepImmutable<Float32Array>;
  3883. /** @hidden */
  3884. _markAsUpdated(): void;
  3885. /** @hidden */
  3886. private _updateIdentityStatus;
  3887. /**
  3888. * Creates an empty matrix (filled with zeros)
  3889. */
  3890. constructor();
  3891. /**
  3892. * Check if the current matrix is identity
  3893. * @returns true is the matrix is the identity matrix
  3894. */
  3895. isIdentity(): boolean;
  3896. /**
  3897. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3898. * @returns true is the matrix is the identity matrix
  3899. */
  3900. isIdentityAs3x2(): boolean;
  3901. /**
  3902. * Gets the determinant of the matrix
  3903. * @returns the matrix determinant
  3904. */
  3905. determinant(): number;
  3906. /**
  3907. * Returns the matrix as a Float32Array
  3908. * @returns the matrix underlying array
  3909. */
  3910. toArray(): DeepImmutable<Float32Array>;
  3911. /**
  3912. * Returns the matrix as a Float32Array
  3913. * @returns the matrix underlying array.
  3914. */
  3915. asArray(): DeepImmutable<Float32Array>;
  3916. /**
  3917. * Inverts the current matrix in place
  3918. * @returns the current inverted matrix
  3919. */
  3920. invert(): Matrix;
  3921. /**
  3922. * Sets all the matrix elements to zero
  3923. * @returns the current matrix
  3924. */
  3925. reset(): Matrix;
  3926. /**
  3927. * Adds the current matrix with a second one
  3928. * @param other defines the matrix to add
  3929. * @returns a new matrix as the addition of the current matrix and the given one
  3930. */
  3931. add(other: DeepImmutable<Matrix>): Matrix;
  3932. /**
  3933. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3934. * @param other defines the matrix to add
  3935. * @param result defines the target matrix
  3936. * @returns the current matrix
  3937. */
  3938. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3939. /**
  3940. * Adds in place the given matrix to the current matrix
  3941. * @param other defines the second operand
  3942. * @returns the current updated matrix
  3943. */
  3944. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3945. /**
  3946. * Sets the given matrix to the current inverted Matrix
  3947. * @param other defines the target matrix
  3948. * @returns the unmodified current matrix
  3949. */
  3950. invertToRef(other: Matrix): Matrix;
  3951. /**
  3952. * add a value at the specified position in the current Matrix
  3953. * @param index the index of the value within the matrix. between 0 and 15.
  3954. * @param value the value to be added
  3955. * @returns the current updated matrix
  3956. */
  3957. addAtIndex(index: number, value: number): Matrix;
  3958. /**
  3959. * mutiply the specified position in the current Matrix by a value
  3960. * @param index the index of the value within the matrix. between 0 and 15.
  3961. * @param value the value to be added
  3962. * @returns the current updated matrix
  3963. */
  3964. multiplyAtIndex(index: number, value: number): Matrix;
  3965. /**
  3966. * Inserts the translation vector (using 3 floats) in the current matrix
  3967. * @param x defines the 1st component of the translation
  3968. * @param y defines the 2nd component of the translation
  3969. * @param z defines the 3rd component of the translation
  3970. * @returns the current updated matrix
  3971. */
  3972. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3973. /**
  3974. * Adds the translation vector (using 3 floats) in the current matrix
  3975. * @param x defines the 1st component of the translation
  3976. * @param y defines the 2nd component of the translation
  3977. * @param z defines the 3rd component of the translation
  3978. * @returns the current updated matrix
  3979. */
  3980. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3981. /**
  3982. * Inserts the translation vector in the current matrix
  3983. * @param vector3 defines the translation to insert
  3984. * @returns the current updated matrix
  3985. */
  3986. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3987. /**
  3988. * Gets the translation value of the current matrix
  3989. * @returns a new Vector3 as the extracted translation from the matrix
  3990. */
  3991. getTranslation(): Vector3;
  3992. /**
  3993. * Fill a Vector3 with the extracted translation from the matrix
  3994. * @param result defines the Vector3 where to store the translation
  3995. * @returns the current matrix
  3996. */
  3997. getTranslationToRef(result: Vector3): Matrix;
  3998. /**
  3999. * Remove rotation and scaling part from the matrix
  4000. * @returns the updated matrix
  4001. */
  4002. removeRotationAndScaling(): Matrix;
  4003. /**
  4004. * Multiply two matrices
  4005. * @param other defines the second operand
  4006. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4007. */
  4008. multiply(other: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Copy the current matrix from the given one
  4011. * @param other defines the source matrix
  4012. * @returns the current updated matrix
  4013. */
  4014. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Populates the given array from the starting index with the current matrix values
  4017. * @param array defines the target array
  4018. * @param offset defines the offset in the target array where to start storing values
  4019. * @returns the current matrix
  4020. */
  4021. copyToArray(array: Float32Array, offset?: number): Matrix;
  4022. /**
  4023. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4024. * @param other defines the second operand
  4025. * @param result defines the matrix where to store the multiplication
  4026. * @returns the current matrix
  4027. */
  4028. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4029. /**
  4030. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4031. * @param other defines the second operand
  4032. * @param result defines the array where to store the multiplication
  4033. * @param offset defines the offset in the target array where to start storing values
  4034. * @returns the current matrix
  4035. */
  4036. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4037. /**
  4038. * Check equality between this matrix and a second one
  4039. * @param value defines the second matrix to compare
  4040. * @returns true is the current matrix and the given one values are strictly equal
  4041. */
  4042. equals(value: DeepImmutable<Matrix>): boolean;
  4043. /**
  4044. * Clone the current matrix
  4045. * @returns a new matrix from the current matrix
  4046. */
  4047. clone(): Matrix;
  4048. /**
  4049. * Returns the name of the current matrix class
  4050. * @returns the string "Matrix"
  4051. */
  4052. getClassName(): string;
  4053. /**
  4054. * Gets the hash code of the current matrix
  4055. * @returns the hash code
  4056. */
  4057. getHashCode(): number;
  4058. /**
  4059. * Decomposes the current Matrix into a translation, rotation and scaling components
  4060. * @param scale defines the scale vector3 given as a reference to update
  4061. * @param rotation defines the rotation quaternion given as a reference to update
  4062. * @param translation defines the translation vector3 given as a reference to update
  4063. * @returns true if operation was successful
  4064. */
  4065. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4066. /**
  4067. * Gets specific row of the matrix
  4068. * @param index defines the number of the row to get
  4069. * @returns the index-th row of the current matrix as a new Vector4
  4070. */
  4071. getRow(index: number): Nullable<Vector4>;
  4072. /**
  4073. * Sets the index-th row of the current matrix to the vector4 values
  4074. * @param index defines the number of the row to set
  4075. * @param row defines the target vector4
  4076. * @returns the updated current matrix
  4077. */
  4078. setRow(index: number, row: Vector4): Matrix;
  4079. /**
  4080. * Compute the transpose of the matrix
  4081. * @returns the new transposed matrix
  4082. */
  4083. transpose(): Matrix;
  4084. /**
  4085. * Compute the transpose of the matrix and store it in a given matrix
  4086. * @param result defines the target matrix
  4087. * @returns the current matrix
  4088. */
  4089. transposeToRef(result: Matrix): Matrix;
  4090. /**
  4091. * Sets the index-th row of the current matrix with the given 4 x float values
  4092. * @param index defines the row index
  4093. * @param x defines the x component to set
  4094. * @param y defines the y component to set
  4095. * @param z defines the z component to set
  4096. * @param w defines the w component to set
  4097. * @returns the updated current matrix
  4098. */
  4099. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4100. /**
  4101. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4102. * @param scale defines the scale factor
  4103. * @returns a new matrix
  4104. */
  4105. scale(scale: number): Matrix;
  4106. /**
  4107. * Scale the current matrix values by a factor to a given result matrix
  4108. * @param scale defines the scale factor
  4109. * @param result defines the matrix to store the result
  4110. * @returns the current matrix
  4111. */
  4112. scaleToRef(scale: number, result: Matrix): Matrix;
  4113. /**
  4114. * Scale the current matrix values by a factor and add the result to a given matrix
  4115. * @param scale defines the scale factor
  4116. * @param result defines the Matrix to store the result
  4117. * @returns the current matrix
  4118. */
  4119. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4120. /**
  4121. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4122. * @param ref matrix to store the result
  4123. */
  4124. toNormalMatrix(ref: Matrix): void;
  4125. /**
  4126. * Gets only rotation part of the current matrix
  4127. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4128. */
  4129. getRotationMatrix(): Matrix;
  4130. /**
  4131. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4132. * @param result defines the target matrix to store data to
  4133. * @returns the current matrix
  4134. */
  4135. getRotationMatrixToRef(result: Matrix): Matrix;
  4136. /**
  4137. * Toggles model matrix from being right handed to left handed in place and vice versa
  4138. */
  4139. toggleModelMatrixHandInPlace(): void;
  4140. /**
  4141. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleProjectionMatrixHandInPlace(): void;
  4144. /**
  4145. * Creates a matrix from an array
  4146. * @param array defines the source array
  4147. * @param offset defines an offset in the source array
  4148. * @returns a new Matrix set from the starting index of the given array
  4149. */
  4150. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4151. /**
  4152. * Copy the content of an array into a given matrix
  4153. * @param array defines the source array
  4154. * @param offset defines an offset in the source array
  4155. * @param result defines the target matrix
  4156. */
  4157. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4158. /**
  4159. * Stores an array into a matrix after having multiplied each component by a given factor
  4160. * @param array defines the source array
  4161. * @param offset defines the offset in the source array
  4162. * @param scale defines the scaling factor
  4163. * @param result defines the target matrix
  4164. */
  4165. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4166. /**
  4167. * Gets an identity matrix that must not be updated
  4168. */
  4169. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4170. /**
  4171. * Stores a list of values (16) inside a given matrix
  4172. * @param initialM11 defines 1st value of 1st row
  4173. * @param initialM12 defines 2nd value of 1st row
  4174. * @param initialM13 defines 3rd value of 1st row
  4175. * @param initialM14 defines 4th value of 1st row
  4176. * @param initialM21 defines 1st value of 2nd row
  4177. * @param initialM22 defines 2nd value of 2nd row
  4178. * @param initialM23 defines 3rd value of 2nd row
  4179. * @param initialM24 defines 4th value of 2nd row
  4180. * @param initialM31 defines 1st value of 3rd row
  4181. * @param initialM32 defines 2nd value of 3rd row
  4182. * @param initialM33 defines 3rd value of 3rd row
  4183. * @param initialM34 defines 4th value of 3rd row
  4184. * @param initialM41 defines 1st value of 4th row
  4185. * @param initialM42 defines 2nd value of 4th row
  4186. * @param initialM43 defines 3rd value of 4th row
  4187. * @param initialM44 defines 4th value of 4th row
  4188. * @param result defines the target matrix
  4189. */
  4190. 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;
  4191. /**
  4192. * Creates new matrix from a list of values (16)
  4193. * @param initialM11 defines 1st value of 1st row
  4194. * @param initialM12 defines 2nd value of 1st row
  4195. * @param initialM13 defines 3rd value of 1st row
  4196. * @param initialM14 defines 4th value of 1st row
  4197. * @param initialM21 defines 1st value of 2nd row
  4198. * @param initialM22 defines 2nd value of 2nd row
  4199. * @param initialM23 defines 3rd value of 2nd row
  4200. * @param initialM24 defines 4th value of 2nd row
  4201. * @param initialM31 defines 1st value of 3rd row
  4202. * @param initialM32 defines 2nd value of 3rd row
  4203. * @param initialM33 defines 3rd value of 3rd row
  4204. * @param initialM34 defines 4th value of 3rd row
  4205. * @param initialM41 defines 1st value of 4th row
  4206. * @param initialM42 defines 2nd value of 4th row
  4207. * @param initialM43 defines 3rd value of 4th row
  4208. * @param initialM44 defines 4th value of 4th row
  4209. * @returns the new matrix
  4210. */
  4211. 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;
  4212. /**
  4213. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4214. * @param scale defines the scale vector3
  4215. * @param rotation defines the rotation quaternion
  4216. * @param translation defines the translation vector3
  4217. * @returns a new matrix
  4218. */
  4219. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4220. /**
  4221. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4222. * @param scale defines the scale vector3
  4223. * @param rotation defines the rotation quaternion
  4224. * @param translation defines the translation vector3
  4225. * @param result defines the target matrix
  4226. */
  4227. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4228. /**
  4229. * Creates a new identity matrix
  4230. * @returns a new identity matrix
  4231. */
  4232. static Identity(): Matrix;
  4233. /**
  4234. * Creates a new identity matrix and stores the result in a given matrix
  4235. * @param result defines the target matrix
  4236. */
  4237. static IdentityToRef(result: Matrix): void;
  4238. /**
  4239. * Creates a new zero matrix
  4240. * @returns a new zero matrix
  4241. */
  4242. static Zero(): Matrix;
  4243. /**
  4244. * Creates a new rotation matrix for "angle" radians around the X axis
  4245. * @param angle defines the angle (in radians) to use
  4246. * @return the new matrix
  4247. */
  4248. static RotationX(angle: number): Matrix;
  4249. /**
  4250. * Creates a new matrix as the invert of a given matrix
  4251. * @param source defines the source matrix
  4252. * @returns the new matrix
  4253. */
  4254. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4257. * @param angle defines the angle (in radians) to use
  4258. * @param result defines the target matrix
  4259. */
  4260. static RotationXToRef(angle: number, result: Matrix): void;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the Y axis
  4263. * @param angle defines the angle (in radians) to use
  4264. * @return the new matrix
  4265. */
  4266. static RotationY(angle: number): Matrix;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4269. * @param angle defines the angle (in radians) to use
  4270. * @param result defines the target matrix
  4271. */
  4272. static RotationYToRef(angle: number, result: Matrix): void;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Z axis
  4275. * @param angle defines the angle (in radians) to use
  4276. * @return the new matrix
  4277. */
  4278. static RotationZ(angle: number): Matrix;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4281. * @param angle defines the angle (in radians) to use
  4282. * @param result defines the target matrix
  4283. */
  4284. static RotationZToRef(angle: number, result: Matrix): void;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the given axis
  4287. * @param axis defines the axis to use
  4288. * @param angle defines the angle (in radians) to use
  4289. * @return the new matrix
  4290. */
  4291. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4292. /**
  4293. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4294. * @param axis defines the axis to use
  4295. * @param angle defines the angle (in radians) to use
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4299. /**
  4300. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4301. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4302. * @param from defines the vector to align
  4303. * @param to defines the vector to align to
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4307. /**
  4308. * Creates a rotation matrix
  4309. * @param yaw defines the yaw angle in radians (Y axis)
  4310. * @param pitch defines the pitch angle in radians (X axis)
  4311. * @param roll defines the roll angle in radians (X axis)
  4312. * @returns the new rotation matrix
  4313. */
  4314. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4315. /**
  4316. * Creates a rotation matrix and stores it in a given matrix
  4317. * @param yaw defines the yaw angle in radians (Y axis)
  4318. * @param pitch defines the pitch angle in radians (X axis)
  4319. * @param roll defines the roll angle in radians (X axis)
  4320. * @param result defines the target matrix
  4321. */
  4322. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4323. /**
  4324. * Creates a scaling matrix
  4325. * @param x defines the scale factor on X axis
  4326. * @param y defines the scale factor on Y axis
  4327. * @param z defines the scale factor on Z axis
  4328. * @returns the new matrix
  4329. */
  4330. static Scaling(x: number, y: number, z: number): Matrix;
  4331. /**
  4332. * Creates a scaling matrix and stores it in a given matrix
  4333. * @param x defines the scale factor on X axis
  4334. * @param y defines the scale factor on Y axis
  4335. * @param z defines the scale factor on Z axis
  4336. * @param result defines the target matrix
  4337. */
  4338. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4339. /**
  4340. * Creates a translation matrix
  4341. * @param x defines the translation on X axis
  4342. * @param y defines the translation on Y axis
  4343. * @param z defines the translationon Z axis
  4344. * @returns the new matrix
  4345. */
  4346. static Translation(x: number, y: number, z: number): Matrix;
  4347. /**
  4348. * Creates a translation matrix and stores it in a given matrix
  4349. * @param x defines the translation on X axis
  4350. * @param y defines the translation on Y axis
  4351. * @param z defines the translationon Z axis
  4352. * @param result defines the target matrix
  4353. */
  4354. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4355. /**
  4356. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4357. * @param startValue defines the start value
  4358. * @param endValue defines the end value
  4359. * @param gradient defines the gradient factor
  4360. * @returns the new matrix
  4361. */
  4362. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4363. /**
  4364. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4365. * @param startValue defines the start value
  4366. * @param endValue defines the end value
  4367. * @param gradient defines the gradient factor
  4368. * @param result defines the Matrix object where to store data
  4369. */
  4370. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4371. /**
  4372. * Builds a new matrix whose values 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. * @returns the new matrix
  4380. */
  4381. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4382. /**
  4383. * Update a matrix to values which are computed by:
  4384. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4385. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4386. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4387. * @param startValue defines the first matrix
  4388. * @param endValue defines the second matrix
  4389. * @param gradient defines the gradient between the two matrices
  4390. * @param result defines the target matrix
  4391. */
  4392. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * 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"
  4395. * This function works in left handed mode
  4396. * @param eye defines the final position of the entity
  4397. * @param target defines where the entity should look at
  4398. * @param up defines the up vector for the entity
  4399. * @returns the new matrix
  4400. */
  4401. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4402. /**
  4403. * 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".
  4404. * This function works in left handed mode
  4405. * @param eye defines the final position of the entity
  4406. * @param target defines where the entity should look at
  4407. * @param up defines the up vector for the entity
  4408. * @param result defines the target matrix
  4409. */
  4410. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4411. /**
  4412. * 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"
  4413. * This function works in right handed mode
  4414. * @param eye defines the final position of the entity
  4415. * @param target defines where the entity should look at
  4416. * @param up defines the up vector for the entity
  4417. * @returns the new matrix
  4418. */
  4419. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4420. /**
  4421. * 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".
  4422. * This function works in right handed mode
  4423. * @param eye defines the final position of the entity
  4424. * @param target defines where the entity should look at
  4425. * @param up defines the up vector for the entity
  4426. * @param result defines the target matrix
  4427. */
  4428. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Create a left-handed orthographic projection matrix
  4431. * @param width defines the viewport width
  4432. * @param height defines the viewport height
  4433. * @param znear defines the near clip plane
  4434. * @param zfar defines the far clip plane
  4435. * @returns a new matrix as a left-handed orthographic projection matrix
  4436. */
  4437. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4438. /**
  4439. * Store a left-handed orthographic projection to a given matrix
  4440. * @param width defines the viewport width
  4441. * @param height defines the viewport height
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @param result defines the target matrix
  4445. */
  4446. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4447. /**
  4448. * Create a left-handed orthographic projection 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. * @returns a new matrix as a left-handed orthographic projection matrix
  4456. */
  4457. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4458. /**
  4459. * Stores a left-handed orthographic projection into a given 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. * @param result defines the target matrix
  4467. */
  4468. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Creates a right-handed orthographic projection 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. * @returns a new matrix as a right-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a right-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a left-handed perspective projection matrix
  4493. * @param width defines the viewport width
  4494. * @param height defines the viewport height
  4495. * @param znear defines the near clip plane
  4496. * @param zfar defines the far clip plane
  4497. * @returns a new matrix as a left-handed perspective projection matrix
  4498. */
  4499. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4500. /**
  4501. * Creates a left-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a left-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a left-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Creates a right-handed perspective projection matrix
  4531. * @param fov defines the horizontal field of view
  4532. * @param aspect defines the aspect ratio
  4533. * @param znear defines the near clip plane
  4534. * @param zfar defines the far clip plane
  4535. * @returns a new matrix as a right-handed perspective projection matrix
  4536. */
  4537. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4538. /**
  4539. * Stores a right-handed perspective projection into a given matrix
  4540. * @param fov defines the horizontal field of view
  4541. * @param aspect defines the aspect ratio
  4542. * @param znear defines the near clip plane
  4543. * @param zfar defines the far clip plane
  4544. * @param result defines the target matrix
  4545. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4546. */
  4547. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4548. /**
  4549. * Stores a right-handed perspective projection into a given matrix
  4550. * @param fov defines the horizontal field of view
  4551. * @param aspect defines the aspect ratio
  4552. * @param znear defines the near clip plane
  4553. * @param zfar not used as infinity is used as far clip
  4554. * @param result defines the target matrix
  4555. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4556. */
  4557. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4558. /**
  4559. * Stores a perspective projection for WebVR info a given matrix
  4560. * @param fov defines the field of view
  4561. * @param znear defines the near clip plane
  4562. * @param zfar defines the far clip plane
  4563. * @param result defines the target matrix
  4564. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4565. */
  4566. static PerspectiveFovWebVRToRef(fov: {
  4567. upDegrees: number;
  4568. downDegrees: number;
  4569. leftDegrees: number;
  4570. rightDegrees: number;
  4571. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4572. /**
  4573. * Computes a complete transformation matrix
  4574. * @param viewport defines the viewport to use
  4575. * @param world defines the world matrix
  4576. * @param view defines the view matrix
  4577. * @param projection defines the projection matrix
  4578. * @param zmin defines the near clip plane
  4579. * @param zmax defines the far clip plane
  4580. * @returns the transformation matrix
  4581. */
  4582. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4583. /**
  4584. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4585. * @param matrix defines the matrix to use
  4586. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4587. */
  4588. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4589. /**
  4590. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Compute the transpose of a given matrix
  4597. * @param matrix defines the matrix to transpose
  4598. * @returns the new matrix
  4599. */
  4600. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4601. /**
  4602. * Compute the transpose of a matrix and store it in a target matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @param result defines the target matrix
  4605. */
  4606. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4607. /**
  4608. * Computes a reflection matrix from a plane
  4609. * @param plane defines the reflection plane
  4610. * @returns a new matrix
  4611. */
  4612. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @param result defines the target matrix
  4617. */
  4618. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4619. /**
  4620. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4621. * @param xaxis defines the value of the 1st axis
  4622. * @param yaxis defines the value of the 2nd axis
  4623. * @param zaxis defines the value of the 3rd axis
  4624. * @param result defines the target matrix
  4625. */
  4626. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4627. /**
  4628. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4629. * @param quat defines the quaternion to use
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4633. }
  4634. /**
  4635. * @hidden
  4636. */
  4637. export class TmpVectors {
  4638. static Vector2: Vector2[];
  4639. static Vector3: Vector3[];
  4640. static Vector4: Vector4[];
  4641. static Quaternion: Quaternion[];
  4642. static Matrix: Matrix[];
  4643. }
  4644. }
  4645. declare module BABYLON {
  4646. /**
  4647. * Defines potential orientation for back face culling
  4648. */
  4649. export enum Orientation {
  4650. /**
  4651. * Clockwise
  4652. */
  4653. CW = 0,
  4654. /** Counter clockwise */
  4655. CCW = 1
  4656. }
  4657. /** Class used to represent a Bezier curve */
  4658. export class BezierCurve {
  4659. /**
  4660. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4661. * @param t defines the time
  4662. * @param x1 defines the left coordinate on X axis
  4663. * @param y1 defines the left coordinate on Y axis
  4664. * @param x2 defines the right coordinate on X axis
  4665. * @param y2 defines the right coordinate on Y axis
  4666. * @returns the interpolated value
  4667. */
  4668. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4669. }
  4670. /**
  4671. * Defines angle representation
  4672. */
  4673. export class Angle {
  4674. private _radians;
  4675. /**
  4676. * Creates an Angle object of "radians" radians (float).
  4677. * @param radians the angle in radians
  4678. */
  4679. constructor(radians: number);
  4680. /**
  4681. * Get value in degrees
  4682. * @returns the Angle value in degrees (float)
  4683. */
  4684. degrees(): number;
  4685. /**
  4686. * Get value in radians
  4687. * @returns the Angle value in radians (float)
  4688. */
  4689. radians(): number;
  4690. /**
  4691. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4692. * @param a defines first vector
  4693. * @param b defines second vector
  4694. * @returns a new Angle
  4695. */
  4696. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4697. /**
  4698. * Gets a new Angle object from the given float in radians
  4699. * @param radians defines the angle value in radians
  4700. * @returns a new Angle
  4701. */
  4702. static FromRadians(radians: number): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in degrees
  4705. * @param degrees defines the angle value in degrees
  4706. * @returns a new Angle
  4707. */
  4708. static FromDegrees(degrees: number): Angle;
  4709. }
  4710. /**
  4711. * This represents an arc in a 2d space.
  4712. */
  4713. export class Arc2 {
  4714. /** Defines the start point of the arc */
  4715. startPoint: Vector2;
  4716. /** Defines the mid point of the arc */
  4717. midPoint: Vector2;
  4718. /** Defines the end point of the arc */
  4719. endPoint: Vector2;
  4720. /**
  4721. * Defines the center point of the arc.
  4722. */
  4723. centerPoint: Vector2;
  4724. /**
  4725. * Defines the radius of the arc.
  4726. */
  4727. radius: number;
  4728. /**
  4729. * Defines the angle of the arc (from mid point to end point).
  4730. */
  4731. angle: Angle;
  4732. /**
  4733. * Defines the start angle of the arc (from start point to middle point).
  4734. */
  4735. startAngle: Angle;
  4736. /**
  4737. * Defines the orientation of the arc (clock wise/counter clock wise).
  4738. */
  4739. orientation: Orientation;
  4740. /**
  4741. * Creates an Arc object from the three given points : start, middle and end.
  4742. * @param startPoint Defines the start point of the arc
  4743. * @param midPoint Defines the midlle point of the arc
  4744. * @param endPoint Defines the end point of the arc
  4745. */
  4746. constructor(
  4747. /** Defines the start point of the arc */
  4748. startPoint: Vector2,
  4749. /** Defines the mid point of the arc */
  4750. midPoint: Vector2,
  4751. /** Defines the end point of the arc */
  4752. endPoint: Vector2);
  4753. }
  4754. /**
  4755. * Represents a 2D path made up of multiple 2D points
  4756. */
  4757. export class Path2 {
  4758. private _points;
  4759. private _length;
  4760. /**
  4761. * If the path start and end point are the same
  4762. */
  4763. closed: boolean;
  4764. /**
  4765. * Creates a Path2 object from the starting 2D coordinates x and y.
  4766. * @param x the starting points x value
  4767. * @param y the starting points y value
  4768. */
  4769. constructor(x: number, y: number);
  4770. /**
  4771. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4772. * @param x the added points x value
  4773. * @param y the added points y value
  4774. * @returns the updated Path2.
  4775. */
  4776. addLineTo(x: number, y: number): Path2;
  4777. /**
  4778. * 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.
  4779. * @param midX middle point x value
  4780. * @param midY middle point y value
  4781. * @param endX end point x value
  4782. * @param endY end point y value
  4783. * @param numberOfSegments (default: 36)
  4784. * @returns the updated Path2.
  4785. */
  4786. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4787. /**
  4788. * Closes the Path2.
  4789. * @returns the Path2.
  4790. */
  4791. close(): Path2;
  4792. /**
  4793. * Gets the sum of the distance between each sequential point in the path
  4794. * @returns the Path2 total length (float).
  4795. */
  4796. length(): number;
  4797. /**
  4798. * Gets the points which construct the path
  4799. * @returns the Path2 internal array of points.
  4800. */
  4801. getPoints(): Vector2[];
  4802. /**
  4803. * Retreives the point at the distance aways from the starting point
  4804. * @param normalizedLengthPosition the length along the path to retreive the point from
  4805. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4806. */
  4807. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4808. /**
  4809. * Creates a new path starting from an x and y position
  4810. * @param x starting x value
  4811. * @param y starting y value
  4812. * @returns a new Path2 starting at the coordinates (x, y).
  4813. */
  4814. static StartingAt(x: number, y: number): Path2;
  4815. }
  4816. /**
  4817. * Represents a 3D path made up of multiple 3D points
  4818. */
  4819. export class Path3D {
  4820. /**
  4821. * an array of Vector3, the curve axis of the Path3D
  4822. */
  4823. path: Vector3[];
  4824. private _curve;
  4825. private _distances;
  4826. private _tangents;
  4827. private _normals;
  4828. private _binormals;
  4829. private _raw;
  4830. private _alignTangentsWithPath;
  4831. private readonly _pointAtData;
  4832. /**
  4833. * new Path3D(path, normal, raw)
  4834. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4835. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4836. * @param path an array of Vector3, the curve axis of the Path3D
  4837. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4838. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4839. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4840. */
  4841. constructor(
  4842. /**
  4843. * an array of Vector3, the curve axis of the Path3D
  4844. */
  4845. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4846. /**
  4847. * Returns the Path3D array of successive Vector3 designing its curve.
  4848. * @returns the Path3D array of successive Vector3 designing its curve.
  4849. */
  4850. getCurve(): Vector3[];
  4851. /**
  4852. * Returns the Path3D array of successive Vector3 designing its curve.
  4853. * @returns the Path3D array of successive Vector3 designing its curve.
  4854. */
  4855. getPoints(): Vector3[];
  4856. /**
  4857. * @returns the computed length (float) of the path.
  4858. */
  4859. length(): number;
  4860. /**
  4861. * Returns an array populated with tangent vectors on each Path3D curve point.
  4862. * @returns an array populated with tangent vectors on each Path3D curve point.
  4863. */
  4864. getTangents(): Vector3[];
  4865. /**
  4866. * Returns an array populated with normal vectors on each Path3D curve point.
  4867. * @returns an array populated with normal vectors on each Path3D curve point.
  4868. */
  4869. getNormals(): Vector3[];
  4870. /**
  4871. * Returns an array populated with binormal vectors on each Path3D curve point.
  4872. * @returns an array populated with binormal vectors on each Path3D curve point.
  4873. */
  4874. getBinormals(): Vector3[];
  4875. /**
  4876. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4877. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4878. */
  4879. getDistances(): number[];
  4880. /**
  4881. * Returns an interpolated point along this path
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns a new Vector3 as the point
  4884. */
  4885. getPointAt(position: number): Vector3;
  4886. /**
  4887. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4890. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4891. */
  4892. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4893. /**
  4894. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4895. * @param position the position of the point along this path, from 0.0 to 1.0
  4896. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4897. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4898. */
  4899. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4900. /**
  4901. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4902. * @param position the position of the point along this path, from 0.0 to 1.0
  4903. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4904. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4905. */
  4906. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4907. /**
  4908. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4909. * @param position the position of the point along this path, from 0.0 to 1.0
  4910. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4911. */
  4912. getDistanceAt(position: number): number;
  4913. /**
  4914. * Returns the array index of the previous point of an interpolated point along this path
  4915. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4916. * @returns the array index
  4917. */
  4918. getPreviousPointIndexAt(position: number): number;
  4919. /**
  4920. * 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)
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the sub position
  4923. */
  4924. getSubPositionAt(position: number): number;
  4925. /**
  4926. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4927. * @param target the vector of which to get the closest position to
  4928. * @returns the position of the closest virtual point on this path to the target vector
  4929. */
  4930. getClosestPositionTo(target: Vector3): number;
  4931. /**
  4932. * Returns a sub path (slice) of this path
  4933. * @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
  4934. * @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
  4935. * @returns a sub path (slice) of this path
  4936. */
  4937. slice(start?: number, end?: number): Path3D;
  4938. /**
  4939. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4940. * @param path path which all values are copied into the curves points
  4941. * @param firstNormal which should be projected onto the curve
  4942. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4943. * @returns the same object updated.
  4944. */
  4945. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4946. private _compute;
  4947. private _getFirstNonNullVector;
  4948. private _getLastNonNullVector;
  4949. private _normalVector;
  4950. /**
  4951. * Updates the point at data for an interpolated point along this curve
  4952. * @param position the position of the point along this curve, from 0.0 to 1.0
  4953. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4954. * @returns the (updated) point at data
  4955. */
  4956. private _updatePointAtData;
  4957. /**
  4958. * Updates the point at data from the specified parameters
  4959. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4960. * @param point the interpolated point
  4961. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4962. */
  4963. private _setPointAtData;
  4964. /**
  4965. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4966. */
  4967. private _updateInterpolationMatrix;
  4968. }
  4969. /**
  4970. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4971. * A Curve3 is designed from a series of successive Vector3.
  4972. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4973. */
  4974. export class Curve3 {
  4975. private _points;
  4976. private _length;
  4977. /**
  4978. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4979. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4980. * @param v1 (Vector3) the control point
  4981. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4982. * @param nbPoints (integer) the wanted number of points in the curve
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4986. /**
  4987. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4988. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4989. * @param v1 (Vector3) the first control point
  4990. * @param v2 (Vector3) the second control point
  4991. * @param v3 (Vector3) the end point of the Cubic Bezier
  4992. * @param nbPoints (integer) the wanted number of points in the curve
  4993. * @returns the created Curve3
  4994. */
  4995. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4996. /**
  4997. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4998. * @param p1 (Vector3) the origin point of the Hermite Spline
  4999. * @param t1 (Vector3) the tangent vector at the origin point
  5000. * @param p2 (Vector3) the end point of the Hermite Spline
  5001. * @param t2 (Vector3) the tangent vector at the end point
  5002. * @param nbPoints (integer) the wanted number of points in the curve
  5003. * @returns the created Curve3
  5004. */
  5005. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5006. /**
  5007. * Returns a Curve3 object along a CatmullRom Spline curve :
  5008. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5009. * @param nbPoints (integer) the wanted number of points between each curve control points
  5010. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5014. /**
  5015. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5016. * A Curve3 is designed from a series of successive Vector3.
  5017. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5018. * @param points points which make up the curve
  5019. */
  5020. constructor(points: Vector3[]);
  5021. /**
  5022. * @returns the Curve3 stored array of successive Vector3
  5023. */
  5024. getPoints(): Vector3[];
  5025. /**
  5026. * @returns the computed length (float) of the curve.
  5027. */
  5028. length(): number;
  5029. /**
  5030. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5031. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5032. * curveA and curveB keep unchanged.
  5033. * @param curve the curve to continue from this curve
  5034. * @returns the newly constructed curve
  5035. */
  5036. continue(curve: DeepImmutable<Curve3>): Curve3;
  5037. private _computeLength;
  5038. }
  5039. }
  5040. declare module BABYLON {
  5041. /**
  5042. * This represents the main contract an easing function should follow.
  5043. * Easing functions are used throughout the animation system.
  5044. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5045. */
  5046. export interface IEasingFunction {
  5047. /**
  5048. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5049. * of the easing function.
  5050. * The link below provides some of the most common examples of easing functions.
  5051. * @see https://easings.net/
  5052. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5053. * @returns the corresponding value on the curve defined by the easing function
  5054. */
  5055. ease(gradient: number): number;
  5056. }
  5057. /**
  5058. * Base class used for every default easing function.
  5059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5060. */
  5061. export class EasingFunction implements IEasingFunction {
  5062. /**
  5063. * Interpolation follows the mathematical formula associated with the easing function.
  5064. */
  5065. static readonly EASINGMODE_EASEIN: number;
  5066. /**
  5067. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5068. */
  5069. static readonly EASINGMODE_EASEOUT: number;
  5070. /**
  5071. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5072. */
  5073. static readonly EASINGMODE_EASEINOUT: number;
  5074. private _easingMode;
  5075. /**
  5076. * Sets the easing mode of the current function.
  5077. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5078. */
  5079. setEasingMode(easingMode: number): void;
  5080. /**
  5081. * Gets the current easing mode.
  5082. * @returns the easing mode
  5083. */
  5084. getEasingMode(): number;
  5085. /**
  5086. * @hidden
  5087. */
  5088. easeInCore(gradient: number): number;
  5089. /**
  5090. * Given an input gradient between 0 and 1, this returns the corresponding value
  5091. * of the easing function.
  5092. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5093. * @returns the corresponding value on the curve defined by the easing function
  5094. */
  5095. ease(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a circle shape (see link below).
  5099. * @see https://easings.net/#easeInCirc
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class CircleEase extends EasingFunction implements IEasingFunction {
  5103. /** @hidden */
  5104. easeInCore(gradient: number): number;
  5105. }
  5106. /**
  5107. * Easing function with a ease back shape (see link below).
  5108. * @see https://easings.net/#easeInBack
  5109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5110. */
  5111. export class BackEase extends EasingFunction implements IEasingFunction {
  5112. /** Defines the amplitude of the function */
  5113. amplitude: number;
  5114. /**
  5115. * Instantiates a back ease easing
  5116. * @see https://easings.net/#easeInBack
  5117. * @param amplitude Defines the amplitude of the function
  5118. */
  5119. constructor(
  5120. /** Defines the amplitude of the function */
  5121. amplitude?: number);
  5122. /** @hidden */
  5123. easeInCore(gradient: number): number;
  5124. }
  5125. /**
  5126. * Easing function with a bouncing shape (see link below).
  5127. * @see https://easings.net/#easeInBounce
  5128. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5129. */
  5130. export class BounceEase extends EasingFunction implements IEasingFunction {
  5131. /** Defines the number of bounces */
  5132. bounces: number;
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness: number;
  5135. /**
  5136. * Instantiates a bounce easing
  5137. * @see https://easings.net/#easeInBounce
  5138. * @param bounces Defines the number of bounces
  5139. * @param bounciness Defines the amplitude of the bounce
  5140. */
  5141. constructor(
  5142. /** Defines the number of bounces */
  5143. bounces?: number,
  5144. /** Defines the amplitude of the bounce */
  5145. bounciness?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a power of 3 shape (see link below).
  5151. * @see https://easings.net/#easeInCubic
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class CubicEase extends EasingFunction implements IEasingFunction {
  5155. /** @hidden */
  5156. easeInCore(gradient: number): number;
  5157. }
  5158. /**
  5159. * Easing function with an elastic shape (see link below).
  5160. * @see https://easings.net/#easeInElastic
  5161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5162. */
  5163. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5164. /** Defines the number of oscillations*/
  5165. oscillations: number;
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness: number;
  5168. /**
  5169. * Instantiates an elastic easing function
  5170. * @see https://easings.net/#easeInElastic
  5171. * @param oscillations Defines the number of oscillations
  5172. * @param springiness Defines the amplitude of the oscillations
  5173. */
  5174. constructor(
  5175. /** Defines the number of oscillations*/
  5176. oscillations?: number,
  5177. /** Defines the amplitude of the oscillations*/
  5178. springiness?: number);
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an exponential shape (see link below).
  5184. * @see https://easings.net/#easeInExpo
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the exponent of the function */
  5189. exponent: number;
  5190. /**
  5191. * Instantiates an exponential easing function
  5192. * @see https://easings.net/#easeInExpo
  5193. * @param exponent Defines the exponent of the function
  5194. */
  5195. constructor(
  5196. /** Defines the exponent of the function */
  5197. exponent?: number);
  5198. /** @hidden */
  5199. easeInCore(gradient: number): number;
  5200. }
  5201. /**
  5202. * Easing function with a power shape (see link below).
  5203. * @see https://easings.net/#easeInQuad
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export class PowerEase extends EasingFunction implements IEasingFunction {
  5207. /** Defines the power of the function */
  5208. power: number;
  5209. /**
  5210. * Instantiates an power base easing function
  5211. * @see https://easings.net/#easeInQuad
  5212. * @param power Defines the power of the function
  5213. */
  5214. constructor(
  5215. /** Defines the power of the function */
  5216. power?: number);
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a power of 2 shape (see link below).
  5222. * @see https://easings.net/#easeInQuad
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a power of 4 shape (see link below).
  5231. * @see https://easings.net/#easeInQuart
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5235. /** @hidden */
  5236. easeInCore(gradient: number): number;
  5237. }
  5238. /**
  5239. * Easing function with a power of 5 shape (see link below).
  5240. * @see https://easings.net/#easeInQuint
  5241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5242. */
  5243. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a sin shape (see link below).
  5249. * @see https://easings.net/#easeInSine
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class SineEase extends EasingFunction implements IEasingFunction {
  5253. /** @hidden */
  5254. easeInCore(gradient: number): number;
  5255. }
  5256. /**
  5257. * Easing function with a bezier shape (see link below).
  5258. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5260. */
  5261. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5262. /** Defines the x component of the start tangent in the bezier curve */
  5263. x1: number;
  5264. /** Defines the y component of the start tangent in the bezier curve */
  5265. y1: number;
  5266. /** Defines the x component of the end tangent in the bezier curve */
  5267. x2: number;
  5268. /** Defines the y component of the end tangent in the bezier curve */
  5269. y2: number;
  5270. /**
  5271. * Instantiates a bezier function
  5272. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5273. * @param x1 Defines the x component of the start tangent in the bezier curve
  5274. * @param y1 Defines the y component of the start tangent in the bezier curve
  5275. * @param x2 Defines the x component of the end tangent in the bezier curve
  5276. * @param y2 Defines the y component of the end tangent in the bezier curve
  5277. */
  5278. constructor(
  5279. /** Defines the x component of the start tangent in the bezier curve */
  5280. x1?: number,
  5281. /** Defines the y component of the start tangent in the bezier curve */
  5282. y1?: number,
  5283. /** Defines the x component of the end tangent in the bezier curve */
  5284. x2?: number,
  5285. /** Defines the y component of the end tangent in the bezier curve */
  5286. y2?: number);
  5287. /** @hidden */
  5288. easeInCore(gradient: number): number;
  5289. }
  5290. }
  5291. declare module BABYLON {
  5292. /**
  5293. * Class used to hold a RBG color
  5294. */
  5295. export class Color3 {
  5296. /**
  5297. * Defines the red component (between 0 and 1, default is 0)
  5298. */
  5299. r: number;
  5300. /**
  5301. * Defines the green component (between 0 and 1, default is 0)
  5302. */
  5303. g: number;
  5304. /**
  5305. * Defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. b: number;
  5308. /**
  5309. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5310. * @param r defines the red component (between 0 and 1, default is 0)
  5311. * @param g defines the green component (between 0 and 1, default is 0)
  5312. * @param b defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. constructor(
  5315. /**
  5316. * Defines the red component (between 0 and 1, default is 0)
  5317. */
  5318. r?: number,
  5319. /**
  5320. * Defines the green component (between 0 and 1, default is 0)
  5321. */
  5322. g?: number,
  5323. /**
  5324. * Defines the blue component (between 0 and 1, default is 0)
  5325. */
  5326. b?: number);
  5327. /**
  5328. * Creates a string with the Color3 current values
  5329. * @returns the string representation of the Color3 object
  5330. */
  5331. toString(): string;
  5332. /**
  5333. * Returns the string "Color3"
  5334. * @returns "Color3"
  5335. */
  5336. getClassName(): string;
  5337. /**
  5338. * Compute the Color3 hash code
  5339. * @returns an unique number that can be used to hash Color3 objects
  5340. */
  5341. getHashCode(): number;
  5342. /**
  5343. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5344. * @param array defines the array where to store the r,g,b components
  5345. * @param index defines an optional index in the target array to define where to start storing values
  5346. * @returns the current Color3 object
  5347. */
  5348. toArray(array: FloatArray, index?: number): Color3;
  5349. /**
  5350. * Returns a new Color4 object from the current Color3 and the given alpha
  5351. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5352. * @returns a new Color4 object
  5353. */
  5354. toColor4(alpha?: number): Color4;
  5355. /**
  5356. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5357. * @returns the new array
  5358. */
  5359. asArray(): number[];
  5360. /**
  5361. * Returns the luminance value
  5362. * @returns a float value
  5363. */
  5364. toLuminance(): number;
  5365. /**
  5366. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5367. * @param otherColor defines the second operand
  5368. * @returns the new Color3 object
  5369. */
  5370. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5371. /**
  5372. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5373. * @param otherColor defines the second operand
  5374. * @param result defines the Color3 object where to store the result
  5375. * @returns the current Color3
  5376. */
  5377. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5378. /**
  5379. * Determines equality between Color3 objects
  5380. * @param otherColor defines the second operand
  5381. * @returns true if the rgb values are equal to the given ones
  5382. */
  5383. equals(otherColor: DeepImmutable<Color3>): boolean;
  5384. /**
  5385. * Determines equality between the current Color3 object and a set of r,b,g values
  5386. * @param r defines the red component to check
  5387. * @param g defines the green component to check
  5388. * @param b defines the blue component to check
  5389. * @returns true if the rgb values are equal to the given ones
  5390. */
  5391. equalsFloats(r: number, g: number, b: number): boolean;
  5392. /**
  5393. * Multiplies in place each rgb value by scale
  5394. * @param scale defines the scaling factor
  5395. * @returns the updated Color3
  5396. */
  5397. scale(scale: number): Color3;
  5398. /**
  5399. * Multiplies the rgb values by scale and stores the result into "result"
  5400. * @param scale defines the scaling factor
  5401. * @param result defines the Color3 object where to store the result
  5402. * @returns the unmodified current Color3
  5403. */
  5404. scaleToRef(scale: number, result: Color3): Color3;
  5405. /**
  5406. * Scale the current Color3 values by a factor and add the result to a given Color3
  5407. * @param scale defines the scale factor
  5408. * @param result defines color to store the result into
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Clamps the rgb values by the min and max values and stores the result into "result"
  5414. * @param min defines minimum clamping value (default is 0)
  5415. * @param max defines maximum clamping value (default is 1)
  5416. * @param result defines color to store the result into
  5417. * @returns the original Color3
  5418. */
  5419. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5420. /**
  5421. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5422. * @param otherColor defines the second operand
  5423. * @returns the new Color3
  5424. */
  5425. add(otherColor: DeepImmutable<Color3>): Color3;
  5426. /**
  5427. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5428. * @param otherColor defines the second operand
  5429. * @param result defines Color3 object to store the result into
  5430. * @returns the unmodified current Color3
  5431. */
  5432. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5433. /**
  5434. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5435. * @param otherColor defines the second operand
  5436. * @returns the new Color3
  5437. */
  5438. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5439. /**
  5440. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5441. * @param otherColor defines the second operand
  5442. * @param result defines Color3 object to store the result into
  5443. * @returns the unmodified current Color3
  5444. */
  5445. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5446. /**
  5447. * Copy the current object
  5448. * @returns a new Color3 copied the current one
  5449. */
  5450. clone(): Color3;
  5451. /**
  5452. * Copies the rgb values from the source in the current Color3
  5453. * @param source defines the source Color3 object
  5454. * @returns the updated Color3 object
  5455. */
  5456. copyFrom(source: DeepImmutable<Color3>): Color3;
  5457. /**
  5458. * Updates the Color3 rgb values from the given floats
  5459. * @param r defines the red component to read from
  5460. * @param g defines the green component to read from
  5461. * @param b defines the blue component to read from
  5462. * @returns the current Color3 object
  5463. */
  5464. copyFromFloats(r: number, g: number, b: number): Color3;
  5465. /**
  5466. * Updates the Color3 rgb values from the given floats
  5467. * @param r defines the red component to read from
  5468. * @param g defines the green component to read from
  5469. * @param b defines the blue component to read from
  5470. * @returns the current Color3 object
  5471. */
  5472. set(r: number, g: number, b: number): Color3;
  5473. /**
  5474. * Compute the Color3 hexadecimal code as a string
  5475. * @returns a string containing the hexadecimal representation of the Color3 object
  5476. */
  5477. toHexString(): string;
  5478. /**
  5479. * Computes a new Color3 converted from the current one to linear space
  5480. * @returns a new Color3 object
  5481. */
  5482. toLinearSpace(): Color3;
  5483. /**
  5484. * Converts current color in rgb space to HSV values
  5485. * @returns a new color3 representing the HSV values
  5486. */
  5487. toHSV(): Color3;
  5488. /**
  5489. * Converts current color in rgb space to HSV values
  5490. * @param result defines the Color3 where to store the HSV values
  5491. */
  5492. toHSVToRef(result: Color3): void;
  5493. /**
  5494. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the linear space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5499. /**
  5500. * Computes a new Color3 converted from the current one to gamma space
  5501. * @returns a new Color3 object
  5502. */
  5503. toGammaSpace(): Color3;
  5504. /**
  5505. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5506. * @param convertedColor defines the Color3 object where to store the gamma space version
  5507. * @returns the unmodified Color3
  5508. */
  5509. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5510. private static _BlackReadOnly;
  5511. /**
  5512. * Convert Hue, saturation and value to a Color3 (RGB)
  5513. * @param hue defines the hue
  5514. * @param saturation defines the saturation
  5515. * @param value defines the value
  5516. * @param result defines the Color3 where to store the RGB values
  5517. */
  5518. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5519. /**
  5520. * Creates a new Color3 from the string containing valid hexadecimal values
  5521. * @param hex defines a string containing valid hexadecimal values
  5522. * @returns a new Color3 object
  5523. */
  5524. static FromHexString(hex: string): Color3;
  5525. /**
  5526. * Creates a new Color3 from the starting index of the given array
  5527. * @param array defines the source array
  5528. * @param offset defines an offset in the source array
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5532. /**
  5533. * Creates a new Color3 from integer values (< 256)
  5534. * @param r defines the red component to read from (value between 0 and 255)
  5535. * @param g defines the green component to read from (value between 0 and 255)
  5536. * @param b defines the blue component to read from (value between 0 and 255)
  5537. * @returns a new Color3 object
  5538. */
  5539. static FromInts(r: number, g: number, b: number): Color3;
  5540. /**
  5541. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5542. * @param start defines the start Color3 value
  5543. * @param end defines the end Color3 value
  5544. * @param amount defines the gradient value between start and end
  5545. * @returns a new Color3 object
  5546. */
  5547. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5548. /**
  5549. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5550. * @param left defines the start value
  5551. * @param right defines the end value
  5552. * @param amount defines the gradient factor
  5553. * @param result defines the Color3 object where to store the result
  5554. */
  5555. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5556. /**
  5557. * Returns a Color3 value containing a red color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Red(): Color3;
  5561. /**
  5562. * Returns a Color3 value containing a green color
  5563. * @returns a new Color3 object
  5564. */
  5565. static Green(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a blue color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Blue(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a black color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Black(): Color3;
  5576. /**
  5577. * Gets a Color3 value containing a black color that must not be updated
  5578. */
  5579. static get BlackReadOnly(): DeepImmutable<Color3>;
  5580. /**
  5581. * Returns a Color3 value containing a white color
  5582. * @returns a new Color3 object
  5583. */
  5584. static White(): Color3;
  5585. /**
  5586. * Returns a Color3 value containing a purple color
  5587. * @returns a new Color3 object
  5588. */
  5589. static Purple(): Color3;
  5590. /**
  5591. * Returns a Color3 value containing a magenta color
  5592. * @returns a new Color3 object
  5593. */
  5594. static Magenta(): Color3;
  5595. /**
  5596. * Returns a Color3 value containing a yellow color
  5597. * @returns a new Color3 object
  5598. */
  5599. static Yellow(): Color3;
  5600. /**
  5601. * Returns a Color3 value containing a gray color
  5602. * @returns a new Color3 object
  5603. */
  5604. static Gray(): Color3;
  5605. /**
  5606. * Returns a Color3 value containing a teal color
  5607. * @returns a new Color3 object
  5608. */
  5609. static Teal(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a random color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Random(): Color3;
  5615. }
  5616. /**
  5617. * Class used to hold a RBGA color
  5618. */
  5619. export class Color4 {
  5620. /**
  5621. * Defines the red component (between 0 and 1, default is 0)
  5622. */
  5623. r: number;
  5624. /**
  5625. * Defines the green component (between 0 and 1, default is 0)
  5626. */
  5627. g: number;
  5628. /**
  5629. * Defines the blue component (between 0 and 1, default is 0)
  5630. */
  5631. b: number;
  5632. /**
  5633. * Defines the alpha component (between 0 and 1, default is 1)
  5634. */
  5635. a: number;
  5636. /**
  5637. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5638. * @param r defines the red component (between 0 and 1, default is 0)
  5639. * @param g defines the green component (between 0 and 1, default is 0)
  5640. * @param b defines the blue component (between 0 and 1, default is 0)
  5641. * @param a defines the alpha component (between 0 and 1, default is 1)
  5642. */
  5643. constructor(
  5644. /**
  5645. * Defines the red component (between 0 and 1, default is 0)
  5646. */
  5647. r?: number,
  5648. /**
  5649. * Defines the green component (between 0 and 1, default is 0)
  5650. */
  5651. g?: number,
  5652. /**
  5653. * Defines the blue component (between 0 and 1, default is 0)
  5654. */
  5655. b?: number,
  5656. /**
  5657. * Defines the alpha component (between 0 and 1, default is 1)
  5658. */
  5659. a?: number);
  5660. /**
  5661. * Adds in place the given Color4 values to the current Color4 object
  5662. * @param right defines the second operand
  5663. * @returns the current updated Color4 object
  5664. */
  5665. addInPlace(right: DeepImmutable<Color4>): Color4;
  5666. /**
  5667. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5668. * @returns the new array
  5669. */
  5670. asArray(): number[];
  5671. /**
  5672. * Stores from the starting index in the given array the Color4 successive values
  5673. * @param array defines the array where to store the r,g,b components
  5674. * @param index defines an optional index in the target array to define where to start storing values
  5675. * @returns the current Color4 object
  5676. */
  5677. toArray(array: number[], index?: number): Color4;
  5678. /**
  5679. * Determines equality between Color4 objects
  5680. * @param otherColor defines the second operand
  5681. * @returns true if the rgba values are equal to the given ones
  5682. */
  5683. equals(otherColor: DeepImmutable<Color4>): boolean;
  5684. /**
  5685. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5686. * @param right defines the second operand
  5687. * @returns a new Color4 object
  5688. */
  5689. add(right: DeepImmutable<Color4>): Color4;
  5690. /**
  5691. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5692. * @param right defines the second operand
  5693. * @returns a new Color4 object
  5694. */
  5695. subtract(right: DeepImmutable<Color4>): Color4;
  5696. /**
  5697. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5698. * @param right defines the second operand
  5699. * @param result defines the Color4 object where to store the result
  5700. * @returns the current Color4 object
  5701. */
  5702. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5703. /**
  5704. * Creates a new Color4 with the current Color4 values multiplied by scale
  5705. * @param scale defines the scaling factor to apply
  5706. * @returns a new Color4 object
  5707. */
  5708. scale(scale: number): Color4;
  5709. /**
  5710. * Multiplies the current Color4 values by scale and stores the result in "result"
  5711. * @param scale defines the scaling factor to apply
  5712. * @param result defines the Color4 object where to store the result
  5713. * @returns the current unmodified Color4
  5714. */
  5715. scaleToRef(scale: number, result: Color4): Color4;
  5716. /**
  5717. * Scale the current Color4 values by a factor and add the result to a given Color4
  5718. * @param scale defines the scale factor
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the unmodified current Color4
  5721. */
  5722. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Clamps the rgb values by the min and max values and stores the result into "result"
  5725. * @param min defines minimum clamping value (default is 0)
  5726. * @param max defines maximum clamping value (default is 1)
  5727. * @param result defines color to store the result into.
  5728. * @returns the cuurent Color4
  5729. */
  5730. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5731. /**
  5732. * Multipy an Color4 value by another and return a new Color4 object
  5733. * @param color defines the Color4 value to multiply by
  5734. * @returns a new Color4 object
  5735. */
  5736. multiply(color: Color4): Color4;
  5737. /**
  5738. * Multipy a Color4 value by another and push the result in a reference value
  5739. * @param color defines the Color4 value to multiply by
  5740. * @param result defines the Color4 to fill the result in
  5741. * @returns the result Color4
  5742. */
  5743. multiplyToRef(color: Color4, result: Color4): Color4;
  5744. /**
  5745. * Creates a string with the Color4 current values
  5746. * @returns the string representation of the Color4 object
  5747. */
  5748. toString(): string;
  5749. /**
  5750. * Returns the string "Color4"
  5751. * @returns "Color4"
  5752. */
  5753. getClassName(): string;
  5754. /**
  5755. * Compute the Color4 hash code
  5756. * @returns an unique number that can be used to hash Color4 objects
  5757. */
  5758. getHashCode(): number;
  5759. /**
  5760. * Creates a new Color4 copied from the current one
  5761. * @returns a new Color4 object
  5762. */
  5763. clone(): Color4;
  5764. /**
  5765. * Copies the given Color4 values into the current one
  5766. * @param source defines the source Color4 object
  5767. * @returns the current updated Color4 object
  5768. */
  5769. copyFrom(source: Color4): Color4;
  5770. /**
  5771. * Copies the given float values into the current one
  5772. * @param r defines the red component to read from
  5773. * @param g defines the green component to read from
  5774. * @param b defines the blue component to read from
  5775. * @param a defines the alpha component to read from
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. set(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Compute the Color4 hexadecimal code as a string
  5790. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5791. * @returns a string containing the hexadecimal representation of the Color4 object
  5792. */
  5793. toHexString(returnAsColor3?: boolean): string;
  5794. /**
  5795. * Computes a new Color4 converted from the current one to linear space
  5796. * @returns a new Color4 object
  5797. */
  5798. toLinearSpace(): Color4;
  5799. /**
  5800. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5801. * @param convertedColor defines the Color4 object where to store the linear space version
  5802. * @returns the unmodified Color4
  5803. */
  5804. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5805. /**
  5806. * Computes a new Color4 converted from the current one to gamma space
  5807. * @returns a new Color4 object
  5808. */
  5809. toGammaSpace(): Color4;
  5810. /**
  5811. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5812. * @param convertedColor defines the Color4 object where to store the gamma space version
  5813. * @returns the unmodified Color4
  5814. */
  5815. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5816. /**
  5817. * Creates a new Color4 from the string containing valid hexadecimal values
  5818. * @param hex defines a string containing valid hexadecimal values
  5819. * @returns a new Color4 object
  5820. */
  5821. static FromHexString(hex: string): Color4;
  5822. /**
  5823. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5824. * @param left defines the start value
  5825. * @param right defines the end value
  5826. * @param amount defines the gradient factor
  5827. * @returns a new Color4 object
  5828. */
  5829. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5830. /**
  5831. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5832. * @param left defines the start value
  5833. * @param right defines the end value
  5834. * @param amount defines the gradient factor
  5835. * @param result defines the Color4 object where to store data
  5836. */
  5837. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5838. /**
  5839. * Creates a new Color4 from a Color3 and an alpha value
  5840. * @param color3 defines the source Color3 to read from
  5841. * @param alpha defines the alpha component (1.0 by default)
  5842. * @returns a new Color4 object
  5843. */
  5844. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5845. /**
  5846. * Creates a new Color4 from the starting index element of the given array
  5847. * @param array defines the source array to read from
  5848. * @param offset defines the offset in the source array
  5849. * @returns a new Color4 object
  5850. */
  5851. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5852. /**
  5853. * Creates a new Color3 from integer values (< 256)
  5854. * @param r defines the red component to read from (value between 0 and 255)
  5855. * @param g defines the green component to read from (value between 0 and 255)
  5856. * @param b defines the blue component to read from (value between 0 and 255)
  5857. * @param a defines the alpha component to read from (value between 0 and 255)
  5858. * @returns a new Color3 object
  5859. */
  5860. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5861. /**
  5862. * Check the content of a given array and convert it to an array containing RGBA data
  5863. * If the original array was already containing count * 4 values then it is returned directly
  5864. * @param colors defines the array to check
  5865. * @param count defines the number of RGBA data to expect
  5866. * @returns an array containing count * 4 values (RGBA)
  5867. */
  5868. static CheckColors4(colors: number[], count: number): number[];
  5869. }
  5870. /**
  5871. * @hidden
  5872. */
  5873. export class TmpColors {
  5874. static Color3: Color3[];
  5875. static Color4: Color4[];
  5876. }
  5877. }
  5878. declare module BABYLON {
  5879. /**
  5880. * Defines an interface which represents an animation key frame
  5881. */
  5882. export interface IAnimationKey {
  5883. /**
  5884. * Frame of the key frame
  5885. */
  5886. frame: number;
  5887. /**
  5888. * Value at the specifies key frame
  5889. */
  5890. value: any;
  5891. /**
  5892. * The input tangent for the cubic hermite spline
  5893. */
  5894. inTangent?: any;
  5895. /**
  5896. * The output tangent for the cubic hermite spline
  5897. */
  5898. outTangent?: any;
  5899. /**
  5900. * The animation interpolation type
  5901. */
  5902. interpolation?: AnimationKeyInterpolation;
  5903. }
  5904. /**
  5905. * Enum for the animation key frame interpolation type
  5906. */
  5907. export enum AnimationKeyInterpolation {
  5908. /**
  5909. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5910. */
  5911. STEP = 1
  5912. }
  5913. }
  5914. declare module BABYLON {
  5915. /**
  5916. * Represents the range of an animation
  5917. */
  5918. export class AnimationRange {
  5919. /**The name of the animation range**/
  5920. name: string;
  5921. /**The starting frame of the animation */
  5922. from: number;
  5923. /**The ending frame of the animation*/
  5924. to: number;
  5925. /**
  5926. * Initializes the range of an animation
  5927. * @param name The name of the animation range
  5928. * @param from The starting frame of the animation
  5929. * @param to The ending frame of the animation
  5930. */
  5931. constructor(
  5932. /**The name of the animation range**/
  5933. name: string,
  5934. /**The starting frame of the animation */
  5935. from: number,
  5936. /**The ending frame of the animation*/
  5937. to: number);
  5938. /**
  5939. * Makes a copy of the animation range
  5940. * @returns A copy of the animation range
  5941. */
  5942. clone(): AnimationRange;
  5943. }
  5944. }
  5945. declare module BABYLON {
  5946. /**
  5947. * Composed of a frame, and an action function
  5948. */
  5949. export class AnimationEvent {
  5950. /** The frame for which the event is triggered **/
  5951. frame: number;
  5952. /** The event to perform when triggered **/
  5953. action: (currentFrame: number) => void;
  5954. /** Specifies if the event should be triggered only once**/
  5955. onlyOnce?: boolean | undefined;
  5956. /**
  5957. * Specifies if the animation event is done
  5958. */
  5959. isDone: boolean;
  5960. /**
  5961. * Initializes the animation event
  5962. * @param frame The frame for which the event is triggered
  5963. * @param action The event to perform when triggered
  5964. * @param onlyOnce Specifies if the event should be triggered only once
  5965. */
  5966. constructor(
  5967. /** The frame for which the event is triggered **/
  5968. frame: number,
  5969. /** The event to perform when triggered **/
  5970. action: (currentFrame: number) => void,
  5971. /** Specifies if the event should be triggered only once**/
  5972. onlyOnce?: boolean | undefined);
  5973. /** @hidden */
  5974. _clone(): AnimationEvent;
  5975. }
  5976. }
  5977. declare module BABYLON {
  5978. /**
  5979. * Interface used to define a behavior
  5980. */
  5981. export interface Behavior<T> {
  5982. /** gets or sets behavior's name */
  5983. name: string;
  5984. /**
  5985. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5986. */
  5987. init(): void;
  5988. /**
  5989. * Called when the behavior is attached to a target
  5990. * @param target defines the target where the behavior is attached to
  5991. */
  5992. attach(target: T): void;
  5993. /**
  5994. * Called when the behavior is detached from its target
  5995. */
  5996. detach(): void;
  5997. }
  5998. /**
  5999. * Interface implemented by classes supporting behaviors
  6000. */
  6001. export interface IBehaviorAware<T> {
  6002. /**
  6003. * Attach a behavior
  6004. * @param behavior defines the behavior to attach
  6005. * @returns the current host
  6006. */
  6007. addBehavior(behavior: Behavior<T>): T;
  6008. /**
  6009. * Remove a behavior from the current object
  6010. * @param behavior defines the behavior to detach
  6011. * @returns the current host
  6012. */
  6013. removeBehavior(behavior: Behavior<T>): T;
  6014. /**
  6015. * Gets a behavior using its name to search
  6016. * @param name defines the name to search
  6017. * @returns the behavior or null if not found
  6018. */
  6019. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6020. }
  6021. }
  6022. declare module BABYLON {
  6023. /**
  6024. * Defines an array and its length.
  6025. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6026. */
  6027. export interface ISmartArrayLike<T> {
  6028. /**
  6029. * The data of the array.
  6030. */
  6031. data: Array<T>;
  6032. /**
  6033. * The active length of the array.
  6034. */
  6035. length: number;
  6036. }
  6037. /**
  6038. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6039. */
  6040. export class SmartArray<T> implements ISmartArrayLike<T> {
  6041. /**
  6042. * The full set of data from the array.
  6043. */
  6044. data: Array<T>;
  6045. /**
  6046. * The active length of the array.
  6047. */
  6048. length: number;
  6049. protected _id: number;
  6050. /**
  6051. * Instantiates a Smart Array.
  6052. * @param capacity defines the default capacity of the array.
  6053. */
  6054. constructor(capacity: number);
  6055. /**
  6056. * Pushes a value at the end of the active data.
  6057. * @param value defines the object to push in the array.
  6058. */
  6059. push(value: T): void;
  6060. /**
  6061. * Iterates over the active data and apply the lambda to them.
  6062. * @param func defines the action to apply on each value.
  6063. */
  6064. forEach(func: (content: T) => void): void;
  6065. /**
  6066. * Sorts the full sets of data.
  6067. * @param compareFn defines the comparison function to apply.
  6068. */
  6069. sort(compareFn: (a: T, b: T) => number): void;
  6070. /**
  6071. * Resets the active data to an empty array.
  6072. */
  6073. reset(): void;
  6074. /**
  6075. * Releases all the data from the array as well as the array.
  6076. */
  6077. dispose(): void;
  6078. /**
  6079. * Concats the active data with a given array.
  6080. * @param array defines the data to concatenate with.
  6081. */
  6082. concat(array: any): void;
  6083. /**
  6084. * Returns the position of a value in the active data.
  6085. * @param value defines the value to find the index for
  6086. * @returns the index if found in the active data otherwise -1
  6087. */
  6088. indexOf(value: T): number;
  6089. /**
  6090. * Returns whether an element is part of the active data.
  6091. * @param value defines the value to look for
  6092. * @returns true if found in the active data otherwise false
  6093. */
  6094. contains(value: T): boolean;
  6095. private static _GlobalId;
  6096. }
  6097. /**
  6098. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6099. * The data in this array can only be present once
  6100. */
  6101. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6102. private _duplicateId;
  6103. /**
  6104. * Pushes a value at the end of the active data.
  6105. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6106. * @param value defines the object to push in the array.
  6107. */
  6108. push(value: T): void;
  6109. /**
  6110. * Pushes a value at the end of the active data.
  6111. * If the data is already present, it won t be added again
  6112. * @param value defines the object to push in the array.
  6113. * @returns true if added false if it was already present
  6114. */
  6115. pushNoDuplicate(value: T): boolean;
  6116. /**
  6117. * Resets the active data to an empty array.
  6118. */
  6119. reset(): void;
  6120. /**
  6121. * Concats the active data with a given array.
  6122. * This ensures no dupplicate will be present in the result.
  6123. * @param array defines the data to concatenate with.
  6124. */
  6125. concatWithNoDuplicate(array: any): void;
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * @ignore
  6131. * This is a list of all the different input types that are available in the application.
  6132. * Fo instance: ArcRotateCameraGamepadInput...
  6133. */
  6134. export var CameraInputTypes: {};
  6135. /**
  6136. * This is the contract to implement in order to create a new input class.
  6137. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6138. */
  6139. export interface ICameraInput<TCamera extends Camera> {
  6140. /**
  6141. * Defines the camera the input is attached to.
  6142. */
  6143. camera: Nullable<TCamera>;
  6144. /**
  6145. * Gets the class name of the current intput.
  6146. * @returns the class name
  6147. */
  6148. getClassName(): string;
  6149. /**
  6150. * Get the friendly name associated with the input class.
  6151. * @returns the input friendly name
  6152. */
  6153. getSimpleName(): string;
  6154. /**
  6155. * Attach the input controls to a specific dom element to get the input from.
  6156. * @param element Defines the element the controls should be listened from
  6157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6158. */
  6159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6160. /**
  6161. * Detach the current controls from the specified dom element.
  6162. * @param element Defines the element to stop listening the inputs from
  6163. */
  6164. detachControl(element: Nullable<HTMLElement>): void;
  6165. /**
  6166. * Update the current camera state depending on the inputs that have been used this frame.
  6167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6168. */
  6169. checkInputs?: () => void;
  6170. }
  6171. /**
  6172. * Represents a map of input types to input instance or input index to input instance.
  6173. */
  6174. export interface CameraInputsMap<TCamera extends Camera> {
  6175. /**
  6176. * Accessor to the input by input type.
  6177. */
  6178. [name: string]: ICameraInput<TCamera>;
  6179. /**
  6180. * Accessor to the input by input index.
  6181. */
  6182. [idx: number]: ICameraInput<TCamera>;
  6183. }
  6184. /**
  6185. * This represents the input manager used within a camera.
  6186. * It helps dealing with all the different kind of input attached to a camera.
  6187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6188. */
  6189. export class CameraInputsManager<TCamera extends Camera> {
  6190. /**
  6191. * Defines the list of inputs attahed to the camera.
  6192. */
  6193. attached: CameraInputsMap<TCamera>;
  6194. /**
  6195. * Defines the dom element the camera is collecting inputs from.
  6196. * This is null if the controls have not been attached.
  6197. */
  6198. attachedElement: Nullable<HTMLElement>;
  6199. /**
  6200. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6201. */
  6202. noPreventDefault: boolean;
  6203. /**
  6204. * Defined the camera the input manager belongs to.
  6205. */
  6206. camera: TCamera;
  6207. /**
  6208. * Update the current camera state depending on the inputs that have been used this frame.
  6209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6210. */
  6211. checkInputs: () => void;
  6212. /**
  6213. * Instantiate a new Camera Input Manager.
  6214. * @param camera Defines the camera the input manager blongs to
  6215. */
  6216. constructor(camera: TCamera);
  6217. /**
  6218. * Add an input method to a camera
  6219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6220. * @param input camera input method
  6221. */
  6222. add(input: ICameraInput<TCamera>): void;
  6223. /**
  6224. * Remove a specific input method from a camera
  6225. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6226. * @param inputToRemove camera input method
  6227. */
  6228. remove(inputToRemove: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Remove a specific input type from a camera
  6231. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6232. * @param inputType the type of the input to remove
  6233. */
  6234. removeByType(inputType: string): void;
  6235. private _addCheckInputs;
  6236. /**
  6237. * Attach the input controls to the currently attached dom element to listen the events from.
  6238. * @param input Defines the input to attach
  6239. */
  6240. attachInput(input: ICameraInput<TCamera>): void;
  6241. /**
  6242. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6243. * @param element Defines the dom element to collect the events from
  6244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6245. */
  6246. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6247. /**
  6248. * Detach the current manager inputs controls from a specific dom element.
  6249. * @param element Defines the dom element to collect the events from
  6250. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6251. */
  6252. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6253. /**
  6254. * Rebuild the dynamic inputCheck function from the current list of
  6255. * defined inputs in the manager.
  6256. */
  6257. rebuildInputCheck(): void;
  6258. /**
  6259. * Remove all attached input methods from a camera
  6260. */
  6261. clear(): void;
  6262. /**
  6263. * Serialize the current input manager attached to a camera.
  6264. * This ensures than once parsed,
  6265. * the input associated to the camera will be identical to the current ones
  6266. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6267. */
  6268. serialize(serializedCamera: any): void;
  6269. /**
  6270. * Parses an input manager serialized JSON to restore the previous list of inputs
  6271. * and states associated to a camera.
  6272. * @param parsedCamera Defines the JSON to parse
  6273. */
  6274. parse(parsedCamera: any): void;
  6275. }
  6276. }
  6277. declare module BABYLON {
  6278. /**
  6279. * Class used to store data that will be store in GPU memory
  6280. */
  6281. export class Buffer {
  6282. private _engine;
  6283. private _buffer;
  6284. /** @hidden */
  6285. _data: Nullable<DataArray>;
  6286. private _updatable;
  6287. private _instanced;
  6288. private _divisor;
  6289. /**
  6290. * Gets the byte stride.
  6291. */
  6292. readonly byteStride: number;
  6293. /**
  6294. * Constructor
  6295. * @param engine the engine
  6296. * @param data the data to use for this buffer
  6297. * @param updatable whether the data is updatable
  6298. * @param stride the stride (optional)
  6299. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param useBytes set to true if the stride in in bytes (optional)
  6302. * @param divisor sets an optional divisor for instances (1 by default)
  6303. */
  6304. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6305. /**
  6306. * Create a new VertexBuffer based on the current buffer
  6307. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6308. * @param offset defines offset in the buffer (0 by default)
  6309. * @param size defines the size in floats of attributes (position is 3 for instance)
  6310. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6311. * @param instanced defines if the vertex buffer contains indexed data
  6312. * @param useBytes defines if the offset and stride are in bytes *
  6313. * @param divisor sets an optional divisor for instances (1 by default)
  6314. * @returns the new vertex buffer
  6315. */
  6316. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6317. /**
  6318. * Gets a boolean indicating if the Buffer is updatable?
  6319. * @returns true if the buffer is updatable
  6320. */
  6321. isUpdatable(): boolean;
  6322. /**
  6323. * Gets current buffer's data
  6324. * @returns a DataArray or null
  6325. */
  6326. getData(): Nullable<DataArray>;
  6327. /**
  6328. * Gets underlying native buffer
  6329. * @returns underlying native buffer
  6330. */
  6331. getBuffer(): Nullable<DataBuffer>;
  6332. /**
  6333. * Gets the stride in float32 units (i.e. byte stride / 4).
  6334. * May not be an integer if the byte stride is not divisible by 4.
  6335. * @returns the stride in float32 units
  6336. * @deprecated Please use byteStride instead.
  6337. */
  6338. getStrideSize(): number;
  6339. /**
  6340. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6341. * @param data defines the data to store
  6342. */
  6343. create(data?: Nullable<DataArray>): void;
  6344. /** @hidden */
  6345. _rebuild(): void;
  6346. /**
  6347. * Update current buffer data
  6348. * @param data defines the data to store
  6349. */
  6350. update(data: DataArray): void;
  6351. /**
  6352. * Updates the data directly.
  6353. * @param data the new data
  6354. * @param offset the new offset
  6355. * @param vertexCount the vertex count (optional)
  6356. * @param useBytes set to true if the offset is in bytes
  6357. */
  6358. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6359. /**
  6360. * Release all resources
  6361. */
  6362. dispose(): void;
  6363. }
  6364. /**
  6365. * Specialized buffer used to store vertex data
  6366. */
  6367. export class VertexBuffer {
  6368. /** @hidden */
  6369. _buffer: Buffer;
  6370. private _kind;
  6371. private _size;
  6372. private _ownsBuffer;
  6373. private _instanced;
  6374. private _instanceDivisor;
  6375. /**
  6376. * The byte type.
  6377. */
  6378. static readonly BYTE: number;
  6379. /**
  6380. * The unsigned byte type.
  6381. */
  6382. static readonly UNSIGNED_BYTE: number;
  6383. /**
  6384. * The short type.
  6385. */
  6386. static readonly SHORT: number;
  6387. /**
  6388. * The unsigned short type.
  6389. */
  6390. static readonly UNSIGNED_SHORT: number;
  6391. /**
  6392. * The integer type.
  6393. */
  6394. static readonly INT: number;
  6395. /**
  6396. * The unsigned integer type.
  6397. */
  6398. static readonly UNSIGNED_INT: number;
  6399. /**
  6400. * The float type.
  6401. */
  6402. static readonly FLOAT: number;
  6403. /**
  6404. * Gets or sets the instance divisor when in instanced mode
  6405. */
  6406. get instanceDivisor(): number;
  6407. set instanceDivisor(value: number);
  6408. /**
  6409. * Gets the byte stride.
  6410. */
  6411. readonly byteStride: number;
  6412. /**
  6413. * Gets the byte offset.
  6414. */
  6415. readonly byteOffset: number;
  6416. /**
  6417. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6418. */
  6419. readonly normalized: boolean;
  6420. /**
  6421. * Gets the data type of each component in the array.
  6422. */
  6423. readonly type: number;
  6424. /**
  6425. * Constructor
  6426. * @param engine the engine
  6427. * @param data the data to use for this vertex buffer
  6428. * @param kind the vertex buffer kind
  6429. * @param updatable whether the data is updatable
  6430. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6431. * @param stride the stride (optional)
  6432. * @param instanced whether the buffer is instanced (optional)
  6433. * @param offset the offset of the data (optional)
  6434. * @param size the number of components (optional)
  6435. * @param type the type of the component (optional)
  6436. * @param normalized whether the data contains normalized data (optional)
  6437. * @param useBytes set to true if stride and offset are in bytes (optional)
  6438. * @param divisor defines the instance divisor to use (1 by default)
  6439. */
  6440. 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);
  6441. /** @hidden */
  6442. _rebuild(): void;
  6443. /**
  6444. * Returns the kind of the VertexBuffer (string)
  6445. * @returns a string
  6446. */
  6447. getKind(): string;
  6448. /**
  6449. * Gets a boolean indicating if the VertexBuffer is updatable?
  6450. * @returns true if the buffer is updatable
  6451. */
  6452. isUpdatable(): boolean;
  6453. /**
  6454. * Gets current buffer's data
  6455. * @returns a DataArray or null
  6456. */
  6457. getData(): Nullable<DataArray>;
  6458. /**
  6459. * Gets underlying native buffer
  6460. * @returns underlying native buffer
  6461. */
  6462. getBuffer(): Nullable<DataBuffer>;
  6463. /**
  6464. * Gets the stride in float32 units (i.e. byte stride / 4).
  6465. * May not be an integer if the byte stride is not divisible by 4.
  6466. * @returns the stride in float32 units
  6467. * @deprecated Please use byteStride instead.
  6468. */
  6469. getStrideSize(): number;
  6470. /**
  6471. * Returns the offset as a multiple of the type byte length.
  6472. * @returns the offset in bytes
  6473. * @deprecated Please use byteOffset instead.
  6474. */
  6475. getOffset(): number;
  6476. /**
  6477. * Returns the number of components per vertex attribute (integer)
  6478. * @returns the size in float
  6479. */
  6480. getSize(): number;
  6481. /**
  6482. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6483. * @returns true if this buffer is instanced
  6484. */
  6485. getIsInstanced(): boolean;
  6486. /**
  6487. * Returns the instancing divisor, zero for non-instanced (integer).
  6488. * @returns a number
  6489. */
  6490. getInstanceDivisor(): number;
  6491. /**
  6492. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6493. * @param data defines the data to store
  6494. */
  6495. create(data?: DataArray): void;
  6496. /**
  6497. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6498. * This function will create a new buffer if the current one is not updatable
  6499. * @param data defines the data to store
  6500. */
  6501. update(data: DataArray): void;
  6502. /**
  6503. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6504. * Returns the directly updated WebGLBuffer.
  6505. * @param data the new data
  6506. * @param offset the new offset
  6507. * @param useBytes set to true if the offset is in bytes
  6508. */
  6509. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6510. /**
  6511. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6512. */
  6513. dispose(): void;
  6514. /**
  6515. * Enumerates each value of this vertex buffer as numbers.
  6516. * @param count the number of values to enumerate
  6517. * @param callback the callback function called for each value
  6518. */
  6519. forEach(count: number, callback: (value: number, index: number) => void): void;
  6520. /**
  6521. * Positions
  6522. */
  6523. static readonly PositionKind: string;
  6524. /**
  6525. * Normals
  6526. */
  6527. static readonly NormalKind: string;
  6528. /**
  6529. * Tangents
  6530. */
  6531. static readonly TangentKind: string;
  6532. /**
  6533. * Texture coordinates
  6534. */
  6535. static readonly UVKind: string;
  6536. /**
  6537. * Texture coordinates 2
  6538. */
  6539. static readonly UV2Kind: string;
  6540. /**
  6541. * Texture coordinates 3
  6542. */
  6543. static readonly UV3Kind: string;
  6544. /**
  6545. * Texture coordinates 4
  6546. */
  6547. static readonly UV4Kind: string;
  6548. /**
  6549. * Texture coordinates 5
  6550. */
  6551. static readonly UV5Kind: string;
  6552. /**
  6553. * Texture coordinates 6
  6554. */
  6555. static readonly UV6Kind: string;
  6556. /**
  6557. * Colors
  6558. */
  6559. static readonly ColorKind: string;
  6560. /**
  6561. * Matrix indices (for bones)
  6562. */
  6563. static readonly MatricesIndicesKind: string;
  6564. /**
  6565. * Matrix weights (for bones)
  6566. */
  6567. static readonly MatricesWeightsKind: string;
  6568. /**
  6569. * Additional matrix indices (for bones)
  6570. */
  6571. static readonly MatricesIndicesExtraKind: string;
  6572. /**
  6573. * Additional matrix weights (for bones)
  6574. */
  6575. static readonly MatricesWeightsExtraKind: string;
  6576. /**
  6577. * Deduces the stride given a kind.
  6578. * @param kind The kind string to deduce
  6579. * @returns The deduced stride
  6580. */
  6581. static DeduceStride(kind: string): number;
  6582. /**
  6583. * Gets the byte length of the given type.
  6584. * @param type the type
  6585. * @returns the number of bytes
  6586. */
  6587. static GetTypeByteLength(type: number): number;
  6588. /**
  6589. * Enumerates each value of the given parameters as numbers.
  6590. * @param data the data to enumerate
  6591. * @param byteOffset the byte offset of the data
  6592. * @param byteStride the byte stride of the data
  6593. * @param componentCount the number of components per element
  6594. * @param componentType the type of the component
  6595. * @param count the number of values to enumerate
  6596. * @param normalized whether the data is normalized
  6597. * @param callback the callback function called for each value
  6598. */
  6599. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6600. private static _GetFloatValue;
  6601. }
  6602. }
  6603. declare module BABYLON {
  6604. /**
  6605. * @hidden
  6606. */
  6607. export class IntersectionInfo {
  6608. bu: Nullable<number>;
  6609. bv: Nullable<number>;
  6610. distance: number;
  6611. faceId: number;
  6612. subMeshId: number;
  6613. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6614. }
  6615. }
  6616. declare module BABYLON {
  6617. /**
  6618. * Represens a plane by the equation ax + by + cz + d = 0
  6619. */
  6620. export class Plane {
  6621. private static _TmpMatrix;
  6622. /**
  6623. * Normal of the plane (a,b,c)
  6624. */
  6625. normal: Vector3;
  6626. /**
  6627. * d component of the plane
  6628. */
  6629. d: number;
  6630. /**
  6631. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6632. * @param a a component of the plane
  6633. * @param b b component of the plane
  6634. * @param c c component of the plane
  6635. * @param d d component of the plane
  6636. */
  6637. constructor(a: number, b: number, c: number, d: number);
  6638. /**
  6639. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6640. */
  6641. asArray(): number[];
  6642. /**
  6643. * @returns a new plane copied from the current Plane.
  6644. */
  6645. clone(): Plane;
  6646. /**
  6647. * @returns the string "Plane".
  6648. */
  6649. getClassName(): string;
  6650. /**
  6651. * @returns the Plane hash code.
  6652. */
  6653. getHashCode(): number;
  6654. /**
  6655. * Normalize the current Plane in place.
  6656. * @returns the updated Plane.
  6657. */
  6658. normalize(): Plane;
  6659. /**
  6660. * Applies a transformation the plane and returns the result
  6661. * @param transformation the transformation matrix to be applied to the plane
  6662. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6663. */
  6664. transform(transformation: DeepImmutable<Matrix>): Plane;
  6665. /**
  6666. * Calcualtte the dot product between the point and the plane normal
  6667. * @param point point to calculate the dot product with
  6668. * @returns the dot product (float) of the point coordinates and the plane normal.
  6669. */
  6670. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6671. /**
  6672. * Updates the current Plane from the plane defined by the three given points.
  6673. * @param point1 one of the points used to contruct the plane
  6674. * @param point2 one of the points used to contruct the plane
  6675. * @param point3 one of the points used to contruct the plane
  6676. * @returns the updated Plane.
  6677. */
  6678. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6679. /**
  6680. * Checks if the plane is facing a given direction
  6681. * @param direction the direction to check if the plane is facing
  6682. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6683. * @returns True is the vector "direction" is the same side than the plane normal.
  6684. */
  6685. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6686. /**
  6687. * Calculates the distance to a point
  6688. * @param point point to calculate distance to
  6689. * @returns the signed distance (float) from the given point to the Plane.
  6690. */
  6691. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6692. /**
  6693. * Creates a plane from an array
  6694. * @param array the array to create a plane from
  6695. * @returns a new Plane from the given array.
  6696. */
  6697. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6698. /**
  6699. * Creates a plane from three points
  6700. * @param point1 point used to create the plane
  6701. * @param point2 point used to create the plane
  6702. * @param point3 point used to create the plane
  6703. * @returns a new Plane defined by the three given points.
  6704. */
  6705. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6706. /**
  6707. * Creates a plane from an origin point and a normal
  6708. * @param origin origin of the plane to be constructed
  6709. * @param normal normal of the plane to be constructed
  6710. * @returns a new Plane the normal vector to this plane at the given origin point.
  6711. * Note : the vector "normal" is updated because normalized.
  6712. */
  6713. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6714. /**
  6715. * Calculates the distance from a plane and a point
  6716. * @param origin origin of the plane to be constructed
  6717. * @param normal normal of the plane to be constructed
  6718. * @param point point to calculate distance to
  6719. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6720. */
  6721. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6722. }
  6723. }
  6724. declare module BABYLON {
  6725. /**
  6726. * Class used to store bounding sphere information
  6727. */
  6728. export class BoundingSphere {
  6729. /**
  6730. * Gets the center of the bounding sphere in local space
  6731. */
  6732. readonly center: Vector3;
  6733. /**
  6734. * Radius of the bounding sphere in local space
  6735. */
  6736. radius: number;
  6737. /**
  6738. * Gets the center of the bounding sphere in world space
  6739. */
  6740. readonly centerWorld: Vector3;
  6741. /**
  6742. * Radius of the bounding sphere in world space
  6743. */
  6744. radiusWorld: number;
  6745. /**
  6746. * Gets the minimum vector in local space
  6747. */
  6748. readonly minimum: Vector3;
  6749. /**
  6750. * Gets the maximum vector in local space
  6751. */
  6752. readonly maximum: Vector3;
  6753. private _worldMatrix;
  6754. private static readonly TmpVector3;
  6755. /**
  6756. * Creates a new bounding sphere
  6757. * @param min defines the minimum vector (in local space)
  6758. * @param max defines the maximum vector (in local space)
  6759. * @param worldMatrix defines the new world matrix
  6760. */
  6761. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6762. /**
  6763. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6764. * @param min defines the new minimum vector (in local space)
  6765. * @param max defines the new maximum vector (in local space)
  6766. * @param worldMatrix defines the new world matrix
  6767. */
  6768. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6769. /**
  6770. * Scale the current bounding sphere by applying a scale factor
  6771. * @param factor defines the scale factor to apply
  6772. * @returns the current bounding box
  6773. */
  6774. scale(factor: number): BoundingSphere;
  6775. /**
  6776. * Gets the world matrix of the bounding box
  6777. * @returns a matrix
  6778. */
  6779. getWorldMatrix(): DeepImmutable<Matrix>;
  6780. /** @hidden */
  6781. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6782. /**
  6783. * Tests if the bounding sphere is intersecting the frustum planes
  6784. * @param frustumPlanes defines the frustum planes to test
  6785. * @returns true if there is an intersection
  6786. */
  6787. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6788. /**
  6789. * Tests if the bounding sphere center is in between the frustum planes.
  6790. * Used for optimistic fast inclusion.
  6791. * @param frustumPlanes defines the frustum planes to test
  6792. * @returns true if the sphere center is in between the frustum planes
  6793. */
  6794. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6795. /**
  6796. * Tests if a point is inside the bounding sphere
  6797. * @param point defines the point to test
  6798. * @returns true if the point is inside the bounding sphere
  6799. */
  6800. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6801. /**
  6802. * Checks if two sphere intersct
  6803. * @param sphere0 sphere 0
  6804. * @param sphere1 sphere 1
  6805. * @returns true if the speres intersect
  6806. */
  6807. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6808. }
  6809. }
  6810. declare module BABYLON {
  6811. /**
  6812. * Class used to store bounding box information
  6813. */
  6814. export class BoundingBox implements ICullable {
  6815. /**
  6816. * Gets the 8 vectors representing the bounding box in local space
  6817. */
  6818. readonly vectors: Vector3[];
  6819. /**
  6820. * Gets the center of the bounding box in local space
  6821. */
  6822. readonly center: Vector3;
  6823. /**
  6824. * Gets the center of the bounding box in world space
  6825. */
  6826. readonly centerWorld: Vector3;
  6827. /**
  6828. * Gets the extend size in local space
  6829. */
  6830. readonly extendSize: Vector3;
  6831. /**
  6832. * Gets the extend size in world space
  6833. */
  6834. readonly extendSizeWorld: Vector3;
  6835. /**
  6836. * Gets the OBB (object bounding box) directions
  6837. */
  6838. readonly directions: Vector3[];
  6839. /**
  6840. * Gets the 8 vectors representing the bounding box in world space
  6841. */
  6842. readonly vectorsWorld: Vector3[];
  6843. /**
  6844. * Gets the minimum vector in world space
  6845. */
  6846. readonly minimumWorld: Vector3;
  6847. /**
  6848. * Gets the maximum vector in world space
  6849. */
  6850. readonly maximumWorld: Vector3;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * @hidden
  6863. */
  6864. _tag: number;
  6865. /**
  6866. * Creates a new bounding box
  6867. * @param min defines the minimum vector (in local space)
  6868. * @param max defines the maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6872. /**
  6873. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6874. * @param min defines the new minimum vector (in local space)
  6875. * @param max defines the new maximum vector (in local space)
  6876. * @param worldMatrix defines the new world matrix
  6877. */
  6878. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6879. /**
  6880. * Scale the current bounding box by applying a scale factor
  6881. * @param factor defines the scale factor to apply
  6882. * @returns the current bounding box
  6883. */
  6884. scale(factor: number): BoundingBox;
  6885. /**
  6886. * Gets the world matrix of the bounding box
  6887. * @returns a matrix
  6888. */
  6889. getWorldMatrix(): DeepImmutable<Matrix>;
  6890. /** @hidden */
  6891. _update(world: DeepImmutable<Matrix>): void;
  6892. /**
  6893. * Tests if the bounding box is intersecting the frustum planes
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if there is an intersection
  6896. */
  6897. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if the bounding box is entirely inside the frustum planes
  6900. * @param frustumPlanes defines the frustum planes to test
  6901. * @returns true if there is an inclusion
  6902. */
  6903. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6904. /**
  6905. * Tests if a point is inside the bounding box
  6906. * @param point defines the point to test
  6907. * @returns true if the point is inside the bounding box
  6908. */
  6909. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6910. /**
  6911. * Tests if the bounding box intersects with a bounding sphere
  6912. * @param sphere defines the sphere to test
  6913. * @returns true if there is an intersection
  6914. */
  6915. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6916. /**
  6917. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6918. * @param min defines the min vector to use
  6919. * @param max defines the max vector to use
  6920. * @returns true if there is an intersection
  6921. */
  6922. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6923. /**
  6924. * Tests if two bounding boxes are intersections
  6925. * @param box0 defines the first box to test
  6926. * @param box1 defines the second box to test
  6927. * @returns true if there is an intersection
  6928. */
  6929. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6930. /**
  6931. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6932. * @param minPoint defines the minimum vector of the bounding box
  6933. * @param maxPoint defines the maximum vector of the bounding box
  6934. * @param sphereCenter defines the sphere center
  6935. * @param sphereRadius defines the sphere radius
  6936. * @returns true if there is an intersection
  6937. */
  6938. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6939. /**
  6940. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6941. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @return true if there is an inclusion
  6944. */
  6945. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6948. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6949. * @param frustumPlanes defines the frustum planes to test
  6950. * @return true if there is an intersection
  6951. */
  6952. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6953. }
  6954. }
  6955. declare module BABYLON {
  6956. /** @hidden */
  6957. export class Collider {
  6958. /** Define if a collision was found */
  6959. collisionFound: boolean;
  6960. /**
  6961. * Define last intersection point in local space
  6962. */
  6963. intersectionPoint: Vector3;
  6964. /**
  6965. * Define last collided mesh
  6966. */
  6967. collidedMesh: Nullable<AbstractMesh>;
  6968. private _collisionPoint;
  6969. private _planeIntersectionPoint;
  6970. private _tempVector;
  6971. private _tempVector2;
  6972. private _tempVector3;
  6973. private _tempVector4;
  6974. private _edge;
  6975. private _baseToVertex;
  6976. private _destinationPoint;
  6977. private _slidePlaneNormal;
  6978. private _displacementVector;
  6979. /** @hidden */
  6980. _radius: Vector3;
  6981. /** @hidden */
  6982. _retry: number;
  6983. private _velocity;
  6984. private _basePoint;
  6985. private _epsilon;
  6986. /** @hidden */
  6987. _velocityWorldLength: number;
  6988. /** @hidden */
  6989. _basePointWorld: Vector3;
  6990. private _velocityWorld;
  6991. private _normalizedVelocity;
  6992. /** @hidden */
  6993. _initialVelocity: Vector3;
  6994. /** @hidden */
  6995. _initialPosition: Vector3;
  6996. private _nearestDistance;
  6997. private _collisionMask;
  6998. get collisionMask(): number;
  6999. set collisionMask(mask: number);
  7000. /**
  7001. * Gets the plane normal used to compute the sliding response (in local space)
  7002. */
  7003. get slidePlaneNormal(): Vector3;
  7004. /** @hidden */
  7005. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7006. /** @hidden */
  7007. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7008. /** @hidden */
  7009. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7010. /** @hidden */
  7011. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7014. /** @hidden */
  7015. _getResponse(pos: Vector3, vel: Vector3): void;
  7016. }
  7017. }
  7018. declare module BABYLON {
  7019. /**
  7020. * Interface for cullable objects
  7021. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7022. */
  7023. export interface ICullable {
  7024. /**
  7025. * Checks if the object or part of the object is in the frustum
  7026. * @param frustumPlanes Camera near/planes
  7027. * @returns true if the object is in frustum otherwise false
  7028. */
  7029. isInFrustum(frustumPlanes: Plane[]): boolean;
  7030. /**
  7031. * Checks if a cullable object (mesh...) is in the camera frustum
  7032. * Unlike isInFrustum this cheks the full bounding box
  7033. * @param frustumPlanes Camera near/planes
  7034. * @returns true if the object is in frustum otherwise false
  7035. */
  7036. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7037. }
  7038. /**
  7039. * Info for a bounding data of a mesh
  7040. */
  7041. export class BoundingInfo implements ICullable {
  7042. /**
  7043. * Bounding box for the mesh
  7044. */
  7045. readonly boundingBox: BoundingBox;
  7046. /**
  7047. * Bounding sphere for the mesh
  7048. */
  7049. readonly boundingSphere: BoundingSphere;
  7050. private _isLocked;
  7051. private static readonly TmpVector3;
  7052. /**
  7053. * Constructs bounding info
  7054. * @param minimum min vector of the bounding box/sphere
  7055. * @param maximum max vector of the bounding box/sphere
  7056. * @param worldMatrix defines the new world matrix
  7057. */
  7058. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7059. /**
  7060. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7061. * @param min defines the new minimum vector (in local space)
  7062. * @param max defines the new maximum vector (in local space)
  7063. * @param worldMatrix defines the new world matrix
  7064. */
  7065. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7066. /**
  7067. * min vector of the bounding box/sphere
  7068. */
  7069. get minimum(): Vector3;
  7070. /**
  7071. * max vector of the bounding box/sphere
  7072. */
  7073. get maximum(): Vector3;
  7074. /**
  7075. * If the info is locked and won't be updated to avoid perf overhead
  7076. */
  7077. get isLocked(): boolean;
  7078. set isLocked(value: boolean);
  7079. /**
  7080. * Updates the bounding sphere and box
  7081. * @param world world matrix to be used to update
  7082. */
  7083. update(world: DeepImmutable<Matrix>): void;
  7084. /**
  7085. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7086. * @param center New center of the bounding info
  7087. * @param extend New extend of the bounding info
  7088. * @returns the current bounding info
  7089. */
  7090. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7091. /**
  7092. * Scale the current bounding info by applying a scale factor
  7093. * @param factor defines the scale factor to apply
  7094. * @returns the current bounding info
  7095. */
  7096. scale(factor: number): BoundingInfo;
  7097. /**
  7098. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7099. * @param frustumPlanes defines the frustum to test
  7100. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7101. * @returns true if the bounding info is in the frustum planes
  7102. */
  7103. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7104. /**
  7105. * Gets the world distance between the min and max points of the bounding box
  7106. */
  7107. get diagonalLength(): number;
  7108. /**
  7109. * Checks if a cullable object (mesh...) is in the camera frustum
  7110. * Unlike isInFrustum this cheks the full bounding box
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7115. /** @hidden */
  7116. _checkCollision(collider: Collider): boolean;
  7117. /**
  7118. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7119. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7120. * @param point the point to check intersection with
  7121. * @returns if the point intersects
  7122. */
  7123. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7124. /**
  7125. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7126. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7127. * @param boundingInfo the bounding info to check intersection with
  7128. * @param precise if the intersection should be done using OBB
  7129. * @returns if the bounding info intersects
  7130. */
  7131. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7132. }
  7133. }
  7134. declare module BABYLON {
  7135. /**
  7136. * Extracts minimum and maximum values from a list of indexed positions
  7137. * @param positions defines the positions to use
  7138. * @param indices defines the indices to the positions
  7139. * @param indexStart defines the start index
  7140. * @param indexCount defines the end index
  7141. * @param bias defines bias value to add to the result
  7142. * @return minimum and maximum values
  7143. */
  7144. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7145. minimum: Vector3;
  7146. maximum: Vector3;
  7147. };
  7148. /**
  7149. * Extracts minimum and maximum values from a list of positions
  7150. * @param positions defines the positions to use
  7151. * @param start defines the start index in the positions array
  7152. * @param count defines the number of positions to handle
  7153. * @param bias defines bias value to add to the result
  7154. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7155. * @return minimum and maximum values
  7156. */
  7157. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7158. minimum: Vector3;
  7159. maximum: Vector3;
  7160. };
  7161. }
  7162. declare module BABYLON {
  7163. /** @hidden */
  7164. export class WebGLDataBuffer extends DataBuffer {
  7165. private _buffer;
  7166. constructor(resource: WebGLBuffer);
  7167. get underlyingResource(): any;
  7168. }
  7169. }
  7170. declare module BABYLON {
  7171. /** @hidden */
  7172. export class WebGLPipelineContext implements IPipelineContext {
  7173. engine: ThinEngine;
  7174. program: Nullable<WebGLProgram>;
  7175. context?: WebGLRenderingContext;
  7176. vertexShader?: WebGLShader;
  7177. fragmentShader?: WebGLShader;
  7178. isParallelCompiled: boolean;
  7179. onCompiled?: () => void;
  7180. transformFeedback?: WebGLTransformFeedback | null;
  7181. vertexCompilationError: Nullable<string>;
  7182. fragmentCompilationError: Nullable<string>;
  7183. programLinkError: Nullable<string>;
  7184. programValidationError: Nullable<string>;
  7185. get isAsync(): boolean;
  7186. get isReady(): boolean;
  7187. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7188. _getVertexShaderCode(): string | null;
  7189. _getFragmentShaderCode(): string | null;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. declare module BABYLON {
  7238. /**
  7239. * Uniform buffer objects.
  7240. *
  7241. * Handles blocks of uniform on the GPU.
  7242. *
  7243. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7244. *
  7245. * For more information, please refer to :
  7246. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7247. */
  7248. export class UniformBuffer {
  7249. private _engine;
  7250. private _buffer;
  7251. private _data;
  7252. private _bufferData;
  7253. private _dynamic?;
  7254. private _uniformLocations;
  7255. private _uniformSizes;
  7256. private _uniformLocationPointer;
  7257. private _needSync;
  7258. private _noUBO;
  7259. private _currentEffect;
  7260. /** @hidden */
  7261. _alreadyBound: boolean;
  7262. private static _MAX_UNIFORM_SIZE;
  7263. private static _tempBuffer;
  7264. /**
  7265. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7266. * This is dynamic to allow compat with webgl 1 and 2.
  7267. * You will need to pass the name of the uniform as well as the value.
  7268. */
  7269. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7270. /**
  7271. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7272. * This is dynamic to allow compat with webgl 1 and 2.
  7273. * You will need to pass the name of the uniform as well as the value.
  7274. */
  7275. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7276. /**
  7277. * Lambda to Update a single float in a uniform buffer.
  7278. * This is dynamic to allow compat with webgl 1 and 2.
  7279. * You will need to pass the name of the uniform as well as the value.
  7280. */
  7281. updateFloat: (name: string, x: number) => void;
  7282. /**
  7283. * Lambda to Update a vec2 of float in a uniform buffer.
  7284. * This is dynamic to allow compat with webgl 1 and 2.
  7285. * You will need to pass the name of the uniform as well as the value.
  7286. */
  7287. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7288. /**
  7289. * Lambda to Update a vec3 of float in a uniform buffer.
  7290. * This is dynamic to allow compat with webgl 1 and 2.
  7291. * You will need to pass the name of the uniform as well as the value.
  7292. */
  7293. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7294. /**
  7295. * Lambda to Update a vec4 of float in a uniform buffer.
  7296. * This is dynamic to allow compat with webgl 1 and 2.
  7297. * You will need to pass the name of the uniform as well as the value.
  7298. */
  7299. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7300. /**
  7301. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7302. * This is dynamic to allow compat with webgl 1 and 2.
  7303. * You will need to pass the name of the uniform as well as the value.
  7304. */
  7305. updateMatrix: (name: string, mat: Matrix) => void;
  7306. /**
  7307. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7308. * This is dynamic to allow compat with webgl 1 and 2.
  7309. * You will need to pass the name of the uniform as well as the value.
  7310. */
  7311. updateVector3: (name: string, vector: Vector3) => void;
  7312. /**
  7313. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7314. * This is dynamic to allow compat with webgl 1 and 2.
  7315. * You will need to pass the name of the uniform as well as the value.
  7316. */
  7317. updateVector4: (name: string, vector: Vector4) => void;
  7318. /**
  7319. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7320. * This is dynamic to allow compat with webgl 1 and 2.
  7321. * You will need to pass the name of the uniform as well as the value.
  7322. */
  7323. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7324. /**
  7325. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7326. * This is dynamic to allow compat with webgl 1 and 2.
  7327. * You will need to pass the name of the uniform as well as the value.
  7328. */
  7329. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7330. /**
  7331. * Instantiates a new Uniform buffer objects.
  7332. *
  7333. * Handles blocks of uniform on the GPU.
  7334. *
  7335. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7336. *
  7337. * For more information, please refer to :
  7338. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7339. * @param engine Define the engine the buffer is associated with
  7340. * @param data Define the data contained in the buffer
  7341. * @param dynamic Define if the buffer is updatable
  7342. */
  7343. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7344. /**
  7345. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7346. * or just falling back on setUniformXXX calls.
  7347. */
  7348. get useUbo(): boolean;
  7349. /**
  7350. * Indicates if the WebGL underlying uniform buffer is in sync
  7351. * with the javascript cache data.
  7352. */
  7353. get isSync(): boolean;
  7354. /**
  7355. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7356. * Also, a dynamic UniformBuffer will disable cache verification and always
  7357. * update the underlying WebGL uniform buffer to the GPU.
  7358. * @returns if Dynamic, otherwise false
  7359. */
  7360. isDynamic(): boolean;
  7361. /**
  7362. * The data cache on JS side.
  7363. * @returns the underlying data as a float array
  7364. */
  7365. getData(): Float32Array;
  7366. /**
  7367. * The underlying WebGL Uniform buffer.
  7368. * @returns the webgl buffer
  7369. */
  7370. getBuffer(): Nullable<DataBuffer>;
  7371. /**
  7372. * std140 layout specifies how to align data within an UBO structure.
  7373. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7374. * for specs.
  7375. */
  7376. private _fillAlignment;
  7377. /**
  7378. * Adds an uniform in the buffer.
  7379. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7380. * for the layout to be correct !
  7381. * @param name Name of the uniform, as used in the uniform block in the shader.
  7382. * @param size Data size, or data directly.
  7383. */
  7384. addUniform(name: string, size: number | number[]): void;
  7385. /**
  7386. * Adds a Matrix 4x4 to the uniform buffer.
  7387. * @param name Name of the uniform, as used in the uniform block in the shader.
  7388. * @param mat A 4x4 matrix.
  7389. */
  7390. addMatrix(name: string, mat: Matrix): void;
  7391. /**
  7392. * Adds a vec2 to the uniform buffer.
  7393. * @param name Name of the uniform, as used in the uniform block in the shader.
  7394. * @param x Define the x component value of the vec2
  7395. * @param y Define the y component value of the vec2
  7396. */
  7397. addFloat2(name: string, x: number, y: number): void;
  7398. /**
  7399. * Adds a vec3 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. * @param x Define the x component value of the vec3
  7402. * @param y Define the y component value of the vec3
  7403. * @param z Define the z component value of the vec3
  7404. */
  7405. addFloat3(name: string, x: number, y: number, z: number): void;
  7406. /**
  7407. * Adds a vec3 to the uniform buffer.
  7408. * @param name Name of the uniform, as used in the uniform block in the shader.
  7409. * @param color Define the vec3 from a Color
  7410. */
  7411. addColor3(name: string, color: Color3): void;
  7412. /**
  7413. * Adds a vec4 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param color Define the rgb components from a Color
  7416. * @param alpha Define the a component of the vec4
  7417. */
  7418. addColor4(name: string, color: Color3, alpha: number): void;
  7419. /**
  7420. * Adds a vec3 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. * @param vector Define the vec3 components from a Vector
  7423. */
  7424. addVector3(name: string, vector: Vector3): void;
  7425. /**
  7426. * Adds a Matrix 3x3 to the uniform buffer.
  7427. * @param name Name of the uniform, as used in the uniform block in the shader.
  7428. */
  7429. addMatrix3x3(name: string): void;
  7430. /**
  7431. * Adds a Matrix 2x2 to the uniform buffer.
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. */
  7434. addMatrix2x2(name: string): void;
  7435. /**
  7436. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7437. */
  7438. create(): void;
  7439. /** @hidden */
  7440. _rebuild(): void;
  7441. /**
  7442. * Updates the WebGL Uniform Buffer on the GPU.
  7443. * If the `dynamic` flag is set to true, no cache comparison is done.
  7444. * Otherwise, the buffer will be updated only if the cache differs.
  7445. */
  7446. update(): void;
  7447. /**
  7448. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7449. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7450. * @param data Define the flattened data
  7451. * @param size Define the size of the data.
  7452. */
  7453. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7454. private _valueCache;
  7455. private _cacheMatrix;
  7456. private _updateMatrix3x3ForUniform;
  7457. private _updateMatrix3x3ForEffect;
  7458. private _updateMatrix2x2ForEffect;
  7459. private _updateMatrix2x2ForUniform;
  7460. private _updateFloatForEffect;
  7461. private _updateFloatForUniform;
  7462. private _updateFloat2ForEffect;
  7463. private _updateFloat2ForUniform;
  7464. private _updateFloat3ForEffect;
  7465. private _updateFloat3ForUniform;
  7466. private _updateFloat4ForEffect;
  7467. private _updateFloat4ForUniform;
  7468. private _updateMatrixForEffect;
  7469. private _updateMatrixForUniform;
  7470. private _updateVector3ForEffect;
  7471. private _updateVector3ForUniform;
  7472. private _updateVector4ForEffect;
  7473. private _updateVector4ForUniform;
  7474. private _updateColor3ForEffect;
  7475. private _updateColor3ForUniform;
  7476. private _updateColor4ForEffect;
  7477. private _updateColor4ForUniform;
  7478. /**
  7479. * Sets a sampler uniform on the effect.
  7480. * @param name Define the name of the sampler.
  7481. * @param texture Define the texture to set in the sampler
  7482. */
  7483. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7484. /**
  7485. * Directly updates the value of the uniform in the cache AND on the GPU.
  7486. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7487. * @param data Define the flattened data
  7488. */
  7489. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7490. /**
  7491. * Binds this uniform buffer to an effect.
  7492. * @param effect Define the effect to bind the buffer to
  7493. * @param name Name of the uniform block in the shader.
  7494. */
  7495. bindToEffect(effect: Effect, name: string): void;
  7496. /**
  7497. * Disposes the uniform buffer.
  7498. */
  7499. dispose(): void;
  7500. }
  7501. }
  7502. declare module BABYLON {
  7503. /**
  7504. * Enum that determines the text-wrapping mode to use.
  7505. */
  7506. export enum InspectableType {
  7507. /**
  7508. * Checkbox for booleans
  7509. */
  7510. Checkbox = 0,
  7511. /**
  7512. * Sliders for numbers
  7513. */
  7514. Slider = 1,
  7515. /**
  7516. * Vector3
  7517. */
  7518. Vector3 = 2,
  7519. /**
  7520. * Quaternions
  7521. */
  7522. Quaternion = 3,
  7523. /**
  7524. * Color3
  7525. */
  7526. Color3 = 4,
  7527. /**
  7528. * String
  7529. */
  7530. String = 5
  7531. }
  7532. /**
  7533. * Interface used to define custom inspectable properties.
  7534. * This interface is used by the inspector to display custom property grids
  7535. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7536. */
  7537. export interface IInspectable {
  7538. /**
  7539. * Gets the label to display
  7540. */
  7541. label: string;
  7542. /**
  7543. * Gets the name of the property to edit
  7544. */
  7545. propertyName: string;
  7546. /**
  7547. * Gets the type of the editor to use
  7548. */
  7549. type: InspectableType;
  7550. /**
  7551. * Gets the minimum value of the property when using in "slider" mode
  7552. */
  7553. min?: number;
  7554. /**
  7555. * Gets the maximum value of the property when using in "slider" mode
  7556. */
  7557. max?: number;
  7558. /**
  7559. * Gets the setp to use when using in "slider" mode
  7560. */
  7561. step?: number;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Class used to provide helper for timing
  7567. */
  7568. export class TimingTools {
  7569. /**
  7570. * Polyfill for setImmediate
  7571. * @param action defines the action to execute after the current execution block
  7572. */
  7573. static SetImmediate(action: () => void): void;
  7574. }
  7575. }
  7576. declare module BABYLON {
  7577. /**
  7578. * Class used to enable instatition of objects by class name
  7579. */
  7580. export class InstantiationTools {
  7581. /**
  7582. * Use this object to register external classes like custom textures or material
  7583. * to allow the laoders to instantiate them
  7584. */
  7585. static RegisteredExternalClasses: {
  7586. [key: string]: Object;
  7587. };
  7588. /**
  7589. * Tries to instantiate a new object from a given class name
  7590. * @param className defines the class name to instantiate
  7591. * @returns the new object or null if the system was not able to do the instantiation
  7592. */
  7593. static Instantiate(className: string): any;
  7594. }
  7595. }
  7596. declare module BABYLON {
  7597. /**
  7598. * Define options used to create a depth texture
  7599. */
  7600. export class DepthTextureCreationOptions {
  7601. /** Specifies whether or not a stencil should be allocated in the texture */
  7602. generateStencil?: boolean;
  7603. /** Specifies whether or not bilinear filtering is enable on the texture */
  7604. bilinearFiltering?: boolean;
  7605. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7606. comparisonFunction?: number;
  7607. /** Specifies if the created texture is a cube texture */
  7608. isCube?: boolean;
  7609. }
  7610. }
  7611. declare module BABYLON {
  7612. interface ThinEngine {
  7613. /**
  7614. * Creates a depth stencil cube texture.
  7615. * This is only available in WebGL 2.
  7616. * @param size The size of face edge in the cube texture.
  7617. * @param options The options defining the cube texture.
  7618. * @returns The cube texture
  7619. */
  7620. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7621. /**
  7622. * Creates a cube texture
  7623. * @param rootUrl defines the url where the files to load is located
  7624. * @param scene defines the current scene
  7625. * @param files defines the list of files to load (1 per face)
  7626. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7627. * @param onLoad defines an optional callback raised when the texture is loaded
  7628. * @param onError defines an optional callback raised if there is an issue to load the texture
  7629. * @param format defines the format of the data
  7630. * @param forcedExtension defines the extension to use to pick the right loader
  7631. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7635. * @returns the cube texture as an InternalTexture
  7636. */
  7637. 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;
  7638. /**
  7639. * Creates a cube texture
  7640. * @param rootUrl defines the url where the files to load is located
  7641. * @param scene defines the current scene
  7642. * @param files defines the list of files to load (1 per face)
  7643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7644. * @param onLoad defines an optional callback raised when the texture is loaded
  7645. * @param onError defines an optional callback raised if there is an issue to load the texture
  7646. * @param format defines the format of the data
  7647. * @param forcedExtension defines the extension to use to pick the right loader
  7648. * @returns the cube texture as an InternalTexture
  7649. */
  7650. 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;
  7651. /**
  7652. * Creates a cube texture
  7653. * @param rootUrl defines the url where the files to load is located
  7654. * @param scene defines the current scene
  7655. * @param files defines the list of files to load (1 per face)
  7656. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7657. * @param onLoad defines an optional callback raised when the texture is loaded
  7658. * @param onError defines an optional callback raised if there is an issue to load the texture
  7659. * @param format defines the format of the data
  7660. * @param forcedExtension defines the extension to use to pick the right loader
  7661. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7662. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7663. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. 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;
  7667. /** @hidden */
  7668. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7671. /** @hidden */
  7672. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /** @hidden */
  7674. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7675. /**
  7676. * @hidden
  7677. */
  7678. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7679. }
  7680. }
  7681. declare module BABYLON {
  7682. /**
  7683. * Class for creating a cube texture
  7684. */
  7685. export class CubeTexture extends BaseTexture {
  7686. private _delayedOnLoad;
  7687. /**
  7688. * Observable triggered once the texture has been loaded.
  7689. */
  7690. onLoadObservable: Observable<CubeTexture>;
  7691. /**
  7692. * The url of the texture
  7693. */
  7694. url: string;
  7695. /**
  7696. * Gets or sets the center of the bounding box associated with the cube texture.
  7697. * It must define where the camera used to render the texture was set
  7698. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7699. */
  7700. boundingBoxPosition: Vector3;
  7701. private _boundingBoxSize;
  7702. /**
  7703. * Gets or sets the size of the bounding box associated with the cube texture
  7704. * When defined, the cubemap will switch to local mode
  7705. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7706. * @example https://www.babylonjs-playground.com/#RNASML
  7707. */
  7708. set boundingBoxSize(value: Vector3);
  7709. /**
  7710. * Returns the bounding box size
  7711. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7712. */
  7713. get boundingBoxSize(): Vector3;
  7714. protected _rotationY: number;
  7715. /**
  7716. * Sets texture matrix rotation angle around Y axis in radians.
  7717. */
  7718. set rotationY(value: number);
  7719. /**
  7720. * Gets texture matrix rotation angle around Y axis radians.
  7721. */
  7722. get rotationY(): number;
  7723. /**
  7724. * Are mip maps generated for this texture or not.
  7725. */
  7726. get noMipmap(): boolean;
  7727. private _noMipmap;
  7728. private _files;
  7729. protected _forcedExtension: Nullable<string>;
  7730. private _extensions;
  7731. private _textureMatrix;
  7732. private _format;
  7733. private _createPolynomials;
  7734. /** @hidden */
  7735. _prefiltered: boolean;
  7736. /**
  7737. * Creates a cube texture from an array of image urls
  7738. * @param files defines an array of image urls
  7739. * @param scene defines the hosting scene
  7740. * @param noMipmap specifies if mip maps are not used
  7741. * @returns a cube texture
  7742. */
  7743. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7744. /**
  7745. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7746. * @param url defines the url of the prefiltered texture
  7747. * @param scene defines the scene the texture is attached to
  7748. * @param forcedExtension defines the extension of the file if different from the url
  7749. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7750. * @return the prefiltered texture
  7751. */
  7752. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7753. /**
  7754. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7755. * as prefiltered data.
  7756. * @param rootUrl defines the url of the texture or the root name of the six images
  7757. * @param scene defines the scene the texture is attached to
  7758. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7759. * @param noMipmap defines if mipmaps should be created or not
  7760. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7761. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7762. * @param onError defines a callback triggered in case of error during load
  7763. * @param format defines the internal format to use for the texture once loaded
  7764. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7765. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7766. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7767. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7768. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7769. * @return the cube texture
  7770. */
  7771. 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);
  7772. /**
  7773. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7774. */
  7775. get isPrefiltered(): boolean;
  7776. /**
  7777. * Get the current class name of the texture useful for serialization or dynamic coding.
  7778. * @returns "CubeTexture"
  7779. */
  7780. getClassName(): string;
  7781. /**
  7782. * Update the url (and optional buffer) of this texture if url was null during construction.
  7783. * @param url the url of the texture
  7784. * @param forcedExtension defines the extension to use
  7785. * @param onLoad callback called when the texture is loaded (defaults to null)
  7786. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7787. */
  7788. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7789. /**
  7790. * Delays loading of the cube texture
  7791. * @param forcedExtension defines the extension to use
  7792. */
  7793. delayLoad(forcedExtension?: string): void;
  7794. /**
  7795. * Returns the reflection texture matrix
  7796. * @returns the reflection texture matrix
  7797. */
  7798. getReflectionTextureMatrix(): Matrix;
  7799. /**
  7800. * Sets the reflection texture matrix
  7801. * @param value Reflection texture matrix
  7802. */
  7803. setReflectionTextureMatrix(value: Matrix): void;
  7804. /**
  7805. * Parses text to create a cube texture
  7806. * @param parsedTexture define the serialized text to read from
  7807. * @param scene defines the hosting scene
  7808. * @param rootUrl defines the root url of the cube texture
  7809. * @returns a cube texture
  7810. */
  7811. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7812. /**
  7813. * Makes a clone, or deep copy, of the cube texture
  7814. * @returns a new cube texture
  7815. */
  7816. clone(): CubeTexture;
  7817. }
  7818. }
  7819. declare module BABYLON {
  7820. /**
  7821. * Manages the defines for the Material
  7822. */
  7823. export class MaterialDefines {
  7824. /** @hidden */
  7825. protected _keys: string[];
  7826. private _isDirty;
  7827. /** @hidden */
  7828. _renderId: number;
  7829. /** @hidden */
  7830. _areLightsDirty: boolean;
  7831. /** @hidden */
  7832. _areLightsDisposed: boolean;
  7833. /** @hidden */
  7834. _areAttributesDirty: boolean;
  7835. /** @hidden */
  7836. _areTexturesDirty: boolean;
  7837. /** @hidden */
  7838. _areFresnelDirty: boolean;
  7839. /** @hidden */
  7840. _areMiscDirty: boolean;
  7841. /** @hidden */
  7842. _areImageProcessingDirty: boolean;
  7843. /** @hidden */
  7844. _normals: boolean;
  7845. /** @hidden */
  7846. _uvs: boolean;
  7847. /** @hidden */
  7848. _needNormals: boolean;
  7849. /** @hidden */
  7850. _needUVs: boolean;
  7851. [id: string]: any;
  7852. /**
  7853. * Specifies if the material needs to be re-calculated
  7854. */
  7855. get isDirty(): boolean;
  7856. /**
  7857. * Marks the material to indicate that it has been re-calculated
  7858. */
  7859. markAsProcessed(): void;
  7860. /**
  7861. * Marks the material to indicate that it needs to be re-calculated
  7862. */
  7863. markAsUnprocessed(): void;
  7864. /**
  7865. * Marks the material to indicate all of its defines need to be re-calculated
  7866. */
  7867. markAllAsDirty(): void;
  7868. /**
  7869. * Marks the material to indicate that image processing needs to be re-calculated
  7870. */
  7871. markAsImageProcessingDirty(): void;
  7872. /**
  7873. * Marks the material to indicate the lights need to be re-calculated
  7874. * @param disposed Defines whether the light is dirty due to dispose or not
  7875. */
  7876. markAsLightDirty(disposed?: boolean): void;
  7877. /**
  7878. * Marks the attribute state as changed
  7879. */
  7880. markAsAttributesDirty(): void;
  7881. /**
  7882. * Marks the texture state as changed
  7883. */
  7884. markAsTexturesDirty(): void;
  7885. /**
  7886. * Marks the fresnel state as changed
  7887. */
  7888. markAsFresnelDirty(): void;
  7889. /**
  7890. * Marks the misc state as changed
  7891. */
  7892. markAsMiscDirty(): void;
  7893. /**
  7894. * Rebuilds the material defines
  7895. */
  7896. rebuild(): void;
  7897. /**
  7898. * Specifies if two material defines are equal
  7899. * @param other - A material define instance to compare to
  7900. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7901. */
  7902. isEqual(other: MaterialDefines): boolean;
  7903. /**
  7904. * Clones this instance's defines to another instance
  7905. * @param other - material defines to clone values to
  7906. */
  7907. cloneTo(other: MaterialDefines): void;
  7908. /**
  7909. * Resets the material define values
  7910. */
  7911. reset(): void;
  7912. /**
  7913. * Converts the material define values to a string
  7914. * @returns - String of material define information
  7915. */
  7916. toString(): string;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7922. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7923. * 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;
  7924. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7925. */
  7926. export class ColorCurves {
  7927. private _dirty;
  7928. private _tempColor;
  7929. private _globalCurve;
  7930. private _highlightsCurve;
  7931. private _midtonesCurve;
  7932. private _shadowsCurve;
  7933. private _positiveCurve;
  7934. private _negativeCurve;
  7935. private _globalHue;
  7936. private _globalDensity;
  7937. private _globalSaturation;
  7938. private _globalExposure;
  7939. /**
  7940. * Gets the global Hue value.
  7941. * 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).
  7942. */
  7943. get globalHue(): number;
  7944. /**
  7945. * Sets the global Hue value.
  7946. * 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).
  7947. */
  7948. set globalHue(value: number);
  7949. /**
  7950. * Gets the global Density value.
  7951. * 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.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. get globalDensity(): number;
  7955. /**
  7956. * Sets the global Density value.
  7957. * 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.
  7958. * Values less than zero provide a filter of opposite hue.
  7959. */
  7960. set globalDensity(value: number);
  7961. /**
  7962. * Gets the global Saturation value.
  7963. * 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.
  7964. */
  7965. get globalSaturation(): number;
  7966. /**
  7967. * Sets the global Saturation value.
  7968. * 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.
  7969. */
  7970. set globalSaturation(value: number);
  7971. /**
  7972. * Gets the global Exposure value.
  7973. * 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.
  7974. */
  7975. get globalExposure(): number;
  7976. /**
  7977. * Sets the global Exposure value.
  7978. * 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.
  7979. */
  7980. set globalExposure(value: number);
  7981. private _highlightsHue;
  7982. private _highlightsDensity;
  7983. private _highlightsSaturation;
  7984. private _highlightsExposure;
  7985. /**
  7986. * Gets the highlights Hue value.
  7987. * 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).
  7988. */
  7989. get highlightsHue(): number;
  7990. /**
  7991. * Sets the highlights Hue value.
  7992. * 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).
  7993. */
  7994. set highlightsHue(value: number);
  7995. /**
  7996. * Gets the highlights Density value.
  7997. * 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.
  7998. * Values less than zero provide a filter of opposite hue.
  7999. */
  8000. get highlightsDensity(): number;
  8001. /**
  8002. * Sets the highlights Density value.
  8003. * 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.
  8004. * Values less than zero provide a filter of opposite hue.
  8005. */
  8006. set highlightsDensity(value: number);
  8007. /**
  8008. * Gets the highlights Saturation value.
  8009. * 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.
  8010. */
  8011. get highlightsSaturation(): number;
  8012. /**
  8013. * Sets the highlights Saturation value.
  8014. * 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.
  8015. */
  8016. set highlightsSaturation(value: number);
  8017. /**
  8018. * Gets the highlights Exposure value.
  8019. * 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.
  8020. */
  8021. get highlightsExposure(): number;
  8022. /**
  8023. * Sets the highlights Exposure value.
  8024. * 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.
  8025. */
  8026. set highlightsExposure(value: number);
  8027. private _midtonesHue;
  8028. private _midtonesDensity;
  8029. private _midtonesSaturation;
  8030. private _midtonesExposure;
  8031. /**
  8032. * Gets the midtones Hue value.
  8033. * 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).
  8034. */
  8035. get midtonesHue(): number;
  8036. /**
  8037. * Sets the midtones Hue value.
  8038. * 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).
  8039. */
  8040. set midtonesHue(value: number);
  8041. /**
  8042. * Gets the midtones Density value.
  8043. * 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.
  8044. * Values less than zero provide a filter of opposite hue.
  8045. */
  8046. get midtonesDensity(): number;
  8047. /**
  8048. * Sets the midtones Density value.
  8049. * 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.
  8050. * Values less than zero provide a filter of opposite hue.
  8051. */
  8052. set midtonesDensity(value: number);
  8053. /**
  8054. * Gets the midtones Saturation value.
  8055. * 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.
  8056. */
  8057. get midtonesSaturation(): number;
  8058. /**
  8059. * Sets the midtones Saturation value.
  8060. * 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.
  8061. */
  8062. set midtonesSaturation(value: number);
  8063. /**
  8064. * Gets the midtones Exposure value.
  8065. * 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.
  8066. */
  8067. get midtonesExposure(): number;
  8068. /**
  8069. * Sets the midtones Exposure value.
  8070. * 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.
  8071. */
  8072. set midtonesExposure(value: number);
  8073. private _shadowsHue;
  8074. private _shadowsDensity;
  8075. private _shadowsSaturation;
  8076. private _shadowsExposure;
  8077. /**
  8078. * Gets the shadows Hue value.
  8079. * 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).
  8080. */
  8081. get shadowsHue(): number;
  8082. /**
  8083. * Sets the shadows Hue value.
  8084. * 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).
  8085. */
  8086. set shadowsHue(value: number);
  8087. /**
  8088. * Gets the shadows Density value.
  8089. * 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.
  8090. * Values less than zero provide a filter of opposite hue.
  8091. */
  8092. get shadowsDensity(): number;
  8093. /**
  8094. * Sets the shadows Density value.
  8095. * 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.
  8096. * Values less than zero provide a filter of opposite hue.
  8097. */
  8098. set shadowsDensity(value: number);
  8099. /**
  8100. * Gets the shadows Saturation value.
  8101. * 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.
  8102. */
  8103. get shadowsSaturation(): number;
  8104. /**
  8105. * Sets the shadows Saturation value.
  8106. * 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.
  8107. */
  8108. set shadowsSaturation(value: number);
  8109. /**
  8110. * Gets the shadows Exposure value.
  8111. * 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.
  8112. */
  8113. get shadowsExposure(): number;
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * 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.
  8117. */
  8118. set shadowsExposure(value: number);
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module BABYLON {
  8188. /**
  8189. * Interface to follow in your material defines to integrate easily the
  8190. * Image proccessing functions.
  8191. * @hidden
  8192. */
  8193. export interface IImageProcessingConfigurationDefines {
  8194. IMAGEPROCESSING: boolean;
  8195. VIGNETTE: boolean;
  8196. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8197. VIGNETTEBLENDMODEOPAQUE: boolean;
  8198. TONEMAPPING: boolean;
  8199. TONEMAPPING_ACES: boolean;
  8200. CONTRAST: boolean;
  8201. EXPOSURE: boolean;
  8202. COLORCURVES: boolean;
  8203. COLORGRADING: boolean;
  8204. COLORGRADING3D: boolean;
  8205. SAMPLER3DGREENDEPTH: boolean;
  8206. SAMPLER3DBGRMAP: boolean;
  8207. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8208. }
  8209. /**
  8210. * @hidden
  8211. */
  8212. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8213. IMAGEPROCESSING: boolean;
  8214. VIGNETTE: boolean;
  8215. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8216. VIGNETTEBLENDMODEOPAQUE: boolean;
  8217. TONEMAPPING: boolean;
  8218. TONEMAPPING_ACES: boolean;
  8219. CONTRAST: boolean;
  8220. COLORCURVES: boolean;
  8221. COLORGRADING: boolean;
  8222. COLORGRADING3D: boolean;
  8223. SAMPLER3DGREENDEPTH: boolean;
  8224. SAMPLER3DBGRMAP: boolean;
  8225. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8226. EXPOSURE: boolean;
  8227. constructor();
  8228. }
  8229. /**
  8230. * This groups together the common properties used for image processing either in direct forward pass
  8231. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8232. * or not.
  8233. */
  8234. export class ImageProcessingConfiguration {
  8235. /**
  8236. * Default tone mapping applied in BabylonJS.
  8237. */
  8238. static readonly TONEMAPPING_STANDARD: number;
  8239. /**
  8240. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8241. * to other engines rendering to increase portability.
  8242. */
  8243. static readonly TONEMAPPING_ACES: number;
  8244. /**
  8245. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8246. */
  8247. colorCurves: Nullable<ColorCurves>;
  8248. private _colorCurvesEnabled;
  8249. /**
  8250. * Gets wether the color curves effect is enabled.
  8251. */
  8252. get colorCurvesEnabled(): boolean;
  8253. /**
  8254. * Sets wether the color curves effect is enabled.
  8255. */
  8256. set colorCurvesEnabled(value: boolean);
  8257. private _colorGradingTexture;
  8258. /**
  8259. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8260. */
  8261. get colorGradingTexture(): Nullable<BaseTexture>;
  8262. /**
  8263. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8264. */
  8265. set colorGradingTexture(value: Nullable<BaseTexture>);
  8266. private _colorGradingEnabled;
  8267. /**
  8268. * Gets wether the color grading effect is enabled.
  8269. */
  8270. get colorGradingEnabled(): boolean;
  8271. /**
  8272. * Sets wether the color grading effect is enabled.
  8273. */
  8274. set colorGradingEnabled(value: boolean);
  8275. private _colorGradingWithGreenDepth;
  8276. /**
  8277. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8278. */
  8279. get colorGradingWithGreenDepth(): boolean;
  8280. /**
  8281. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. set colorGradingWithGreenDepth(value: boolean);
  8284. private _colorGradingBGR;
  8285. /**
  8286. * Gets wether the color grading texture contains BGR values.
  8287. */
  8288. get colorGradingBGR(): boolean;
  8289. /**
  8290. * Sets wether the color grading texture contains BGR values.
  8291. */
  8292. set colorGradingBGR(value: boolean);
  8293. /** @hidden */
  8294. _exposure: number;
  8295. /**
  8296. * Gets the Exposure used in the effect.
  8297. */
  8298. get exposure(): number;
  8299. /**
  8300. * Sets the Exposure used in the effect.
  8301. */
  8302. set exposure(value: number);
  8303. private _toneMappingEnabled;
  8304. /**
  8305. * Gets wether the tone mapping effect is enabled.
  8306. */
  8307. get toneMappingEnabled(): boolean;
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. set toneMappingEnabled(value: boolean);
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. get toneMappingType(): number;
  8317. /**
  8318. * Sets the type of tone mapping effect used in BabylonJS.
  8319. */
  8320. set toneMappingType(value: number);
  8321. protected _contrast: number;
  8322. /**
  8323. * Gets the contrast used in the effect.
  8324. */
  8325. get contrast(): number;
  8326. /**
  8327. * Sets the contrast used in the effect.
  8328. */
  8329. set contrast(value: number);
  8330. /**
  8331. * Vignette stretch size.
  8332. */
  8333. vignetteStretch: number;
  8334. /**
  8335. * Vignette centre X Offset.
  8336. */
  8337. vignetteCentreX: number;
  8338. /**
  8339. * Vignette centre Y Offset.
  8340. */
  8341. vignetteCentreY: number;
  8342. /**
  8343. * Vignette weight or intensity of the vignette effect.
  8344. */
  8345. vignetteWeight: number;
  8346. /**
  8347. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8348. * if vignetteEnabled is set to true.
  8349. */
  8350. vignetteColor: Color4;
  8351. /**
  8352. * Camera field of view used by the Vignette effect.
  8353. */
  8354. vignetteCameraFov: number;
  8355. private _vignetteBlendMode;
  8356. /**
  8357. * Gets the vignette blend mode allowing different kind of effect.
  8358. */
  8359. get vignetteBlendMode(): number;
  8360. /**
  8361. * Sets the vignette blend mode allowing different kind of effect.
  8362. */
  8363. set vignetteBlendMode(value: number);
  8364. private _vignetteEnabled;
  8365. /**
  8366. * Gets wether the vignette effect is enabled.
  8367. */
  8368. get vignetteEnabled(): boolean;
  8369. /**
  8370. * Sets wether the vignette effect is enabled.
  8371. */
  8372. set vignetteEnabled(value: boolean);
  8373. private _applyByPostProcess;
  8374. /**
  8375. * Gets wether the image processing is applied through a post process or not.
  8376. */
  8377. get applyByPostProcess(): boolean;
  8378. /**
  8379. * Sets wether the image processing is applied through a post process or not.
  8380. */
  8381. set applyByPostProcess(value: boolean);
  8382. private _isEnabled;
  8383. /**
  8384. * Gets wether the image processing is enabled or not.
  8385. */
  8386. get isEnabled(): boolean;
  8387. /**
  8388. * Sets wether the image processing is enabled or not.
  8389. */
  8390. set isEnabled(value: boolean);
  8391. /**
  8392. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8393. */
  8394. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8395. /**
  8396. * Method called each time the image processing information changes requires to recompile the effect.
  8397. */
  8398. protected _updateParameters(): void;
  8399. /**
  8400. * Gets the current class name.
  8401. * @return "ImageProcessingConfiguration"
  8402. */
  8403. getClassName(): string;
  8404. /**
  8405. * Prepare the list of uniforms associated with the Image Processing effects.
  8406. * @param uniforms The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of samplers associated with the Image Processing effects.
  8412. * @param samplersList The list of uniforms used in the effect
  8413. * @param defines the list of defines currently in use
  8414. */
  8415. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8416. /**
  8417. * Prepare the list of defines associated to the shader.
  8418. * @param defines the list of defines to complete
  8419. * @param forPostProcess Define if we are currently in post process mode or not
  8420. */
  8421. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8422. /**
  8423. * Returns true if all the image processing information are ready.
  8424. * @returns True if ready, otherwise, false
  8425. */
  8426. isReady(): boolean;
  8427. /**
  8428. * Binds the image processing to the shader.
  8429. * @param effect The effect to bind to
  8430. * @param overrideAspectRatio Override the aspect ratio of the effect
  8431. */
  8432. bind(effect: Effect, overrideAspectRatio?: number): void;
  8433. /**
  8434. * Clones the current image processing instance.
  8435. * @return The cloned image processing
  8436. */
  8437. clone(): ImageProcessingConfiguration;
  8438. /**
  8439. * Serializes the current image processing instance to a json representation.
  8440. * @return a JSON representation
  8441. */
  8442. serialize(): any;
  8443. /**
  8444. * Parses the image processing from a json representation.
  8445. * @param source the JSON source to parse
  8446. * @return The parsed image processing
  8447. */
  8448. static Parse(source: any): ImageProcessingConfiguration;
  8449. private static _VIGNETTEMODE_MULTIPLY;
  8450. private static _VIGNETTEMODE_OPAQUE;
  8451. /**
  8452. * Used to apply the vignette as a mix with the pixel color.
  8453. */
  8454. static get VIGNETTEMODE_MULTIPLY(): number;
  8455. /**
  8456. * Used to apply the vignette as a replacement of the pixel color.
  8457. */
  8458. static get VIGNETTEMODE_OPAQUE(): number;
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /** @hidden */
  8463. export var postprocessVertexShader: {
  8464. name: string;
  8465. shader: string;
  8466. };
  8467. }
  8468. declare module BABYLON {
  8469. interface ThinEngine {
  8470. /**
  8471. * Creates a new render target texture
  8472. * @param size defines the size of the texture
  8473. * @param options defines the options used to create the texture
  8474. * @returns a new render target texture stored in an InternalTexture
  8475. */
  8476. createRenderTargetTexture(size: number | {
  8477. width: number;
  8478. height: number;
  8479. layers?: number;
  8480. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8481. /**
  8482. * Creates a depth stencil texture.
  8483. * This is only available in WebGL 2 or with the depth texture extension available.
  8484. * @param size The size of face edge in the texture.
  8485. * @param options The options defining the texture.
  8486. * @returns The texture
  8487. */
  8488. createDepthStencilTexture(size: number | {
  8489. width: number;
  8490. height: number;
  8491. layers?: number;
  8492. }, options: DepthTextureCreationOptions): InternalTexture;
  8493. /** @hidden */
  8494. _createDepthStencilTexture(size: number | {
  8495. width: number;
  8496. height: number;
  8497. layers?: number;
  8498. }, options: DepthTextureCreationOptions): InternalTexture;
  8499. }
  8500. }
  8501. declare module BABYLON {
  8502. /** Defines supported spaces */
  8503. export enum Space {
  8504. /** Local (object) space */
  8505. LOCAL = 0,
  8506. /** World space */
  8507. WORLD = 1,
  8508. /** Bone space */
  8509. BONE = 2
  8510. }
  8511. /** Defines the 3 main axes */
  8512. export class Axis {
  8513. /** X axis */
  8514. static X: Vector3;
  8515. /** Y axis */
  8516. static Y: Vector3;
  8517. /** Z axis */
  8518. static Z: Vector3;
  8519. }
  8520. }
  8521. declare module BABYLON {
  8522. /**
  8523. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8524. * This is the base of the follow, arc rotate cameras and Free camera
  8525. * @see http://doc.babylonjs.com/features/cameras
  8526. */
  8527. export class TargetCamera extends Camera {
  8528. private static _RigCamTransformMatrix;
  8529. private static _TargetTransformMatrix;
  8530. private static _TargetFocalPoint;
  8531. /**
  8532. * Define the current direction the camera is moving to
  8533. */
  8534. cameraDirection: Vector3;
  8535. /**
  8536. * Define the current rotation the camera is rotating to
  8537. */
  8538. cameraRotation: Vector2;
  8539. /**
  8540. * When set, the up vector of the camera will be updated by the rotation of the camera
  8541. */
  8542. updateUpVectorFromRotation: boolean;
  8543. private _tmpQuaternion;
  8544. /**
  8545. * Define the current rotation of the camera
  8546. */
  8547. rotation: Vector3;
  8548. /**
  8549. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8550. */
  8551. rotationQuaternion: Quaternion;
  8552. /**
  8553. * Define the current speed of the camera
  8554. */
  8555. speed: number;
  8556. /**
  8557. * Add constraint to the camera to prevent it to move freely in all directions and
  8558. * around all axis.
  8559. */
  8560. noRotationConstraint: boolean;
  8561. /**
  8562. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8563. * panning
  8564. */
  8565. invertRotation: boolean;
  8566. /**
  8567. * Speed multiplier for inverse camera panning
  8568. */
  8569. inverseRotationSpeed: number;
  8570. /**
  8571. * Define the current target of the camera as an object or a position.
  8572. */
  8573. lockedTarget: any;
  8574. /** @hidden */
  8575. _currentTarget: Vector3;
  8576. /** @hidden */
  8577. _initialFocalDistance: number;
  8578. /** @hidden */
  8579. _viewMatrix: Matrix;
  8580. /** @hidden */
  8581. _camMatrix: Matrix;
  8582. /** @hidden */
  8583. _cameraTransformMatrix: Matrix;
  8584. /** @hidden */
  8585. _cameraRotationMatrix: Matrix;
  8586. /** @hidden */
  8587. _referencePoint: Vector3;
  8588. /** @hidden */
  8589. _transformedReferencePoint: Vector3;
  8590. protected _globalCurrentTarget: Vector3;
  8591. protected _globalCurrentUpVector: Vector3;
  8592. /** @hidden */
  8593. _reset: () => void;
  8594. private _defaultUp;
  8595. /**
  8596. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8597. * This is the base of the follow, arc rotate cameras and Free camera
  8598. * @see http://doc.babylonjs.com/features/cameras
  8599. * @param name Defines the name of the camera in the scene
  8600. * @param position Defines the start position of the camera in the scene
  8601. * @param scene Defines the scene the camera belongs to
  8602. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8603. */
  8604. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8605. /**
  8606. * Gets the position in front of the camera at a given distance.
  8607. * @param distance The distance from the camera we want the position to be
  8608. * @returns the position
  8609. */
  8610. getFrontPosition(distance: number): Vector3;
  8611. /** @hidden */
  8612. _getLockedTargetPosition(): Nullable<Vector3>;
  8613. private _storedPosition;
  8614. private _storedRotation;
  8615. private _storedRotationQuaternion;
  8616. /**
  8617. * Store current camera state of the camera (fov, position, rotation, etc..)
  8618. * @returns the camera
  8619. */
  8620. storeState(): Camera;
  8621. /**
  8622. * Restored camera state. You must call storeState() first
  8623. * @returns whether it was successful or not
  8624. * @hidden
  8625. */
  8626. _restoreStateValues(): boolean;
  8627. /** @hidden */
  8628. _initCache(): void;
  8629. /** @hidden */
  8630. _updateCache(ignoreParentClass?: boolean): void;
  8631. /** @hidden */
  8632. _isSynchronizedViewMatrix(): boolean;
  8633. /** @hidden */
  8634. _computeLocalCameraSpeed(): number;
  8635. /**
  8636. * Defines the target the camera should look at.
  8637. * @param target Defines the new target as a Vector or a mesh
  8638. */
  8639. setTarget(target: Vector3): void;
  8640. /**
  8641. * Return the current target position of the camera. This value is expressed in local space.
  8642. * @returns the target position
  8643. */
  8644. getTarget(): Vector3;
  8645. /** @hidden */
  8646. _decideIfNeedsToMove(): boolean;
  8647. /** @hidden */
  8648. _updatePosition(): void;
  8649. /** @hidden */
  8650. _checkInputs(): void;
  8651. protected _updateCameraRotationMatrix(): void;
  8652. /**
  8653. * 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)
  8654. * @returns the current camera
  8655. */
  8656. private _rotateUpVectorWithCameraRotationMatrix;
  8657. private _cachedRotationZ;
  8658. private _cachedQuaternionRotationZ;
  8659. /** @hidden */
  8660. _getViewMatrix(): Matrix;
  8661. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8662. /**
  8663. * @hidden
  8664. */
  8665. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8666. /**
  8667. * @hidden
  8668. */
  8669. _updateRigCameras(): void;
  8670. private _getRigCamPositionAndTarget;
  8671. /**
  8672. * Gets the current object class name.
  8673. * @return the class name
  8674. */
  8675. getClassName(): string;
  8676. }
  8677. }
  8678. declare module BABYLON {
  8679. /**
  8680. * Gather the list of keyboard event types as constants.
  8681. */
  8682. export class KeyboardEventTypes {
  8683. /**
  8684. * The keydown event is fired when a key becomes active (pressed).
  8685. */
  8686. static readonly KEYDOWN: number;
  8687. /**
  8688. * The keyup event is fired when a key has been released.
  8689. */
  8690. static readonly KEYUP: number;
  8691. }
  8692. /**
  8693. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8694. */
  8695. export class KeyboardInfo {
  8696. /**
  8697. * Defines the type of event (KeyboardEventTypes)
  8698. */
  8699. type: number;
  8700. /**
  8701. * Defines the related dom event
  8702. */
  8703. event: KeyboardEvent;
  8704. /**
  8705. * Instantiates a new keyboard info.
  8706. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8707. * @param type Defines the type of event (KeyboardEventTypes)
  8708. * @param event Defines the related dom event
  8709. */
  8710. constructor(
  8711. /**
  8712. * Defines the type of event (KeyboardEventTypes)
  8713. */
  8714. type: number,
  8715. /**
  8716. * Defines the related dom event
  8717. */
  8718. event: KeyboardEvent);
  8719. }
  8720. /**
  8721. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8722. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8723. */
  8724. export class KeyboardInfoPre extends KeyboardInfo {
  8725. /**
  8726. * Defines the type of event (KeyboardEventTypes)
  8727. */
  8728. type: number;
  8729. /**
  8730. * Defines the related dom event
  8731. */
  8732. event: KeyboardEvent;
  8733. /**
  8734. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8735. */
  8736. skipOnPointerObservable: boolean;
  8737. /**
  8738. * Instantiates a new keyboard pre info.
  8739. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8740. * @param type Defines the type of event (KeyboardEventTypes)
  8741. * @param event Defines the related dom event
  8742. */
  8743. constructor(
  8744. /**
  8745. * Defines the type of event (KeyboardEventTypes)
  8746. */
  8747. type: number,
  8748. /**
  8749. * Defines the related dom event
  8750. */
  8751. event: KeyboardEvent);
  8752. }
  8753. }
  8754. declare module BABYLON {
  8755. /**
  8756. * Manage the keyboard inputs to control the movement of a free camera.
  8757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8758. */
  8759. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8760. /**
  8761. * Defines the camera the input is attached to.
  8762. */
  8763. camera: FreeCamera;
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8766. */
  8767. keysUp: number[];
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8770. */
  8771. keysUpward: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8774. */
  8775. keysDown: number[];
  8776. /**
  8777. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8778. */
  8779. keysDownward: number[];
  8780. /**
  8781. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8782. */
  8783. keysLeft: number[];
  8784. /**
  8785. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8786. */
  8787. keysRight: number[];
  8788. private _keys;
  8789. private _onCanvasBlurObserver;
  8790. private _onKeyboardObserver;
  8791. private _engine;
  8792. private _scene;
  8793. /**
  8794. * Attach the input controls to a specific dom element to get the input from.
  8795. * @param element Defines the element the controls should be listened from
  8796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8797. */
  8798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8799. /**
  8800. * Detach the current controls from the specified dom element.
  8801. * @param element Defines the element to stop listening the inputs from
  8802. */
  8803. detachControl(element: Nullable<HTMLElement>): void;
  8804. /**
  8805. * Update the current camera state depending on the inputs that have been used this frame.
  8806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8807. */
  8808. checkInputs(): void;
  8809. /**
  8810. * Gets the class name of the current intput.
  8811. * @returns the class name
  8812. */
  8813. getClassName(): string;
  8814. /** @hidden */
  8815. _onLostFocus(): void;
  8816. /**
  8817. * Get the friendly name associated with the input class.
  8818. * @returns the input friendly name
  8819. */
  8820. getSimpleName(): string;
  8821. }
  8822. }
  8823. declare module BABYLON {
  8824. /**
  8825. * Interface describing all the common properties and methods a shadow light needs to implement.
  8826. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8827. * as well as binding the different shadow properties to the effects.
  8828. */
  8829. export interface IShadowLight extends Light {
  8830. /**
  8831. * The light id in the scene (used in scene.findLighById for instance)
  8832. */
  8833. id: string;
  8834. /**
  8835. * The position the shdow will be casted from.
  8836. */
  8837. position: Vector3;
  8838. /**
  8839. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8840. */
  8841. direction: Vector3;
  8842. /**
  8843. * The transformed position. Position of the light in world space taking parenting in account.
  8844. */
  8845. transformedPosition: Vector3;
  8846. /**
  8847. * The transformed direction. Direction of the light in world space taking parenting in account.
  8848. */
  8849. transformedDirection: Vector3;
  8850. /**
  8851. * The friendly name of the light in the scene.
  8852. */
  8853. name: string;
  8854. /**
  8855. * Defines the shadow projection clipping minimum z value.
  8856. */
  8857. shadowMinZ: number;
  8858. /**
  8859. * Defines the shadow projection clipping maximum z value.
  8860. */
  8861. shadowMaxZ: number;
  8862. /**
  8863. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8864. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8865. */
  8866. computeTransformedInformation(): boolean;
  8867. /**
  8868. * Gets the scene the light belongs to.
  8869. * @returns The scene
  8870. */
  8871. getScene(): Scene;
  8872. /**
  8873. * Callback defining a custom Projection Matrix Builder.
  8874. * This can be used to override the default projection matrix computation.
  8875. */
  8876. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8877. /**
  8878. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8879. * @param matrix The materix to updated with the projection information
  8880. * @param viewMatrix The transform matrix of the light
  8881. * @param renderList The list of mesh to render in the map
  8882. * @returns The current light
  8883. */
  8884. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8885. /**
  8886. * Gets the current depth scale used in ESM.
  8887. * @returns The scale
  8888. */
  8889. getDepthScale(): number;
  8890. /**
  8891. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8892. * @returns true if a cube texture needs to be use
  8893. */
  8894. needCube(): boolean;
  8895. /**
  8896. * Detects if the projection matrix requires to be recomputed this frame.
  8897. * @returns true if it requires to be recomputed otherwise, false.
  8898. */
  8899. needProjectionMatrixCompute(): boolean;
  8900. /**
  8901. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8902. */
  8903. forceProjectionMatrixCompute(): void;
  8904. /**
  8905. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8906. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8907. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8908. */
  8909. getShadowDirection(faceIndex?: number): Vector3;
  8910. /**
  8911. * Gets the minZ used for shadow according to both the scene and the light.
  8912. * @param activeCamera The camera we are returning the min for
  8913. * @returns the depth min z
  8914. */
  8915. getDepthMinZ(activeCamera: Camera): number;
  8916. /**
  8917. * Gets the maxZ used for shadow according to both the scene and the light.
  8918. * @param activeCamera The camera we are returning the max for
  8919. * @returns the depth max z
  8920. */
  8921. getDepthMaxZ(activeCamera: Camera): number;
  8922. }
  8923. /**
  8924. * Base implementation IShadowLight
  8925. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8926. */
  8927. export abstract class ShadowLight extends Light implements IShadowLight {
  8928. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8929. protected _position: Vector3;
  8930. protected _setPosition(value: Vector3): void;
  8931. /**
  8932. * Sets the position the shadow will be casted from. Also use as the light position for both
  8933. * point and spot lights.
  8934. */
  8935. get position(): Vector3;
  8936. /**
  8937. * Sets the position the shadow will be casted from. Also use as the light position for both
  8938. * point and spot lights.
  8939. */
  8940. set position(value: Vector3);
  8941. protected _direction: Vector3;
  8942. protected _setDirection(value: Vector3): void;
  8943. /**
  8944. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8945. * Also use as the light direction on spot and directional lights.
  8946. */
  8947. get direction(): Vector3;
  8948. /**
  8949. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8950. * Also use as the light direction on spot and directional lights.
  8951. */
  8952. set direction(value: Vector3);
  8953. protected _shadowMinZ: number;
  8954. /**
  8955. * Gets the shadow projection clipping minimum z value.
  8956. */
  8957. get shadowMinZ(): number;
  8958. /**
  8959. * Sets the shadow projection clipping minimum z value.
  8960. */
  8961. set shadowMinZ(value: number);
  8962. protected _shadowMaxZ: number;
  8963. /**
  8964. * Sets the shadow projection clipping maximum z value.
  8965. */
  8966. get shadowMaxZ(): number;
  8967. /**
  8968. * Gets the shadow projection clipping maximum z value.
  8969. */
  8970. set shadowMaxZ(value: number);
  8971. /**
  8972. * Callback defining a custom Projection Matrix Builder.
  8973. * This can be used to override the default projection matrix computation.
  8974. */
  8975. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8976. /**
  8977. * The transformed position. Position of the light in world space taking parenting in account.
  8978. */
  8979. transformedPosition: Vector3;
  8980. /**
  8981. * The transformed direction. Direction of the light in world space taking parenting in account.
  8982. */
  8983. transformedDirection: Vector3;
  8984. private _needProjectionMatrixCompute;
  8985. /**
  8986. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8987. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8988. */
  8989. computeTransformedInformation(): boolean;
  8990. /**
  8991. * Return the depth scale used for the shadow map.
  8992. * @returns the depth scale.
  8993. */
  8994. getDepthScale(): number;
  8995. /**
  8996. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8997. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8998. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8999. */
  9000. getShadowDirection(faceIndex?: number): Vector3;
  9001. /**
  9002. * Returns the ShadowLight absolute position in the World.
  9003. * @returns the position vector in world space
  9004. */
  9005. getAbsolutePosition(): Vector3;
  9006. /**
  9007. * Sets the ShadowLight direction toward the passed target.
  9008. * @param target The point to target in local space
  9009. * @returns the updated ShadowLight direction
  9010. */
  9011. setDirectionToTarget(target: Vector3): Vector3;
  9012. /**
  9013. * Returns the light rotation in euler definition.
  9014. * @returns the x y z rotation in local space.
  9015. */
  9016. getRotation(): Vector3;
  9017. /**
  9018. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9019. * @returns true if a cube texture needs to be use
  9020. */
  9021. needCube(): boolean;
  9022. /**
  9023. * Detects if the projection matrix requires to be recomputed this frame.
  9024. * @returns true if it requires to be recomputed otherwise, false.
  9025. */
  9026. needProjectionMatrixCompute(): boolean;
  9027. /**
  9028. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9029. */
  9030. forceProjectionMatrixCompute(): void;
  9031. /** @hidden */
  9032. _initCache(): void;
  9033. /** @hidden */
  9034. _isSynchronized(): boolean;
  9035. /**
  9036. * Computes the world matrix of the node
  9037. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9038. * @returns the world matrix
  9039. */
  9040. computeWorldMatrix(force?: boolean): Matrix;
  9041. /**
  9042. * Gets the minZ used for shadow according to both the scene and the light.
  9043. * @param activeCamera The camera we are returning the min for
  9044. * @returns the depth min z
  9045. */
  9046. getDepthMinZ(activeCamera: Camera): number;
  9047. /**
  9048. * Gets the maxZ used for shadow according to both the scene and the light.
  9049. * @param activeCamera The camera we are returning the max for
  9050. * @returns the depth max z
  9051. */
  9052. getDepthMaxZ(activeCamera: Camera): number;
  9053. /**
  9054. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9055. * @param matrix The materix to updated with the projection information
  9056. * @param viewMatrix The transform matrix of the light
  9057. * @param renderList The list of mesh to render in the map
  9058. * @returns The current light
  9059. */
  9060. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9061. }
  9062. }
  9063. declare module BABYLON {
  9064. /**
  9065. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9066. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9067. */
  9068. export class EffectFallbacks implements IEffectFallbacks {
  9069. private _defines;
  9070. private _currentRank;
  9071. private _maxRank;
  9072. private _mesh;
  9073. /**
  9074. * Removes the fallback from the bound mesh.
  9075. */
  9076. unBindMesh(): void;
  9077. /**
  9078. * Adds a fallback on the specified property.
  9079. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9080. * @param define The name of the define in the shader
  9081. */
  9082. addFallback(rank: number, define: string): void;
  9083. /**
  9084. * Sets the mesh to use CPU skinning when needing to fallback.
  9085. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9086. * @param mesh The mesh to use the fallbacks.
  9087. */
  9088. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9089. /**
  9090. * Checks to see if more fallbacks are still availible.
  9091. */
  9092. get hasMoreFallbacks(): boolean;
  9093. /**
  9094. * Removes the defines that should be removed when falling back.
  9095. * @param currentDefines defines the current define statements for the shader.
  9096. * @param effect defines the current effect we try to compile
  9097. * @returns The resulting defines with defines of the current rank removed.
  9098. */
  9099. reduce(currentDefines: string, effect: Effect): string;
  9100. }
  9101. }
  9102. declare module BABYLON {
  9103. /**
  9104. * "Static Class" containing the most commonly used helper while dealing with material for
  9105. * rendering purpose.
  9106. *
  9107. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9108. *
  9109. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9110. */
  9111. export class MaterialHelper {
  9112. /**
  9113. * Bind the current view position to an effect.
  9114. * @param effect The effect to be bound
  9115. * @param scene The scene the eyes position is used from
  9116. */
  9117. static BindEyePosition(effect: Effect, scene: Scene): void;
  9118. /**
  9119. * Helps preparing the defines values about the UVs in used in the effect.
  9120. * UVs are shared as much as we can accross channels in the shaders.
  9121. * @param texture The texture we are preparing the UVs for
  9122. * @param defines The defines to update
  9123. * @param key The channel key "diffuse", "specular"... used in the shader
  9124. */
  9125. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9126. /**
  9127. * Binds a texture matrix value to its corrsponding uniform
  9128. * @param texture The texture to bind the matrix for
  9129. * @param uniformBuffer The uniform buffer receivin the data
  9130. * @param key The channel key "diffuse", "specular"... used in the shader
  9131. */
  9132. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9133. /**
  9134. * Gets the current status of the fog (should it be enabled?)
  9135. * @param mesh defines the mesh to evaluate for fog support
  9136. * @param scene defines the hosting scene
  9137. * @returns true if fog must be enabled
  9138. */
  9139. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9140. /**
  9141. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9142. * @param mesh defines the current mesh
  9143. * @param scene defines the current scene
  9144. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9145. * @param pointsCloud defines if point cloud rendering has to be turned on
  9146. * @param fogEnabled defines if fog has to be turned on
  9147. * @param alphaTest defines if alpha testing has to be turned on
  9148. * @param defines defines the current list of defines
  9149. */
  9150. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9151. /**
  9152. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9153. * @param scene defines the current scene
  9154. * @param engine defines the current engine
  9155. * @param defines specifies the list of active defines
  9156. * @param useInstances defines if instances have to be turned on
  9157. * @param useClipPlane defines if clip plane have to be turned on
  9158. */
  9159. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9160. /**
  9161. * Prepares the defines for bones
  9162. * @param mesh The mesh containing the geometry data we will draw
  9163. * @param defines The defines to update
  9164. */
  9165. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9166. /**
  9167. * Prepares the defines for morph targets
  9168. * @param mesh The mesh containing the geometry data we will draw
  9169. * @param defines The defines to update
  9170. */
  9171. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9172. /**
  9173. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9174. * @param mesh The mesh containing the geometry data we will draw
  9175. * @param defines The defines to update
  9176. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9177. * @param useBones Precise whether bones should be used or not (override mesh info)
  9178. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9179. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9180. * @returns false if defines are considered not dirty and have not been checked
  9181. */
  9182. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9183. /**
  9184. * Prepares the defines related to multiview
  9185. * @param scene The scene we are intending to draw
  9186. * @param defines The defines to update
  9187. */
  9188. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9189. /**
  9190. * Prepares the defines related to the light information passed in parameter
  9191. * @param scene The scene we are intending to draw
  9192. * @param mesh The mesh the effect is compiling for
  9193. * @param light The light the effect is compiling for
  9194. * @param lightIndex The index of the light
  9195. * @param defines The defines to update
  9196. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9197. * @param state Defines the current state regarding what is needed (normals, etc...)
  9198. */
  9199. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9200. needNormals: boolean;
  9201. needRebuild: boolean;
  9202. shadowEnabled: boolean;
  9203. specularEnabled: boolean;
  9204. lightmapMode: boolean;
  9205. }): void;
  9206. /**
  9207. * Prepares the defines related to the light information passed in parameter
  9208. * @param scene The scene we are intending to draw
  9209. * @param mesh The mesh the effect is compiling for
  9210. * @param defines The defines to update
  9211. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9212. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9213. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9214. * @returns true if normals will be required for the rest of the effect
  9215. */
  9216. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9217. /**
  9218. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9219. * @param lightIndex defines the light index
  9220. * @param uniformsList The uniform list
  9221. * @param samplersList The sampler list
  9222. * @param projectedLightTexture defines if projected texture must be used
  9223. * @param uniformBuffersList defines an optional list of uniform buffers
  9224. */
  9225. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9226. /**
  9227. * Prepares the uniforms and samplers list to be used in the effect
  9228. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9229. * @param samplersList The sampler list
  9230. * @param defines The defines helping in the list generation
  9231. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9232. */
  9233. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9234. /**
  9235. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9236. * @param defines The defines to update while falling back
  9237. * @param fallbacks The authorized effect fallbacks
  9238. * @param maxSimultaneousLights The maximum number of lights allowed
  9239. * @param rank the current rank of the Effect
  9240. * @returns The newly affected rank
  9241. */
  9242. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9243. private static _TmpMorphInfluencers;
  9244. /**
  9245. * Prepares the list of attributes required for morph targets according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the morph targets attributes for
  9248. * @param influencers The number of influencers
  9249. */
  9250. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9251. /**
  9252. * Prepares the list of attributes required for morph targets according to the effect defines.
  9253. * @param attribs The current list of supported attribs
  9254. * @param mesh The mesh to prepare the morph targets attributes for
  9255. * @param defines The current Defines of the effect
  9256. */
  9257. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9258. /**
  9259. * Prepares the list of attributes required for bones according to the effect defines.
  9260. * @param attribs The current list of supported attribs
  9261. * @param mesh The mesh to prepare the bones attributes for
  9262. * @param defines The current Defines of the effect
  9263. * @param fallbacks The current efffect fallback strategy
  9264. */
  9265. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9266. /**
  9267. * Check and prepare the list of attributes required for instances according to the effect defines.
  9268. * @param attribs The current list of supported attribs
  9269. * @param defines The current MaterialDefines of the effect
  9270. */
  9271. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9272. /**
  9273. * Add the list of attributes required for instances to the attribs array.
  9274. * @param attribs The current list of supported attribs
  9275. */
  9276. static PushAttributesForInstances(attribs: string[]): void;
  9277. /**
  9278. * Binds the light information to the effect.
  9279. * @param light The light containing the generator
  9280. * @param effect The effect we are binding the data to
  9281. * @param lightIndex The light index in the effect used to render
  9282. */
  9283. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9284. /**
  9285. * Binds the lights information from the scene to the effect for the given mesh.
  9286. * @param light Light to bind
  9287. * @param lightIndex Light index
  9288. * @param scene The scene where the light belongs to
  9289. * @param effect The effect we are binding the data to
  9290. * @param useSpecular Defines if specular is supported
  9291. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9292. */
  9293. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9294. /**
  9295. * Binds the lights 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 defines The generated defines for the effect
  9300. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9301. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9302. */
  9303. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9304. private static _tempFogColor;
  9305. /**
  9306. * Binds the fog information from the scene to the effect for the given mesh.
  9307. * @param scene The scene the lights belongs to
  9308. * @param mesh The mesh we are binding the information to render
  9309. * @param effect The effect we are binding the data to
  9310. * @param linearSpace Defines if the fog effect is applied in linear space
  9311. */
  9312. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9313. /**
  9314. * Binds the bones information from the mesh to the effect.
  9315. * @param mesh The mesh we are binding the information to render
  9316. * @param effect The effect we are binding the data to
  9317. */
  9318. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9319. /**
  9320. * Binds the morph targets information from the mesh to the effect.
  9321. * @param abstractMesh The mesh we are binding the information to render
  9322. * @param effect The effect we are binding the data to
  9323. */
  9324. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9325. /**
  9326. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9327. * @param defines The generated defines used in the effect
  9328. * @param effect The effect we are binding the data to
  9329. * @param scene The scene we are willing to render with logarithmic scale for
  9330. */
  9331. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9332. /**
  9333. * Binds the clip plane information from the scene to the effect.
  9334. * @param scene The scene the clip plane information are extracted from
  9335. * @param effect The effect we are binding the data to
  9336. */
  9337. static BindClipPlane(effect: Effect, scene: Scene): void;
  9338. }
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var packingFunctions: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var shadowMapFragmentDeclaration: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var clipPlaneFragmentDeclaration: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var clipPlaneFragment: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var shadowMapFragment: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var shadowMapPixelShader: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var bonesDeclaration: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var morphTargetsVertexGlobalDeclaration: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var morphTargetsVertexDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /** @hidden */
  9405. export var instancesDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. export var helperFunctions: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module BABYLON {
  9418. /** @hidden */
  9419. export var shadowMapVertexDeclaration: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module BABYLON {
  9425. /** @hidden */
  9426. export var clipPlaneVertexDeclaration: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module BABYLON {
  9432. /** @hidden */
  9433. export var morphTargetsVertex: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module BABYLON {
  9439. /** @hidden */
  9440. export var instancesVertex: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module BABYLON {
  9446. /** @hidden */
  9447. export var bonesVertex: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module BABYLON {
  9453. /** @hidden */
  9454. export var shadowMapVertexNormalBias: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module BABYLON {
  9460. /** @hidden */
  9461. export var shadowMapVertexMetric: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module BABYLON {
  9467. /** @hidden */
  9468. export var clipPlaneVertex: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module BABYLON {
  9474. /** @hidden */
  9475. export var shadowMapVertexShader: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module BABYLON {
  9481. /** @hidden */
  9482. export var depthBoxBlurPixelShader: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module BABYLON {
  9488. /**
  9489. * Class representing a ray with position and direction
  9490. */
  9491. export class Ray {
  9492. /** origin point */
  9493. origin: Vector3;
  9494. /** direction */
  9495. direction: Vector3;
  9496. /** length of the ray */
  9497. length: number;
  9498. private static readonly TmpVector3;
  9499. private _tmpRay;
  9500. /**
  9501. * Creates a new ray
  9502. * @param origin origin point
  9503. * @param direction direction
  9504. * @param length length of the ray
  9505. */
  9506. constructor(
  9507. /** origin point */
  9508. origin: Vector3,
  9509. /** direction */
  9510. direction: Vector3,
  9511. /** length of the ray */
  9512. length?: number);
  9513. /**
  9514. * Checks if the ray intersects a box
  9515. * This does not account for the ray lenght by design to improve perfs.
  9516. * @param minimum bound of the box
  9517. * @param maximum bound of the box
  9518. * @param intersectionTreshold extra extend to be added to the box in all direction
  9519. * @returns if the box was hit
  9520. */
  9521. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9522. /**
  9523. * Checks if the ray intersects a box
  9524. * This does not account for the ray lenght by design to improve perfs.
  9525. * @param box the bounding box to check
  9526. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9527. * @returns if the box was hit
  9528. */
  9529. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9530. /**
  9531. * If the ray hits a sphere
  9532. * @param sphere the bounding sphere to check
  9533. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9534. * @returns true if it hits the sphere
  9535. */
  9536. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9537. /**
  9538. * If the ray hits a triange
  9539. * @param vertex0 triangle vertex
  9540. * @param vertex1 triangle vertex
  9541. * @param vertex2 triangle vertex
  9542. * @returns intersection information if hit
  9543. */
  9544. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9545. /**
  9546. * Checks if ray intersects a plane
  9547. * @param plane the plane to check
  9548. * @returns the distance away it was hit
  9549. */
  9550. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9551. /**
  9552. * Calculate the intercept of a ray on a given axis
  9553. * @param axis to check 'x' | 'y' | 'z'
  9554. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9555. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9556. */
  9557. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9558. /**
  9559. * Checks if ray intersects a mesh
  9560. * @param mesh the mesh to check
  9561. * @param fastCheck if only the bounding box should checked
  9562. * @returns picking info of the intersecton
  9563. */
  9564. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9565. /**
  9566. * Checks if ray intersects a mesh
  9567. * @param meshes the meshes to check
  9568. * @param fastCheck if only the bounding box should checked
  9569. * @param results array to store result in
  9570. * @returns Array of picking infos
  9571. */
  9572. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9573. private _comparePickingInfo;
  9574. private static smallnum;
  9575. private static rayl;
  9576. /**
  9577. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9578. * @param sega the first point of the segment to test the intersection against
  9579. * @param segb the second point of the segment to test the intersection against
  9580. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9581. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9582. */
  9583. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9584. /**
  9585. * Update the ray from viewport position
  9586. * @param x position
  9587. * @param y y position
  9588. * @param viewportWidth viewport width
  9589. * @param viewportHeight viewport height
  9590. * @param world world matrix
  9591. * @param view view matrix
  9592. * @param projection projection matrix
  9593. * @returns this ray updated
  9594. */
  9595. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9596. /**
  9597. * Creates a ray with origin and direction of 0,0,0
  9598. * @returns the new ray
  9599. */
  9600. static Zero(): Ray;
  9601. /**
  9602. * Creates a new ray from screen space and viewport
  9603. * @param x position
  9604. * @param y y position
  9605. * @param viewportWidth viewport width
  9606. * @param viewportHeight viewport height
  9607. * @param world world matrix
  9608. * @param view view matrix
  9609. * @param projection projection matrix
  9610. * @returns new ray
  9611. */
  9612. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9613. /**
  9614. * 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
  9615. * transformed to the given world matrix.
  9616. * @param origin The origin point
  9617. * @param end The end point
  9618. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9619. * @returns the new ray
  9620. */
  9621. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9622. /**
  9623. * Transforms a ray by a matrix
  9624. * @param ray ray to transform
  9625. * @param matrix matrix to apply
  9626. * @returns the resulting new ray
  9627. */
  9628. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9629. /**
  9630. * Transforms a ray by a matrix
  9631. * @param ray ray to transform
  9632. * @param matrix matrix to apply
  9633. * @param result ray to store result in
  9634. */
  9635. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9636. /**
  9637. * Unproject a ray from screen space to object space
  9638. * @param sourceX defines the screen space x coordinate to use
  9639. * @param sourceY defines the screen space y coordinate to use
  9640. * @param viewportWidth defines the current width of the viewport
  9641. * @param viewportHeight defines the current height of the viewport
  9642. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9643. * @param view defines the view matrix to use
  9644. * @param projection defines the projection matrix to use
  9645. */
  9646. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9647. }
  9648. /**
  9649. * Type used to define predicate used to select faces when a mesh intersection is detected
  9650. */
  9651. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9652. interface Scene {
  9653. /** @hidden */
  9654. _tempPickingRay: Nullable<Ray>;
  9655. /** @hidden */
  9656. _cachedRayForTransform: Ray;
  9657. /** @hidden */
  9658. _pickWithRayInverseMatrix: Matrix;
  9659. /** @hidden */
  9660. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9661. /** @hidden */
  9662. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9663. }
  9664. }
  9665. declare module BABYLON {
  9666. /**
  9667. * Groups all the scene component constants in one place to ease maintenance.
  9668. * @hidden
  9669. */
  9670. export class SceneComponentConstants {
  9671. static readonly NAME_EFFECTLAYER: string;
  9672. static readonly NAME_LAYER: string;
  9673. static readonly NAME_LENSFLARESYSTEM: string;
  9674. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9675. static readonly NAME_PARTICLESYSTEM: string;
  9676. static readonly NAME_GAMEPAD: string;
  9677. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9678. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9679. static readonly NAME_DEPTHRENDERER: string;
  9680. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9681. static readonly NAME_SPRITE: string;
  9682. static readonly NAME_OUTLINERENDERER: string;
  9683. static readonly NAME_PROCEDURALTEXTURE: string;
  9684. static readonly NAME_SHADOWGENERATOR: string;
  9685. static readonly NAME_OCTREE: string;
  9686. static readonly NAME_PHYSICSENGINE: string;
  9687. static readonly NAME_AUDIO: string;
  9688. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9689. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9690. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9691. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9692. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9693. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9694. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9695. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9696. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9697. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9698. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9699. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9700. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9701. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9702. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9703. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9704. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9705. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9706. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9707. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9708. static readonly STEP_AFTERRENDER_AUDIO: number;
  9709. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9710. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9711. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9712. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9713. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9714. static readonly STEP_POINTERMOVE_SPRITE: number;
  9715. static readonly STEP_POINTERDOWN_SPRITE: number;
  9716. static readonly STEP_POINTERUP_SPRITE: number;
  9717. }
  9718. /**
  9719. * This represents a scene component.
  9720. *
  9721. * This is used to decouple the dependency the scene is having on the different workloads like
  9722. * layers, post processes...
  9723. */
  9724. export interface ISceneComponent {
  9725. /**
  9726. * The name of the component. Each component must have a unique name.
  9727. */
  9728. name: string;
  9729. /**
  9730. * The scene the component belongs to.
  9731. */
  9732. scene: Scene;
  9733. /**
  9734. * Register the component to one instance of a scene.
  9735. */
  9736. register(): void;
  9737. /**
  9738. * Rebuilds the elements related to this component in case of
  9739. * context lost for instance.
  9740. */
  9741. rebuild(): void;
  9742. /**
  9743. * Disposes the component and the associated ressources.
  9744. */
  9745. dispose(): void;
  9746. }
  9747. /**
  9748. * This represents a SERIALIZABLE scene component.
  9749. *
  9750. * This extends Scene Component to add Serialization methods on top.
  9751. */
  9752. export interface ISceneSerializableComponent extends ISceneComponent {
  9753. /**
  9754. * Adds all the elements from the container to the scene
  9755. * @param container the container holding the elements
  9756. */
  9757. addFromContainer(container: AbstractScene): void;
  9758. /**
  9759. * Removes all the elements in the container from the scene
  9760. * @param container contains the elements to remove
  9761. * @param dispose if the removed element should be disposed (default: false)
  9762. */
  9763. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9764. /**
  9765. * Serializes the component data to the specified json object
  9766. * @param serializationObject The object to serialize to
  9767. */
  9768. serialize(serializationObject: any): void;
  9769. }
  9770. /**
  9771. * Strong typing of a Mesh related stage step action
  9772. */
  9773. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9774. /**
  9775. * Strong typing of a Evaluate Sub Mesh related stage step action
  9776. */
  9777. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9778. /**
  9779. * Strong typing of a Active Mesh related stage step action
  9780. */
  9781. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9782. /**
  9783. * Strong typing of a Camera related stage step action
  9784. */
  9785. export type CameraStageAction = (camera: Camera) => void;
  9786. /**
  9787. * Strong typing of a Camera Frame buffer related stage step action
  9788. */
  9789. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9790. /**
  9791. * Strong typing of a Render Target related stage step action
  9792. */
  9793. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9794. /**
  9795. * Strong typing of a RenderingGroup related stage step action
  9796. */
  9797. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9798. /**
  9799. * Strong typing of a Mesh Render related stage step action
  9800. */
  9801. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9802. /**
  9803. * Strong typing of a simple stage step action
  9804. */
  9805. export type SimpleStageAction = () => void;
  9806. /**
  9807. * Strong typing of a render target action.
  9808. */
  9809. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9810. /**
  9811. * Strong typing of a pointer move action.
  9812. */
  9813. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9814. /**
  9815. * Strong typing of a pointer up/down action.
  9816. */
  9817. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9818. /**
  9819. * Representation of a stage in the scene (Basically a list of ordered steps)
  9820. * @hidden
  9821. */
  9822. export class Stage<T extends Function> extends Array<{
  9823. index: number;
  9824. component: ISceneComponent;
  9825. action: T;
  9826. }> {
  9827. /**
  9828. * Hide ctor from the rest of the world.
  9829. * @param items The items to add.
  9830. */
  9831. private constructor();
  9832. /**
  9833. * Creates a new Stage.
  9834. * @returns A new instance of a Stage
  9835. */
  9836. static Create<T extends Function>(): Stage<T>;
  9837. /**
  9838. * Registers a step in an ordered way in the targeted stage.
  9839. * @param index Defines the position to register the step in
  9840. * @param component Defines the component attached to the step
  9841. * @param action Defines the action to launch during the step
  9842. */
  9843. registerStep(index: number, component: ISceneComponent, action: T): void;
  9844. /**
  9845. * Clears all the steps from the stage.
  9846. */
  9847. clear(): void;
  9848. }
  9849. }
  9850. declare module BABYLON {
  9851. interface Scene {
  9852. /** @hidden */
  9853. _pointerOverSprite: Nullable<Sprite>;
  9854. /** @hidden */
  9855. _pickedDownSprite: Nullable<Sprite>;
  9856. /** @hidden */
  9857. _tempSpritePickingRay: Nullable<Ray>;
  9858. /**
  9859. * All of the sprite managers added to this scene
  9860. * @see http://doc.babylonjs.com/babylon101/sprites
  9861. */
  9862. spriteManagers: Array<ISpriteManager>;
  9863. /**
  9864. * An event triggered when sprites rendering is about to start
  9865. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9866. */
  9867. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9868. /**
  9869. * An event triggered when sprites rendering is done
  9870. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9871. */
  9872. onAfterSpritesRenderingObservable: Observable<Scene>;
  9873. /** @hidden */
  9874. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9875. /** Launch a ray to try to pick a sprite in the scene
  9876. * @param x position on screen
  9877. * @param y position on screen
  9878. * @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
  9879. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9880. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9881. * @returns a PickingInfo
  9882. */
  9883. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9884. /** Use the given ray to pick a sprite in the scene
  9885. * @param ray The ray (in world space) to use to pick meshes
  9886. * @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
  9887. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9888. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9889. * @returns a PickingInfo
  9890. */
  9891. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9892. /** @hidden */
  9893. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9894. /** Launch a ray to try to pick sprites in the scene
  9895. * @param x position on screen
  9896. * @param y position on screen
  9897. * @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
  9898. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9899. * @returns a PickingInfo array
  9900. */
  9901. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9902. /** Use the given ray to pick sprites in the scene
  9903. * @param ray The ray (in world space) to use to pick meshes
  9904. * @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
  9905. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9906. * @returns a PickingInfo array
  9907. */
  9908. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9909. /**
  9910. * Force the sprite under the pointer
  9911. * @param sprite defines the sprite to use
  9912. */
  9913. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9914. /**
  9915. * Gets the sprite under the pointer
  9916. * @returns a Sprite or null if no sprite is under the pointer
  9917. */
  9918. getPointerOverSprite(): Nullable<Sprite>;
  9919. }
  9920. /**
  9921. * Defines the sprite scene component responsible to manage sprites
  9922. * in a given scene.
  9923. */
  9924. export class SpriteSceneComponent implements ISceneComponent {
  9925. /**
  9926. * The component name helpfull to identify the component in the list of scene components.
  9927. */
  9928. readonly name: string;
  9929. /**
  9930. * The scene the component belongs to.
  9931. */
  9932. scene: Scene;
  9933. /** @hidden */
  9934. private _spritePredicate;
  9935. /**
  9936. * Creates a new instance of the component for the given scene
  9937. * @param scene Defines the scene to register the component in
  9938. */
  9939. constructor(scene: Scene);
  9940. /**
  9941. * Registers the component in a given scene
  9942. */
  9943. register(): void;
  9944. /**
  9945. * Rebuilds the elements related to this component in case of
  9946. * context lost for instance.
  9947. */
  9948. rebuild(): void;
  9949. /**
  9950. * Disposes the component and the associated ressources.
  9951. */
  9952. dispose(): void;
  9953. private _pickSpriteButKeepRay;
  9954. private _pointerMove;
  9955. private _pointerDown;
  9956. private _pointerUp;
  9957. }
  9958. }
  9959. declare module BABYLON {
  9960. /** @hidden */
  9961. export var fogFragmentDeclaration: {
  9962. name: string;
  9963. shader: string;
  9964. };
  9965. }
  9966. declare module BABYLON {
  9967. /** @hidden */
  9968. export var fogFragment: {
  9969. name: string;
  9970. shader: string;
  9971. };
  9972. }
  9973. declare module BABYLON {
  9974. /** @hidden */
  9975. export var spritesPixelShader: {
  9976. name: string;
  9977. shader: string;
  9978. };
  9979. }
  9980. declare module BABYLON {
  9981. /** @hidden */
  9982. export var fogVertexDeclaration: {
  9983. name: string;
  9984. shader: string;
  9985. };
  9986. }
  9987. declare module BABYLON {
  9988. /** @hidden */
  9989. export var spritesVertexShader: {
  9990. name: string;
  9991. shader: string;
  9992. };
  9993. }
  9994. declare module BABYLON {
  9995. /**
  9996. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9997. */
  9998. export interface ISpriteManager extends IDisposable {
  9999. /**
  10000. * Restricts the camera to viewing objects with the same layerMask.
  10001. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10002. */
  10003. layerMask: number;
  10004. /**
  10005. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10006. */
  10007. isPickable: boolean;
  10008. /**
  10009. * Specifies the rendering group id for this mesh (0 by default)
  10010. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10011. */
  10012. renderingGroupId: number;
  10013. /**
  10014. * Defines the list of sprites managed by the manager.
  10015. */
  10016. sprites: Array<Sprite>;
  10017. /**
  10018. * Tests the intersection of a sprite with a specific ray.
  10019. * @param ray The ray we are sending to test the collision
  10020. * @param camera The camera space we are sending rays in
  10021. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10022. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10023. * @returns picking info or null.
  10024. */
  10025. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10026. /**
  10027. * Intersects the sprites with a ray
  10028. * @param ray defines the ray to intersect with
  10029. * @param camera defines the current active camera
  10030. * @param predicate defines a predicate used to select candidate sprites
  10031. * @returns null if no hit or a PickingInfo array
  10032. */
  10033. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10034. /**
  10035. * Renders the list of sprites on screen.
  10036. */
  10037. render(): void;
  10038. }
  10039. /**
  10040. * Class used to manage multiple sprites on the same spritesheet
  10041. * @see http://doc.babylonjs.com/babylon101/sprites
  10042. */
  10043. export class SpriteManager implements ISpriteManager {
  10044. /** defines the manager's name */
  10045. name: string;
  10046. /** Gets the list of sprites */
  10047. sprites: Sprite[];
  10048. /** Gets or sets the rendering group id (0 by default) */
  10049. renderingGroupId: number;
  10050. /** Gets or sets camera layer mask */
  10051. layerMask: number;
  10052. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10053. fogEnabled: boolean;
  10054. /** Gets or sets a boolean indicating if the sprites are pickable */
  10055. isPickable: boolean;
  10056. /** Defines the default width of a cell in the spritesheet */
  10057. cellWidth: number;
  10058. /** Defines the default height of a cell in the spritesheet */
  10059. cellHeight: number;
  10060. /** Associative array from JSON sprite data file */
  10061. private _cellData;
  10062. /** Array of sprite names from JSON sprite data file */
  10063. private _spriteMap;
  10064. /** True when packed cell data from JSON file is ready*/
  10065. private _packedAndReady;
  10066. private _textureContent;
  10067. /**
  10068. * An event triggered when the manager is disposed.
  10069. */
  10070. onDisposeObservable: Observable<SpriteManager>;
  10071. private _onDisposeObserver;
  10072. /**
  10073. * Callback called when the manager is disposed
  10074. */
  10075. set onDispose(callback: () => void);
  10076. private _capacity;
  10077. private _fromPacked;
  10078. private _spriteTexture;
  10079. private _epsilon;
  10080. private _scene;
  10081. private _vertexData;
  10082. private _buffer;
  10083. private _vertexBuffers;
  10084. private _indexBuffer;
  10085. private _effectBase;
  10086. private _effectFog;
  10087. /**
  10088. * Gets or sets the spritesheet texture
  10089. */
  10090. get texture(): Texture;
  10091. set texture(value: Texture);
  10092. private _blendMode;
  10093. /**
  10094. * Blend mode use to render the particle, it can be any of
  10095. * the static Constants.ALPHA_x properties provided in this class.
  10096. * Default value is Constants.ALPHA_COMBINE
  10097. */
  10098. get blendMode(): number;
  10099. set blendMode(blendMode: number);
  10100. /** Disables writing to the depth buffer when rendering the sprites.
  10101. * It can be handy to disable depth writing when using textures without alpha channel
  10102. * and setting some specific blend modes.
  10103. */
  10104. disableDepthWrite: boolean;
  10105. /**
  10106. * Creates a new sprite manager
  10107. * @param name defines the manager's name
  10108. * @param imgUrl defines the sprite sheet url
  10109. * @param capacity defines the maximum allowed number of sprites
  10110. * @param cellSize defines the size of a sprite cell
  10111. * @param scene defines the hosting scene
  10112. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10113. * @param samplingMode defines the smapling mode to use with spritesheet
  10114. * @param fromPacked set to false; do not alter
  10115. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10116. */
  10117. constructor(
  10118. /** defines the manager's name */
  10119. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10120. private _makePacked;
  10121. private _appendSpriteVertex;
  10122. private _checkTextureAlpha;
  10123. /**
  10124. * Intersects the sprites with a ray
  10125. * @param ray defines the ray to intersect with
  10126. * @param camera defines the current active camera
  10127. * @param predicate defines a predicate used to select candidate sprites
  10128. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10129. * @returns null if no hit or a PickingInfo
  10130. */
  10131. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10132. /**
  10133. * Intersects the sprites with a ray
  10134. * @param ray defines the ray to intersect with
  10135. * @param camera defines the current active camera
  10136. * @param predicate defines a predicate used to select candidate sprites
  10137. * @returns null if no hit or a PickingInfo array
  10138. */
  10139. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10140. /**
  10141. * Render all child sprites
  10142. */
  10143. render(): void;
  10144. /**
  10145. * Release associated resources
  10146. */
  10147. dispose(): void;
  10148. }
  10149. }
  10150. declare module BABYLON {
  10151. /** Interface used by value gradients (color, factor, ...) */
  10152. export interface IValueGradient {
  10153. /**
  10154. * Gets or sets the gradient value (between 0 and 1)
  10155. */
  10156. gradient: number;
  10157. }
  10158. /** Class used to store color4 gradient */
  10159. export class ColorGradient implements IValueGradient {
  10160. /**
  10161. * Gets or sets the gradient value (between 0 and 1)
  10162. */
  10163. gradient: number;
  10164. /**
  10165. * Gets or sets first associated color
  10166. */
  10167. color1: Color4;
  10168. /**
  10169. * Gets or sets second associated color
  10170. */
  10171. color2?: Color4 | undefined;
  10172. /**
  10173. * Creates a new color4 gradient
  10174. * @param gradient gets or sets the gradient value (between 0 and 1)
  10175. * @param color1 gets or sets first associated color
  10176. * @param color2 gets or sets first second color
  10177. */
  10178. constructor(
  10179. /**
  10180. * Gets or sets the gradient value (between 0 and 1)
  10181. */
  10182. gradient: number,
  10183. /**
  10184. * Gets or sets first associated color
  10185. */
  10186. color1: Color4,
  10187. /**
  10188. * Gets or sets second associated color
  10189. */
  10190. color2?: Color4 | undefined);
  10191. /**
  10192. * Will get a color picked randomly between color1 and color2.
  10193. * If color2 is undefined then color1 will be used
  10194. * @param result defines the target Color4 to store the result in
  10195. */
  10196. getColorToRef(result: Color4): void;
  10197. }
  10198. /** Class used to store color 3 gradient */
  10199. export class Color3Gradient implements IValueGradient {
  10200. /**
  10201. * Gets or sets the gradient value (between 0 and 1)
  10202. */
  10203. gradient: number;
  10204. /**
  10205. * Gets or sets the associated color
  10206. */
  10207. color: Color3;
  10208. /**
  10209. * Creates a new color3 gradient
  10210. * @param gradient gets or sets the gradient value (between 0 and 1)
  10211. * @param color gets or sets associated color
  10212. */
  10213. constructor(
  10214. /**
  10215. * Gets or sets the gradient value (between 0 and 1)
  10216. */
  10217. gradient: number,
  10218. /**
  10219. * Gets or sets the associated color
  10220. */
  10221. color: Color3);
  10222. }
  10223. /** Class used to store factor gradient */
  10224. export class FactorGradient implements IValueGradient {
  10225. /**
  10226. * Gets or sets the gradient value (between 0 and 1)
  10227. */
  10228. gradient: number;
  10229. /**
  10230. * Gets or sets first associated factor
  10231. */
  10232. factor1: number;
  10233. /**
  10234. * Gets or sets second associated factor
  10235. */
  10236. factor2?: number | undefined;
  10237. /**
  10238. * Creates a new factor gradient
  10239. * @param gradient gets or sets the gradient value (between 0 and 1)
  10240. * @param factor1 gets or sets first associated factor
  10241. * @param factor2 gets or sets second associated factor
  10242. */
  10243. constructor(
  10244. /**
  10245. * Gets or sets the gradient value (between 0 and 1)
  10246. */
  10247. gradient: number,
  10248. /**
  10249. * Gets or sets first associated factor
  10250. */
  10251. factor1: number,
  10252. /**
  10253. * Gets or sets second associated factor
  10254. */
  10255. factor2?: number | undefined);
  10256. /**
  10257. * Will get a number picked randomly between factor1 and factor2.
  10258. * If factor2 is undefined then factor1 will be used
  10259. * @returns the picked number
  10260. */
  10261. getFactor(): number;
  10262. }
  10263. /**
  10264. * Helper used to simplify some generic gradient tasks
  10265. */
  10266. export class GradientHelper {
  10267. /**
  10268. * Gets the current gradient from an array of IValueGradient
  10269. * @param ratio defines the current ratio to get
  10270. * @param gradients defines the array of IValueGradient
  10271. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10272. */
  10273. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Interface for the size containing width and height
  10279. */
  10280. export interface ISize {
  10281. /**
  10282. * Width
  10283. */
  10284. width: number;
  10285. /**
  10286. * Heighht
  10287. */
  10288. height: number;
  10289. }
  10290. /**
  10291. * Size containing widht and height
  10292. */
  10293. export class Size implements ISize {
  10294. /**
  10295. * Width
  10296. */
  10297. width: number;
  10298. /**
  10299. * Height
  10300. */
  10301. height: number;
  10302. /**
  10303. * Creates a Size object from the given width and height (floats).
  10304. * @param width width of the new size
  10305. * @param height height of the new size
  10306. */
  10307. constructor(width: number, height: number);
  10308. /**
  10309. * Returns a string with the Size width and height
  10310. * @returns a string with the Size width and height
  10311. */
  10312. toString(): string;
  10313. /**
  10314. * "Size"
  10315. * @returns the string "Size"
  10316. */
  10317. getClassName(): string;
  10318. /**
  10319. * Returns the Size hash code.
  10320. * @returns a hash code for a unique width and height
  10321. */
  10322. getHashCode(): number;
  10323. /**
  10324. * Updates the current size from the given one.
  10325. * @param src the given size
  10326. */
  10327. copyFrom(src: Size): void;
  10328. /**
  10329. * Updates in place the current Size from the given floats.
  10330. * @param width width of the new size
  10331. * @param height height of the new size
  10332. * @returns the updated Size.
  10333. */
  10334. copyFromFloats(width: number, height: number): Size;
  10335. /**
  10336. * Updates in place the current Size from the given floats.
  10337. * @param width width to set
  10338. * @param height height to set
  10339. * @returns the updated Size.
  10340. */
  10341. set(width: number, height: number): Size;
  10342. /**
  10343. * Multiplies the width and height by numbers
  10344. * @param w factor to multiple the width by
  10345. * @param h factor to multiple the height by
  10346. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10347. */
  10348. multiplyByFloats(w: number, h: number): Size;
  10349. /**
  10350. * Clones the size
  10351. * @returns a new Size copied from the given one.
  10352. */
  10353. clone(): Size;
  10354. /**
  10355. * True if the current Size and the given one width and height are strictly equal.
  10356. * @param other the other size to compare against
  10357. * @returns True if the current Size and the given one width and height are strictly equal.
  10358. */
  10359. equals(other: Size): boolean;
  10360. /**
  10361. * The surface of the Size : width * height (float).
  10362. */
  10363. get surface(): number;
  10364. /**
  10365. * Create a new size of zero
  10366. * @returns a new Size set to (0.0, 0.0)
  10367. */
  10368. static Zero(): Size;
  10369. /**
  10370. * Sums the width and height of two sizes
  10371. * @param otherSize size to add to this size
  10372. * @returns a new Size set as the addition result of the current Size and the given one.
  10373. */
  10374. add(otherSize: Size): Size;
  10375. /**
  10376. * Subtracts the width and height of two
  10377. * @param otherSize size to subtract to this size
  10378. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10379. */
  10380. subtract(otherSize: Size): Size;
  10381. /**
  10382. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10383. * @param start starting size to lerp between
  10384. * @param end end size to lerp between
  10385. * @param amount amount to lerp between the start and end values
  10386. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10387. */
  10388. static Lerp(start: Size, end: Size, amount: number): Size;
  10389. }
  10390. }
  10391. declare module BABYLON {
  10392. interface ThinEngine {
  10393. /**
  10394. * Creates a dynamic texture
  10395. * @param width defines the width of the texture
  10396. * @param height defines the height of the texture
  10397. * @param generateMipMaps defines if the engine should generate the mip levels
  10398. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10399. * @returns the dynamic texture inside an InternalTexture
  10400. */
  10401. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10402. /**
  10403. * Update the content of a dynamic texture
  10404. * @param texture defines the texture to update
  10405. * @param canvas defines the canvas containing the source
  10406. * @param invertY defines if data must be stored with Y axis inverted
  10407. * @param premulAlpha defines if alpha is stored as premultiplied
  10408. * @param format defines the format of the data
  10409. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10410. */
  10411. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10412. }
  10413. }
  10414. declare module BABYLON {
  10415. /**
  10416. * Helper class used to generate a canvas to manipulate images
  10417. */
  10418. export class CanvasGenerator {
  10419. /**
  10420. * Create a new canvas (or offscreen canvas depending on the context)
  10421. * @param width defines the expected width
  10422. * @param height defines the expected height
  10423. * @return a new canvas or offscreen canvas
  10424. */
  10425. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10426. }
  10427. }
  10428. declare module BABYLON {
  10429. /**
  10430. * A class extending Texture allowing drawing on a texture
  10431. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10432. */
  10433. export class DynamicTexture extends Texture {
  10434. private _generateMipMaps;
  10435. private _canvas;
  10436. private _context;
  10437. private _engine;
  10438. /**
  10439. * Creates a DynamicTexture
  10440. * @param name defines the name of the texture
  10441. * @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
  10442. * @param scene defines the scene where you want the texture
  10443. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10444. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10445. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10446. */
  10447. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10448. /**
  10449. * Get the current class name of the texture useful for serialization or dynamic coding.
  10450. * @returns "DynamicTexture"
  10451. */
  10452. getClassName(): string;
  10453. /**
  10454. * Gets the current state of canRescale
  10455. */
  10456. get canRescale(): boolean;
  10457. private _recreate;
  10458. /**
  10459. * Scales the texture
  10460. * @param ratio the scale factor to apply to both width and height
  10461. */
  10462. scale(ratio: number): void;
  10463. /**
  10464. * Resizes the texture
  10465. * @param width the new width
  10466. * @param height the new height
  10467. */
  10468. scaleTo(width: number, height: number): void;
  10469. /**
  10470. * Gets the context of the canvas used by the texture
  10471. * @returns the canvas context of the dynamic texture
  10472. */
  10473. getContext(): CanvasRenderingContext2D;
  10474. /**
  10475. * Clears the texture
  10476. */
  10477. clear(): void;
  10478. /**
  10479. * Updates the texture
  10480. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10481. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10482. */
  10483. update(invertY?: boolean, premulAlpha?: boolean): void;
  10484. /**
  10485. * Draws text onto the texture
  10486. * @param text defines the text to be drawn
  10487. * @param x defines the placement of the text from the left
  10488. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10489. * @param font defines the font to be used with font-style, font-size, font-name
  10490. * @param color defines the color used for the text
  10491. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10492. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10493. * @param update defines whether texture is immediately update (default is true)
  10494. */
  10495. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10496. /**
  10497. * Clones the texture
  10498. * @returns the clone of the texture.
  10499. */
  10500. clone(): DynamicTexture;
  10501. /**
  10502. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10503. * @returns a serialized dynamic texture object
  10504. */
  10505. serialize(): any;
  10506. /** @hidden */
  10507. _rebuild(): void;
  10508. }
  10509. }
  10510. declare module BABYLON {
  10511. interface ThinEngine {
  10512. /**
  10513. * Creates a raw texture
  10514. * @param data defines the data to store in the texture
  10515. * @param width defines the width of the texture
  10516. * @param height defines the height of the texture
  10517. * @param format defines the format of the data
  10518. * @param generateMipMaps defines if the engine should generate the mip levels
  10519. * @param invertY defines if data must be stored with Y axis inverted
  10520. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10521. * @param compression defines the compression used (null by default)
  10522. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10523. * @returns the raw texture inside an InternalTexture
  10524. */
  10525. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10526. /**
  10527. * Update a raw texture
  10528. * @param texture defines the texture to update
  10529. * @param data defines the data to store in the texture
  10530. * @param format defines the format of the data
  10531. * @param invertY defines if data must be stored with Y axis inverted
  10532. */
  10533. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10534. /**
  10535. * Update a raw texture
  10536. * @param texture defines the texture to update
  10537. * @param data defines the data to store in the texture
  10538. * @param format defines the format of the data
  10539. * @param invertY defines if data must be stored with Y axis inverted
  10540. * @param compression defines the compression used (null by default)
  10541. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10542. */
  10543. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10544. /**
  10545. * Creates a new raw cube texture
  10546. * @param data defines the array of data to use to create each face
  10547. * @param size defines the size of the textures
  10548. * @param format defines the format of the data
  10549. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10550. * @param generateMipMaps defines if the engine should generate the mip levels
  10551. * @param invertY defines if data must be stored with Y axis inverted
  10552. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10553. * @param compression defines the compression used (null by default)
  10554. * @returns the cube texture as an InternalTexture
  10555. */
  10556. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10557. /**
  10558. * Update a raw cube texture
  10559. * @param texture defines the texture to udpdate
  10560. * @param data defines the data to store
  10561. * @param format defines the data format
  10562. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10563. * @param invertY defines if data must be stored with Y axis inverted
  10564. */
  10565. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10566. /**
  10567. * Update a raw cube texture
  10568. * @param texture defines the texture to udpdate
  10569. * @param data defines the data to store
  10570. * @param format defines the data format
  10571. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10572. * @param invertY defines if data must be stored with Y axis inverted
  10573. * @param compression defines the compression used (null by default)
  10574. */
  10575. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10576. /**
  10577. * Update a raw cube texture
  10578. * @param texture defines the texture to udpdate
  10579. * @param data defines the data to store
  10580. * @param format defines the data format
  10581. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10582. * @param invertY defines if data must be stored with Y axis inverted
  10583. * @param compression defines the compression used (null by default)
  10584. * @param level defines which level of the texture to update
  10585. */
  10586. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10587. /**
  10588. * Creates a new raw cube texture from a specified url
  10589. * @param url defines the url where the data is located
  10590. * @param scene defines the current scene
  10591. * @param size defines the size of the textures
  10592. * @param format defines the format of the data
  10593. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10594. * @param noMipmap defines if the engine should avoid generating the mip levels
  10595. * @param callback defines a callback used to extract texture data from loaded data
  10596. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10597. * @param onLoad defines a callback called when texture is loaded
  10598. * @param onError defines a callback called if there is an error
  10599. * @returns the cube texture as an InternalTexture
  10600. */
  10601. 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;
  10602. /**
  10603. * Creates a new raw cube texture from a specified url
  10604. * @param url defines the url where the data is located
  10605. * @param scene defines the current scene
  10606. * @param size defines the size of the textures
  10607. * @param format defines the format of the data
  10608. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10609. * @param noMipmap defines if the engine should avoid generating the mip levels
  10610. * @param callback defines a callback used to extract texture data from loaded data
  10611. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10612. * @param onLoad defines a callback called when texture is loaded
  10613. * @param onError defines a callback called if there is an error
  10614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10615. * @param invertY defines if data must be stored with Y axis inverted
  10616. * @returns the cube texture as an InternalTexture
  10617. */
  10618. 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;
  10619. /**
  10620. * Creates a new raw 3D texture
  10621. * @param data defines the data used to create the texture
  10622. * @param width defines the width of the texture
  10623. * @param height defines the height of the texture
  10624. * @param depth defines the depth of the texture
  10625. * @param format defines the format of the texture
  10626. * @param generateMipMaps defines if the engine must generate mip levels
  10627. * @param invertY defines if data must be stored with Y axis inverted
  10628. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10629. * @param compression defines the compressed used (can be null)
  10630. * @param textureType defines the compressed used (can be null)
  10631. * @returns a new raw 3D texture (stored in an InternalTexture)
  10632. */
  10633. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10634. /**
  10635. * Update a raw 3D texture
  10636. * @param texture defines the texture to update
  10637. * @param data defines the data to store
  10638. * @param format defines the data format
  10639. * @param invertY defines if data must be stored with Y axis inverted
  10640. */
  10641. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10642. /**
  10643. * Update a raw 3D texture
  10644. * @param texture defines the texture to update
  10645. * @param data defines the data to store
  10646. * @param format defines the data format
  10647. * @param invertY defines if data must be stored with Y axis inverted
  10648. * @param compression defines the used compression (can be null)
  10649. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10650. */
  10651. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10652. /**
  10653. * Creates a new raw 2D array texture
  10654. * @param data defines the data used to create the texture
  10655. * @param width defines the width of the texture
  10656. * @param height defines the height of the texture
  10657. * @param depth defines the number of layers of the texture
  10658. * @param format defines the format of the texture
  10659. * @param generateMipMaps defines if the engine must generate mip levels
  10660. * @param invertY defines if data must be stored with Y axis inverted
  10661. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10662. * @param compression defines the compressed used (can be null)
  10663. * @param textureType defines the compressed used (can be null)
  10664. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10665. */
  10666. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10667. /**
  10668. * Update a raw 2D array texture
  10669. * @param texture defines the texture to update
  10670. * @param data defines the data to store
  10671. * @param format defines the data format
  10672. * @param invertY defines if data must be stored with Y axis inverted
  10673. */
  10674. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10675. /**
  10676. * Update a raw 2D array texture
  10677. * @param texture defines the texture to update
  10678. * @param data defines the data to store
  10679. * @param format defines the data format
  10680. * @param invertY defines if data must be stored with Y axis inverted
  10681. * @param compression defines the used compression (can be null)
  10682. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10683. */
  10684. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10685. }
  10686. }
  10687. declare module BABYLON {
  10688. /**
  10689. * Raw texture can help creating a texture directly from an array of data.
  10690. * This can be super useful if you either get the data from an uncompressed source or
  10691. * if you wish to create your texture pixel by pixel.
  10692. */
  10693. export class RawTexture extends Texture {
  10694. /**
  10695. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10696. */
  10697. format: number;
  10698. private _engine;
  10699. /**
  10700. * Instantiates a new RawTexture.
  10701. * Raw texture can help creating a texture directly from an array of data.
  10702. * This can be super useful if you either get the data from an uncompressed source or
  10703. * if you wish to create your texture pixel by pixel.
  10704. * @param data define the array of data to use to create the texture
  10705. * @param width define the width of the texture
  10706. * @param height define the height of the texture
  10707. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10708. * @param scene define the scene the texture belongs to
  10709. * @param generateMipMaps define whether mip maps should be generated or not
  10710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10713. */
  10714. constructor(data: ArrayBufferView, width: number, height: number,
  10715. /**
  10716. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10717. */
  10718. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10719. /**
  10720. * Updates the texture underlying data.
  10721. * @param data Define the new data of the texture
  10722. */
  10723. update(data: ArrayBufferView): void;
  10724. /**
  10725. * Creates a luminance texture from some data.
  10726. * @param data Define the texture data
  10727. * @param width Define the width of the texture
  10728. * @param height Define the height of the texture
  10729. * @param scene Define the scene the texture belongs to
  10730. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10733. * @returns the luminance texture
  10734. */
  10735. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10736. /**
  10737. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  10746. */
  10747. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10748. /**
  10749. * Creates an alpha texture from some data.
  10750. * @param data Define the texture data
  10751. * @param width Define the width of the texture
  10752. * @param height Define the height of the texture
  10753. * @param scene Define the scene the texture belongs to
  10754. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10755. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10756. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10757. * @returns the alpha texture
  10758. */
  10759. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10760. /**
  10761. * Creates a RGB texture from some data.
  10762. * @param data Define the texture data
  10763. * @param width Define the width of the texture
  10764. * @param height Define the height of the texture
  10765. * @param scene Define the scene the texture belongs to
  10766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10769. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10770. * @returns the RGB alpha texture
  10771. */
  10772. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10773. /**
  10774. * Creates a RGBA texture from some data.
  10775. * @param data Define the texture data
  10776. * @param width Define the width of the texture
  10777. * @param height Define the height of the texture
  10778. * @param scene Define the scene the texture belongs to
  10779. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10780. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10781. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10782. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10783. * @returns the RGBA texture
  10784. */
  10785. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10786. /**
  10787. * Creates a R texture from some data.
  10788. * @param data Define the texture data
  10789. * @param width Define the width of the texture
  10790. * @param height Define the height of the texture
  10791. * @param scene Define the scene the texture belongs to
  10792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10795. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10796. * @returns the R texture
  10797. */
  10798. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10799. }
  10800. }
  10801. declare module BABYLON {
  10802. interface AbstractScene {
  10803. /**
  10804. * The list of procedural textures added to the scene
  10805. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10806. */
  10807. proceduralTextures: Array<ProceduralTexture>;
  10808. }
  10809. /**
  10810. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10811. * in a given scene.
  10812. */
  10813. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10814. /**
  10815. * The component name helpfull to identify the component in the list of scene components.
  10816. */
  10817. readonly name: string;
  10818. /**
  10819. * The scene the component belongs to.
  10820. */
  10821. scene: Scene;
  10822. /**
  10823. * Creates a new instance of the component for the given scene
  10824. * @param scene Defines the scene to register the component in
  10825. */
  10826. constructor(scene: Scene);
  10827. /**
  10828. * Registers the component in a given scene
  10829. */
  10830. register(): void;
  10831. /**
  10832. * Rebuilds the elements related to this component in case of
  10833. * context lost for instance.
  10834. */
  10835. rebuild(): void;
  10836. /**
  10837. * Disposes the component and the associated ressources.
  10838. */
  10839. dispose(): void;
  10840. private _beforeClear;
  10841. }
  10842. }
  10843. declare module BABYLON {
  10844. interface ThinEngine {
  10845. /**
  10846. * Creates a new render target cube texture
  10847. * @param size defines the size of the texture
  10848. * @param options defines the options used to create the texture
  10849. * @returns a new render target cube texture stored in an InternalTexture
  10850. */
  10851. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10852. }
  10853. }
  10854. declare module BABYLON {
  10855. /** @hidden */
  10856. export var proceduralVertexShader: {
  10857. name: string;
  10858. shader: string;
  10859. };
  10860. }
  10861. declare module BABYLON {
  10862. /**
  10863. * 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.
  10864. * This is the base class of any Procedural texture and contains most of the shareable code.
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10866. */
  10867. export class ProceduralTexture extends Texture {
  10868. isCube: boolean;
  10869. /**
  10870. * Define if the texture is enabled or not (disabled texture will not render)
  10871. */
  10872. isEnabled: boolean;
  10873. /**
  10874. * Define if the texture must be cleared before rendering (default is true)
  10875. */
  10876. autoClear: boolean;
  10877. /**
  10878. * Callback called when the texture is generated
  10879. */
  10880. onGenerated: () => void;
  10881. /**
  10882. * Event raised when the texture is generated
  10883. */
  10884. onGeneratedObservable: Observable<ProceduralTexture>;
  10885. /** @hidden */
  10886. _generateMipMaps: boolean;
  10887. /** @hidden **/
  10888. _effect: Effect;
  10889. /** @hidden */
  10890. _textures: {
  10891. [key: string]: Texture;
  10892. };
  10893. /** @hidden */
  10894. protected _fallbackTexture: Nullable<Texture>;
  10895. private _size;
  10896. private _currentRefreshId;
  10897. private _frameId;
  10898. private _refreshRate;
  10899. private _vertexBuffers;
  10900. private _indexBuffer;
  10901. private _uniforms;
  10902. private _samplers;
  10903. private _fragment;
  10904. private _floats;
  10905. private _ints;
  10906. private _floatsArrays;
  10907. private _colors3;
  10908. private _colors4;
  10909. private _vectors2;
  10910. private _vectors3;
  10911. private _matrices;
  10912. private _fallbackTextureUsed;
  10913. private _engine;
  10914. private _cachedDefines;
  10915. private _contentUpdateId;
  10916. private _contentData;
  10917. /**
  10918. * Instantiates a new procedural texture.
  10919. * 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.
  10920. * This is the base class of any Procedural texture and contains most of the shareable code.
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10922. * @param name Define the name of the texture
  10923. * @param size Define the size of the texture to create
  10924. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10925. * @param scene Define the scene the texture belongs to
  10926. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10927. * @param generateMipMaps Define if the texture should creates mip maps or not
  10928. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10929. */
  10930. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10931. /**
  10932. * The effect that is created when initializing the post process.
  10933. * @returns The created effect corresponding the the postprocess.
  10934. */
  10935. getEffect(): Effect;
  10936. /**
  10937. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10938. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10939. */
  10940. getContent(): Nullable<ArrayBufferView>;
  10941. private _createIndexBuffer;
  10942. /** @hidden */
  10943. _rebuild(): void;
  10944. /**
  10945. * Resets the texture in order to recreate its associated resources.
  10946. * This can be called in case of context loss
  10947. */
  10948. reset(): void;
  10949. protected _getDefines(): string;
  10950. /**
  10951. * Is the texture ready to be used ? (rendered at least once)
  10952. * @returns true if ready, otherwise, false.
  10953. */
  10954. isReady(): boolean;
  10955. /**
  10956. * Resets the refresh counter of the texture and start bak from scratch.
  10957. * Could be useful to regenerate the texture if it is setup to render only once.
  10958. */
  10959. resetRefreshCounter(): void;
  10960. /**
  10961. * Set the fragment shader to use in order to render the texture.
  10962. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10963. */
  10964. setFragment(fragment: any): void;
  10965. /**
  10966. * Define the refresh rate of the texture or the rendering frequency.
  10967. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10968. */
  10969. get refreshRate(): number;
  10970. set refreshRate(value: number);
  10971. /** @hidden */
  10972. _shouldRender(): boolean;
  10973. /**
  10974. * Get the size the texture is rendering at.
  10975. * @returns the size (texture is always squared)
  10976. */
  10977. getRenderSize(): number;
  10978. /**
  10979. * Resize the texture to new value.
  10980. * @param size Define the new size the texture should have
  10981. * @param generateMipMaps Define whether the new texture should create mip maps
  10982. */
  10983. resize(size: number, generateMipMaps: boolean): void;
  10984. private _checkUniform;
  10985. /**
  10986. * Set a texture in the shader program used to render.
  10987. * @param name Define the name of the uniform samplers as defined in the shader
  10988. * @param texture Define the texture to bind to this sampler
  10989. * @return the texture itself allowing "fluent" like uniform updates
  10990. */
  10991. setTexture(name: string, texture: Texture): ProceduralTexture;
  10992. /**
  10993. * Set a float in the shader.
  10994. * @param name Define the name of the uniform as defined in the shader
  10995. * @param value Define the value to give to the uniform
  10996. * @return the texture itself allowing "fluent" like uniform updates
  10997. */
  10998. setFloat(name: string, value: number): ProceduralTexture;
  10999. /**
  11000. * Set a int in the shader.
  11001. * @param name Define the name of the uniform as defined in the shader
  11002. * @param value Define the value to give to the uniform
  11003. * @return the texture itself allowing "fluent" like uniform updates
  11004. */
  11005. setInt(name: string, value: number): ProceduralTexture;
  11006. /**
  11007. * Set an array of floats in the shader.
  11008. * @param name Define the name of the uniform as defined in the shader
  11009. * @param value Define the value to give to the uniform
  11010. * @return the texture itself allowing "fluent" like uniform updates
  11011. */
  11012. setFloats(name: string, value: number[]): ProceduralTexture;
  11013. /**
  11014. * Set a vec3 in the shader from a Color3.
  11015. * @param name Define the name of the uniform as defined in the shader
  11016. * @param value Define the value to give to the uniform
  11017. * @return the texture itself allowing "fluent" like uniform updates
  11018. */
  11019. setColor3(name: string, value: Color3): ProceduralTexture;
  11020. /**
  11021. * Set a vec4 in the shader from a Color4.
  11022. * @param name Define the name of the uniform as defined in the shader
  11023. * @param value Define the value to give to the uniform
  11024. * @return the texture itself allowing "fluent" like uniform updates
  11025. */
  11026. setColor4(name: string, value: Color4): ProceduralTexture;
  11027. /**
  11028. * Set a vec2 in the shader from a Vector2.
  11029. * @param name Define the name of the uniform as defined in the shader
  11030. * @param value Define the value to give to the uniform
  11031. * @return the texture itself allowing "fluent" like uniform updates
  11032. */
  11033. setVector2(name: string, value: Vector2): ProceduralTexture;
  11034. /**
  11035. * Set a vec3 in the shader from a Vector3.
  11036. * @param name Define the name of the uniform as defined in the shader
  11037. * @param value Define the value to give to the uniform
  11038. * @return the texture itself allowing "fluent" like uniform updates
  11039. */
  11040. setVector3(name: string, value: Vector3): ProceduralTexture;
  11041. /**
  11042. * Set a mat4 in the shader from a MAtrix.
  11043. * @param name Define the name of the uniform as defined in the shader
  11044. * @param value Define the value to give to the uniform
  11045. * @return the texture itself allowing "fluent" like uniform updates
  11046. */
  11047. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11048. /**
  11049. * Render the texture to its associated render target.
  11050. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11051. */
  11052. render(useCameraPostProcess?: boolean): void;
  11053. /**
  11054. * Clone the texture.
  11055. * @returns the cloned texture
  11056. */
  11057. clone(): ProceduralTexture;
  11058. /**
  11059. * Dispose the texture and release its asoociated resources.
  11060. */
  11061. dispose(): void;
  11062. }
  11063. }
  11064. declare module BABYLON {
  11065. /**
  11066. * This represents the base class for particle system in Babylon.
  11067. * 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.
  11068. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11069. * @example https://doc.babylonjs.com/babylon101/particles
  11070. */
  11071. export class BaseParticleSystem {
  11072. /**
  11073. * Source color is added to the destination color without alpha affecting the result
  11074. */
  11075. static BLENDMODE_ONEONE: number;
  11076. /**
  11077. * Blend current color and particle color using particle’s alpha
  11078. */
  11079. static BLENDMODE_STANDARD: number;
  11080. /**
  11081. * Add current color and particle color multiplied by particle’s alpha
  11082. */
  11083. static BLENDMODE_ADD: number;
  11084. /**
  11085. * Multiply current color with particle color
  11086. */
  11087. static BLENDMODE_MULTIPLY: number;
  11088. /**
  11089. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11090. */
  11091. static BLENDMODE_MULTIPLYADD: number;
  11092. /**
  11093. * List of animations used by the particle system.
  11094. */
  11095. animations: Animation[];
  11096. /**
  11097. * Gets or sets the unique id of the particle system
  11098. */
  11099. uniqueId: number;
  11100. /**
  11101. * The id of the Particle system.
  11102. */
  11103. id: string;
  11104. /**
  11105. * The friendly name of the Particle system.
  11106. */
  11107. name: string;
  11108. /**
  11109. * Snippet ID if the particle system was created from the snippet server
  11110. */
  11111. snippetId: string;
  11112. /**
  11113. * The rendering group used by the Particle system to chose when to render.
  11114. */
  11115. renderingGroupId: number;
  11116. /**
  11117. * The emitter represents the Mesh or position we are attaching the particle system to.
  11118. */
  11119. emitter: Nullable<AbstractMesh | Vector3>;
  11120. /**
  11121. * The maximum number of particles to emit per frame
  11122. */
  11123. emitRate: number;
  11124. /**
  11125. * If you want to launch only a few particles at once, that can be done, as well.
  11126. */
  11127. manualEmitCount: number;
  11128. /**
  11129. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11130. */
  11131. updateSpeed: number;
  11132. /**
  11133. * The amount of time the particle system is running (depends of the overall update speed).
  11134. */
  11135. targetStopDuration: number;
  11136. /**
  11137. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11138. */
  11139. disposeOnStop: boolean;
  11140. /**
  11141. * Minimum power of emitting particles.
  11142. */
  11143. minEmitPower: number;
  11144. /**
  11145. * Maximum power of emitting particles.
  11146. */
  11147. maxEmitPower: number;
  11148. /**
  11149. * Minimum life time of emitting particles.
  11150. */
  11151. minLifeTime: number;
  11152. /**
  11153. * Maximum life time of emitting particles.
  11154. */
  11155. maxLifeTime: number;
  11156. /**
  11157. * Minimum Size of emitting particles.
  11158. */
  11159. minSize: number;
  11160. /**
  11161. * Maximum Size of emitting particles.
  11162. */
  11163. maxSize: number;
  11164. /**
  11165. * Minimum scale of emitting particles on X axis.
  11166. */
  11167. minScaleX: number;
  11168. /**
  11169. * Maximum scale of emitting particles on X axis.
  11170. */
  11171. maxScaleX: number;
  11172. /**
  11173. * Minimum scale of emitting particles on Y axis.
  11174. */
  11175. minScaleY: number;
  11176. /**
  11177. * Maximum scale of emitting particles on Y axis.
  11178. */
  11179. maxScaleY: number;
  11180. /**
  11181. * Gets or sets the minimal initial rotation in radians.
  11182. */
  11183. minInitialRotation: number;
  11184. /**
  11185. * Gets or sets the maximal initial rotation in radians.
  11186. */
  11187. maxInitialRotation: number;
  11188. /**
  11189. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11190. */
  11191. minAngularSpeed: number;
  11192. /**
  11193. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11194. */
  11195. maxAngularSpeed: number;
  11196. /**
  11197. * The texture used to render each particle. (this can be a spritesheet)
  11198. */
  11199. particleTexture: Nullable<Texture>;
  11200. /**
  11201. * The layer mask we are rendering the particles through.
  11202. */
  11203. layerMask: number;
  11204. /**
  11205. * This can help using your own shader to render the particle system.
  11206. * The according effect will be created
  11207. */
  11208. customShader: any;
  11209. /**
  11210. * By default particle system starts as soon as they are created. This prevents the
  11211. * automatic start to happen and let you decide when to start emitting particles.
  11212. */
  11213. preventAutoStart: boolean;
  11214. private _noiseTexture;
  11215. /**
  11216. * Gets or sets a texture used to add random noise to particle positions
  11217. */
  11218. get noiseTexture(): Nullable<ProceduralTexture>;
  11219. set noiseTexture(value: Nullable<ProceduralTexture>);
  11220. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11221. noiseStrength: Vector3;
  11222. /**
  11223. * Callback triggered when the particle animation is ending.
  11224. */
  11225. onAnimationEnd: Nullable<() => void>;
  11226. /**
  11227. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11228. */
  11229. blendMode: number;
  11230. /**
  11231. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11232. * to override the particles.
  11233. */
  11234. forceDepthWrite: boolean;
  11235. /** 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 */
  11236. preWarmCycles: number;
  11237. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11238. preWarmStepOffset: number;
  11239. /**
  11240. * 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)
  11241. */
  11242. spriteCellChangeSpeed: number;
  11243. /**
  11244. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11245. */
  11246. startSpriteCellID: number;
  11247. /**
  11248. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11249. */
  11250. endSpriteCellID: number;
  11251. /**
  11252. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11253. */
  11254. spriteCellWidth: number;
  11255. /**
  11256. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11257. */
  11258. spriteCellHeight: number;
  11259. /**
  11260. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11261. */
  11262. spriteRandomStartCell: boolean;
  11263. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11264. translationPivot: Vector2;
  11265. /** @hidden */
  11266. protected _isAnimationSheetEnabled: boolean;
  11267. /**
  11268. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11269. */
  11270. beginAnimationOnStart: boolean;
  11271. /**
  11272. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11273. */
  11274. beginAnimationFrom: number;
  11275. /**
  11276. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11277. */
  11278. beginAnimationTo: number;
  11279. /**
  11280. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11281. */
  11282. beginAnimationLoop: boolean;
  11283. /**
  11284. * Gets or sets a world offset applied to all particles
  11285. */
  11286. worldOffset: Vector3;
  11287. /**
  11288. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11289. */
  11290. get isAnimationSheetEnabled(): boolean;
  11291. set isAnimationSheetEnabled(value: boolean);
  11292. /**
  11293. * Get hosting scene
  11294. * @returns the scene
  11295. */
  11296. getScene(): Scene;
  11297. /**
  11298. * You can use gravity if you want to give an orientation to your particles.
  11299. */
  11300. gravity: Vector3;
  11301. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11302. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11303. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11304. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11305. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11306. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11307. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11308. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11309. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11310. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11311. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11312. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11313. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11314. /**
  11315. * Defines the delay in milliseconds before starting the system (0 by default)
  11316. */
  11317. startDelay: number;
  11318. /**
  11319. * Gets the current list of drag gradients.
  11320. * You must use addDragGradient and removeDragGradient to udpate this list
  11321. * @returns the list of drag gradients
  11322. */
  11323. getDragGradients(): Nullable<Array<FactorGradient>>;
  11324. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11325. limitVelocityDamping: number;
  11326. /**
  11327. * Gets the current list of limit velocity gradients.
  11328. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11329. * @returns the list of limit velocity gradients
  11330. */
  11331. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11332. /**
  11333. * Gets the current list of color gradients.
  11334. * You must use addColorGradient and removeColorGradient to udpate this list
  11335. * @returns the list of color gradients
  11336. */
  11337. getColorGradients(): Nullable<Array<ColorGradient>>;
  11338. /**
  11339. * Gets the current list of size gradients.
  11340. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11341. * @returns the list of size gradients
  11342. */
  11343. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11344. /**
  11345. * Gets the current list of color remap gradients.
  11346. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11347. * @returns the list of color remap gradients
  11348. */
  11349. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11350. /**
  11351. * Gets the current list of alpha remap gradients.
  11352. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11353. * @returns the list of alpha remap gradients
  11354. */
  11355. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11356. /**
  11357. * Gets the current list of life time gradients.
  11358. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11359. * @returns the list of life time gradients
  11360. */
  11361. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11362. /**
  11363. * Gets the current list of angular speed gradients.
  11364. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11365. * @returns the list of angular speed gradients
  11366. */
  11367. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11368. /**
  11369. * Gets the current list of velocity gradients.
  11370. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11371. * @returns the list of velocity gradients
  11372. */
  11373. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11374. /**
  11375. * Gets the current list of start size gradients.
  11376. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11377. * @returns the list of start size gradients
  11378. */
  11379. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11380. /**
  11381. * Gets the current list of emit rate gradients.
  11382. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11383. * @returns the list of emit rate gradients
  11384. */
  11385. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11386. /**
  11387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11388. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11389. */
  11390. get direction1(): Vector3;
  11391. set direction1(value: Vector3);
  11392. /**
  11393. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11394. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11395. */
  11396. get direction2(): Vector3;
  11397. set direction2(value: Vector3);
  11398. /**
  11399. * 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.
  11400. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11401. */
  11402. get minEmitBox(): Vector3;
  11403. set minEmitBox(value: Vector3);
  11404. /**
  11405. * 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.
  11406. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11407. */
  11408. get maxEmitBox(): Vector3;
  11409. set maxEmitBox(value: Vector3);
  11410. /**
  11411. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11412. */
  11413. color1: Color4;
  11414. /**
  11415. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11416. */
  11417. color2: Color4;
  11418. /**
  11419. * Color the particle will have at the end of its lifetime
  11420. */
  11421. colorDead: Color4;
  11422. /**
  11423. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11424. */
  11425. textureMask: Color4;
  11426. /**
  11427. * The particle emitter type defines the emitter used by the particle system.
  11428. * It can be for example box, sphere, or cone...
  11429. */
  11430. particleEmitterType: IParticleEmitterType;
  11431. /** @hidden */
  11432. _isSubEmitter: boolean;
  11433. /**
  11434. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11435. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11436. */
  11437. billboardMode: number;
  11438. protected _isBillboardBased: boolean;
  11439. /**
  11440. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11441. */
  11442. get isBillboardBased(): boolean;
  11443. set isBillboardBased(value: boolean);
  11444. /**
  11445. * The scene the particle system belongs to.
  11446. */
  11447. protected _scene: Scene;
  11448. /**
  11449. * Local cache of defines for image processing.
  11450. */
  11451. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11452. /**
  11453. * Default configuration related to image processing available in the standard Material.
  11454. */
  11455. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11456. /**
  11457. * Gets the image processing configuration used either in this material.
  11458. */
  11459. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11460. /**
  11461. * Sets the Default image processing configuration used either in the this material.
  11462. *
  11463. * If sets to null, the scene one is in use.
  11464. */
  11465. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11466. /**
  11467. * Attaches a new image processing configuration to the Standard Material.
  11468. * @param configuration
  11469. */
  11470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11471. /** @hidden */
  11472. protected _reset(): void;
  11473. /** @hidden */
  11474. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11475. /**
  11476. * Instantiates a particle system.
  11477. * 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.
  11478. * @param name The name of the particle system
  11479. */
  11480. constructor(name: string);
  11481. /**
  11482. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  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. * @returns the emitter
  11486. */
  11487. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11488. /**
  11489. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11490. * @param radius The radius of the hemisphere to emit from
  11491. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11492. * @returns the emitter
  11493. */
  11494. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11495. /**
  11496. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11497. * @param radius The radius of the sphere to emit from
  11498. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11499. * @returns the emitter
  11500. */
  11501. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11502. /**
  11503. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11504. * @param radius The radius of the sphere to emit from
  11505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11507. * @returns the emitter
  11508. */
  11509. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11510. /**
  11511. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11512. * @param radius The radius of the emission cylinder
  11513. * @param height The height of the emission cylinder
  11514. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11515. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11516. * @returns the emitter
  11517. */
  11518. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11519. /**
  11520. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11521. * @param radius The radius of the cylinder to emit from
  11522. * @param height The height of the emission cylinder
  11523. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11524. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11525. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11526. * @returns the emitter
  11527. */
  11528. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11529. /**
  11530. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11531. * @param radius The radius of the cone to emit from
  11532. * @param angle The base angle of the cone
  11533. * @returns the emitter
  11534. */
  11535. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11536. /**
  11537. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11540. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11541. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11542. * @returns the emitter
  11543. */
  11544. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. /**
  11549. * Type of sub emitter
  11550. */
  11551. export enum SubEmitterType {
  11552. /**
  11553. * Attached to the particle over it's lifetime
  11554. */
  11555. ATTACHED = 0,
  11556. /**
  11557. * Created when the particle dies
  11558. */
  11559. END = 1
  11560. }
  11561. /**
  11562. * Sub emitter class used to emit particles from an existing particle
  11563. */
  11564. export class SubEmitter {
  11565. /**
  11566. * the particle system to be used by the sub emitter
  11567. */
  11568. particleSystem: ParticleSystem;
  11569. /**
  11570. * Type of the submitter (Default: END)
  11571. */
  11572. type: SubEmitterType;
  11573. /**
  11574. * 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)
  11575. * Note: This only is supported when using an emitter of type Mesh
  11576. */
  11577. inheritDirection: boolean;
  11578. /**
  11579. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11580. */
  11581. inheritedVelocityAmount: number;
  11582. /**
  11583. * Creates a sub emitter
  11584. * @param particleSystem the particle system to be used by the sub emitter
  11585. */
  11586. constructor(
  11587. /**
  11588. * the particle system to be used by the sub emitter
  11589. */
  11590. particleSystem: ParticleSystem);
  11591. /**
  11592. * Clones the sub emitter
  11593. * @returns the cloned sub emitter
  11594. */
  11595. clone(): SubEmitter;
  11596. /**
  11597. * Serialize current object to a JSON object
  11598. * @returns the serialized object
  11599. */
  11600. serialize(): any;
  11601. /** @hidden */
  11602. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11603. /**
  11604. * Creates a new SubEmitter from a serialized JSON version
  11605. * @param serializationObject defines the JSON object to read from
  11606. * @param scene defines the hosting scene
  11607. * @param rootUrl defines the rootUrl for data loading
  11608. * @returns a new SubEmitter
  11609. */
  11610. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11611. /** Release associated resources */
  11612. dispose(): void;
  11613. }
  11614. }
  11615. declare module BABYLON {
  11616. /** @hidden */
  11617. export var imageProcessingDeclaration: {
  11618. name: string;
  11619. shader: string;
  11620. };
  11621. }
  11622. declare module BABYLON {
  11623. /** @hidden */
  11624. export var imageProcessingFunctions: {
  11625. name: string;
  11626. shader: string;
  11627. };
  11628. }
  11629. declare module BABYLON {
  11630. /** @hidden */
  11631. export var particlesPixelShader: {
  11632. name: string;
  11633. shader: string;
  11634. };
  11635. }
  11636. declare module BABYLON {
  11637. /** @hidden */
  11638. export var particlesVertexShader: {
  11639. name: string;
  11640. shader: string;
  11641. };
  11642. }
  11643. declare module BABYLON {
  11644. /**
  11645. * This represents a particle system in Babylon.
  11646. * 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.
  11647. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11648. * @example https://doc.babylonjs.com/babylon101/particles
  11649. */
  11650. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11651. /**
  11652. * Billboard mode will only apply to Y axis
  11653. */
  11654. static readonly BILLBOARDMODE_Y: number;
  11655. /**
  11656. * Billboard mode will apply to all axes
  11657. */
  11658. static readonly BILLBOARDMODE_ALL: number;
  11659. /**
  11660. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11661. */
  11662. static readonly BILLBOARDMODE_STRETCHED: number;
  11663. /**
  11664. * This function can be defined to provide custom update for active particles.
  11665. * This function will be called instead of regular update (age, position, color, etc.).
  11666. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11667. */
  11668. updateFunction: (particles: Particle[]) => void;
  11669. private _emitterWorldMatrix;
  11670. /**
  11671. * This function can be defined to specify initial direction for every new particle.
  11672. * It by default use the emitterType defined function
  11673. */
  11674. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11675. /**
  11676. * This function can be defined to specify initial position for every new particle.
  11677. * It by default use the emitterType defined function
  11678. */
  11679. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11680. /**
  11681. * @hidden
  11682. */
  11683. _inheritedVelocityOffset: Vector3;
  11684. /**
  11685. * An event triggered when the system is disposed
  11686. */
  11687. onDisposeObservable: Observable<ParticleSystem>;
  11688. private _onDisposeObserver;
  11689. /**
  11690. * Sets a callback that will be triggered when the system is disposed
  11691. */
  11692. set onDispose(callback: () => void);
  11693. private _particles;
  11694. private _epsilon;
  11695. private _capacity;
  11696. private _stockParticles;
  11697. private _newPartsExcess;
  11698. private _vertexData;
  11699. private _vertexBuffer;
  11700. private _vertexBuffers;
  11701. private _spriteBuffer;
  11702. private _indexBuffer;
  11703. private _effect;
  11704. private _customEffect;
  11705. private _cachedDefines;
  11706. private _scaledColorStep;
  11707. private _colorDiff;
  11708. private _scaledDirection;
  11709. private _scaledGravity;
  11710. private _currentRenderId;
  11711. private _alive;
  11712. private _useInstancing;
  11713. private _started;
  11714. private _stopped;
  11715. private _actualFrame;
  11716. private _scaledUpdateSpeed;
  11717. private _vertexBufferSize;
  11718. /** @hidden */
  11719. _currentEmitRateGradient: Nullable<FactorGradient>;
  11720. /** @hidden */
  11721. _currentEmitRate1: number;
  11722. /** @hidden */
  11723. _currentEmitRate2: number;
  11724. /** @hidden */
  11725. _currentStartSizeGradient: Nullable<FactorGradient>;
  11726. /** @hidden */
  11727. _currentStartSize1: number;
  11728. /** @hidden */
  11729. _currentStartSize2: number;
  11730. private readonly _rawTextureWidth;
  11731. private _rampGradientsTexture;
  11732. private _useRampGradients;
  11733. /** Gets or sets a boolean indicating that ramp gradients must be used
  11734. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11735. */
  11736. get useRampGradients(): boolean;
  11737. set useRampGradients(value: boolean);
  11738. /**
  11739. * 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.
  11740. * 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: [])
  11741. */
  11742. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11743. private _subEmitters;
  11744. /**
  11745. * @hidden
  11746. * If the particle systems emitter should be disposed when the particle system is disposed
  11747. */
  11748. _disposeEmitterOnDispose: boolean;
  11749. /**
  11750. * The current active Sub-systems, this property is used by the root particle system only.
  11751. */
  11752. activeSubSystems: Array<ParticleSystem>;
  11753. /**
  11754. * Specifies if the particles are updated in emitter local space or world space
  11755. */
  11756. isLocal: boolean;
  11757. private _rootParticleSystem;
  11758. /**
  11759. * Gets the current list of active particles
  11760. */
  11761. get particles(): Particle[];
  11762. /**
  11763. * Gets the number of particles active at the same time.
  11764. * @returns The number of active particles.
  11765. */
  11766. getActiveCount(): number;
  11767. /**
  11768. * Returns the string "ParticleSystem"
  11769. * @returns a string containing the class name
  11770. */
  11771. getClassName(): string;
  11772. /**
  11773. * Gets a boolean indicating that the system is stopping
  11774. * @returns true if the system is currently stopping
  11775. */
  11776. isStopping(): boolean;
  11777. /**
  11778. * Instantiates a particle system.
  11779. * 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.
  11780. * @param name The name of the particle system
  11781. * @param capacity The max number of particles alive at the same time
  11782. * @param scene The scene the particle system belongs to
  11783. * @param customEffect a custom effect used to change the way particles are rendered by default
  11784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11785. * @param epsilon Offset used to render the particles
  11786. */
  11787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11788. private _addFactorGradient;
  11789. private _removeFactorGradient;
  11790. /**
  11791. * Adds a new life time gradient
  11792. * @param gradient defines the gradient to use (between 0 and 1)
  11793. * @param factor defines the life time factor to affect to the specified gradient
  11794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11795. * @returns the current particle system
  11796. */
  11797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11798. /**
  11799. * Remove a specific life time gradient
  11800. * @param gradient defines the gradient to remove
  11801. * @returns the current particle system
  11802. */
  11803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11804. /**
  11805. * Adds a new size gradient
  11806. * @param gradient defines the gradient to use (between 0 and 1)
  11807. * @param factor defines the size factor to affect to the specified gradient
  11808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11809. * @returns the current particle system
  11810. */
  11811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11812. /**
  11813. * Remove a specific size gradient
  11814. * @param gradient defines the gradient to remove
  11815. * @returns the current particle system
  11816. */
  11817. removeSizeGradient(gradient: number): IParticleSystem;
  11818. /**
  11819. * Adds a new color remap gradient
  11820. * @param gradient defines the gradient to use (between 0 and 1)
  11821. * @param min defines the color remap minimal range
  11822. * @param max defines the color remap maximal range
  11823. * @returns the current particle system
  11824. */
  11825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11826. /**
  11827. * Remove a specific color remap gradient
  11828. * @param gradient defines the gradient to remove
  11829. * @returns the current particle system
  11830. */
  11831. removeColorRemapGradient(gradient: number): IParticleSystem;
  11832. /**
  11833. * Adds a new alpha remap gradient
  11834. * @param gradient defines the gradient to use (between 0 and 1)
  11835. * @param min defines the alpha remap minimal range
  11836. * @param max defines the alpha remap maximal range
  11837. * @returns the current particle system
  11838. */
  11839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11840. /**
  11841. * Remove a specific alpha remap gradient
  11842. * @param gradient defines the gradient to remove
  11843. * @returns the current particle system
  11844. */
  11845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11846. /**
  11847. * Adds a new angular speed gradient
  11848. * @param gradient defines the gradient to use (between 0 and 1)
  11849. * @param factor defines the angular speed to affect to the specified gradient
  11850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11851. * @returns the current particle system
  11852. */
  11853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11854. /**
  11855. * Remove a specific angular speed gradient
  11856. * @param gradient defines the gradient to remove
  11857. * @returns the current particle system
  11858. */
  11859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11860. /**
  11861. * Adds a new velocity gradient
  11862. * @param gradient defines the gradient to use (between 0 and 1)
  11863. * @param factor defines the velocity to affect to the specified gradient
  11864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11865. * @returns the current particle system
  11866. */
  11867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11868. /**
  11869. * Remove a specific velocity gradient
  11870. * @param gradient defines the gradient to remove
  11871. * @returns the current particle system
  11872. */
  11873. removeVelocityGradient(gradient: number): IParticleSystem;
  11874. /**
  11875. * Adds a new limit velocity gradient
  11876. * @param gradient defines the gradient to use (between 0 and 1)
  11877. * @param factor defines the limit velocity value to affect to the specified gradient
  11878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11879. * @returns the current particle system
  11880. */
  11881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11882. /**
  11883. * Remove a specific limit velocity gradient
  11884. * @param gradient defines the gradient to remove
  11885. * @returns the current particle system
  11886. */
  11887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11888. /**
  11889. * Adds a new drag gradient
  11890. * @param gradient defines the gradient to use (between 0 and 1)
  11891. * @param factor defines the drag value to affect to the specified gradient
  11892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11893. * @returns the current particle system
  11894. */
  11895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11896. /**
  11897. * Remove a specific drag gradient
  11898. * @param gradient defines the gradient to remove
  11899. * @returns the current particle system
  11900. */
  11901. removeDragGradient(gradient: number): IParticleSystem;
  11902. /**
  11903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11904. * @param gradient defines the gradient to use (between 0 and 1)
  11905. * @param factor defines the emit rate value to affect to the specified gradient
  11906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11907. * @returns the current particle system
  11908. */
  11909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11910. /**
  11911. * Remove a specific emit rate gradient
  11912. * @param gradient defines the gradient to remove
  11913. * @returns the current particle system
  11914. */
  11915. removeEmitRateGradient(gradient: number): IParticleSystem;
  11916. /**
  11917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11918. * @param gradient defines the gradient to use (between 0 and 1)
  11919. * @param factor defines the start size value to affect to the specified gradient
  11920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11921. * @returns the current particle system
  11922. */
  11923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11924. /**
  11925. * Remove a specific start size gradient
  11926. * @param gradient defines the gradient to remove
  11927. * @returns the current particle system
  11928. */
  11929. removeStartSizeGradient(gradient: number): IParticleSystem;
  11930. private _createRampGradientTexture;
  11931. /**
  11932. * Gets the current list of ramp gradients.
  11933. * You must use addRampGradient and removeRampGradient to udpate this list
  11934. * @returns the list of ramp gradients
  11935. */
  11936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11937. /** Force the system to rebuild all gradients that need to be resync */
  11938. forceRefreshGradients(): void;
  11939. private _syncRampGradientTexture;
  11940. /**
  11941. * Adds a new ramp gradient used to remap particle colors
  11942. * @param gradient defines the gradient to use (between 0 and 1)
  11943. * @param color defines the color to affect to the specified gradient
  11944. * @returns the current particle system
  11945. */
  11946. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11947. /**
  11948. * Remove a specific ramp gradient
  11949. * @param gradient defines the gradient to remove
  11950. * @returns the current particle system
  11951. */
  11952. removeRampGradient(gradient: number): ParticleSystem;
  11953. /**
  11954. * Adds a new color gradient
  11955. * @param gradient defines the gradient to use (between 0 and 1)
  11956. * @param color1 defines the color to affect to the specified gradient
  11957. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11958. * @returns this particle system
  11959. */
  11960. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11961. /**
  11962. * Remove a specific color gradient
  11963. * @param gradient defines the gradient to remove
  11964. * @returns this particle system
  11965. */
  11966. removeColorGradient(gradient: number): IParticleSystem;
  11967. private _fetchR;
  11968. protected _reset(): void;
  11969. private _resetEffect;
  11970. private _createVertexBuffers;
  11971. private _createIndexBuffer;
  11972. /**
  11973. * Gets the maximum number of particles active at the same time.
  11974. * @returns The max number of active particles.
  11975. */
  11976. getCapacity(): number;
  11977. /**
  11978. * Gets whether there are still active particles in the system.
  11979. * @returns True if it is alive, otherwise false.
  11980. */
  11981. isAlive(): boolean;
  11982. /**
  11983. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11984. * @returns True if it has been started, otherwise false.
  11985. */
  11986. isStarted(): boolean;
  11987. private _prepareSubEmitterInternalArray;
  11988. /**
  11989. * Starts the particle system and begins to emit
  11990. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11991. */
  11992. start(delay?: number): void;
  11993. /**
  11994. * Stops the particle system.
  11995. * @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.
  11996. */
  11997. stop(stopSubEmitters?: boolean): void;
  11998. /**
  11999. * Remove all active particles
  12000. */
  12001. reset(): void;
  12002. /**
  12003. * @hidden (for internal use only)
  12004. */
  12005. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12006. /**
  12007. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12008. * Its lifetime will start back at 0.
  12009. */
  12010. recycleParticle: (particle: Particle) => void;
  12011. private _stopSubEmitters;
  12012. private _createParticle;
  12013. private _removeFromRoot;
  12014. private _emitFromParticle;
  12015. private _update;
  12016. /** @hidden */
  12017. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12018. /** @hidden */
  12019. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12020. /** @hidden */
  12021. private _getEffect;
  12022. /**
  12023. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12024. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12025. */
  12026. animate(preWarmOnly?: boolean): void;
  12027. private _appendParticleVertices;
  12028. /**
  12029. * Rebuilds the particle system.
  12030. */
  12031. rebuild(): void;
  12032. /**
  12033. * Is this system ready to be used/rendered
  12034. * @return true if the system is ready
  12035. */
  12036. isReady(): boolean;
  12037. private _render;
  12038. /**
  12039. * Renders the particle system in its current state.
  12040. * @returns the current number of particles
  12041. */
  12042. render(): number;
  12043. /**
  12044. * Disposes the particle system and free the associated resources
  12045. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12046. */
  12047. dispose(disposeTexture?: boolean): void;
  12048. /**
  12049. * Clones the particle system.
  12050. * @param name The name of the cloned object
  12051. * @param newEmitter The new emitter to use
  12052. * @returns the cloned particle system
  12053. */
  12054. clone(name: string, newEmitter: any): ParticleSystem;
  12055. /**
  12056. * Serializes the particle system to a JSON object
  12057. * @param serializeTexture defines if the texture must be serialized as well
  12058. * @returns the JSON object
  12059. */
  12060. serialize(serializeTexture?: boolean): any;
  12061. /** @hidden */
  12062. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12063. /** @hidden */
  12064. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12065. /**
  12066. * Parses a JSON object to create a particle system.
  12067. * @param parsedParticleSystem The JSON object to parse
  12068. * @param scene The scene to create the particle system in
  12069. * @param rootUrl The root url to use to load external dependencies like texture
  12070. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12071. * @returns the Parsed particle system
  12072. */
  12073. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12074. }
  12075. }
  12076. declare module BABYLON {
  12077. /**
  12078. * A particle represents one of the element emitted by a particle system.
  12079. * This is mainly define by its coordinates, direction, velocity and age.
  12080. */
  12081. export class Particle {
  12082. /**
  12083. * The particle system the particle belongs to.
  12084. */
  12085. particleSystem: ParticleSystem;
  12086. private static _Count;
  12087. /**
  12088. * Unique ID of the particle
  12089. */
  12090. id: number;
  12091. /**
  12092. * The world position of the particle in the scene.
  12093. */
  12094. position: Vector3;
  12095. /**
  12096. * The world direction of the particle in the scene.
  12097. */
  12098. direction: Vector3;
  12099. /**
  12100. * The color of the particle.
  12101. */
  12102. color: Color4;
  12103. /**
  12104. * The color change of the particle per step.
  12105. */
  12106. colorStep: Color4;
  12107. /**
  12108. * Defines how long will the life of the particle be.
  12109. */
  12110. lifeTime: number;
  12111. /**
  12112. * The current age of the particle.
  12113. */
  12114. age: number;
  12115. /**
  12116. * The current size of the particle.
  12117. */
  12118. size: number;
  12119. /**
  12120. * The current scale of the particle.
  12121. */
  12122. scale: Vector2;
  12123. /**
  12124. * The current angle of the particle.
  12125. */
  12126. angle: number;
  12127. /**
  12128. * Defines how fast is the angle changing.
  12129. */
  12130. angularSpeed: number;
  12131. /**
  12132. * Defines the cell index used by the particle to be rendered from a sprite.
  12133. */
  12134. cellIndex: number;
  12135. /**
  12136. * The information required to support color remapping
  12137. */
  12138. remapData: Vector4;
  12139. /** @hidden */
  12140. _randomCellOffset?: number;
  12141. /** @hidden */
  12142. _initialDirection: Nullable<Vector3>;
  12143. /** @hidden */
  12144. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12145. /** @hidden */
  12146. _initialStartSpriteCellID: number;
  12147. /** @hidden */
  12148. _initialEndSpriteCellID: number;
  12149. /** @hidden */
  12150. _currentColorGradient: Nullable<ColorGradient>;
  12151. /** @hidden */
  12152. _currentColor1: Color4;
  12153. /** @hidden */
  12154. _currentColor2: Color4;
  12155. /** @hidden */
  12156. _currentSizeGradient: Nullable<FactorGradient>;
  12157. /** @hidden */
  12158. _currentSize1: number;
  12159. /** @hidden */
  12160. _currentSize2: number;
  12161. /** @hidden */
  12162. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12163. /** @hidden */
  12164. _currentAngularSpeed1: number;
  12165. /** @hidden */
  12166. _currentAngularSpeed2: number;
  12167. /** @hidden */
  12168. _currentVelocityGradient: Nullable<FactorGradient>;
  12169. /** @hidden */
  12170. _currentVelocity1: number;
  12171. /** @hidden */
  12172. _currentVelocity2: number;
  12173. /** @hidden */
  12174. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12175. /** @hidden */
  12176. _currentLimitVelocity1: number;
  12177. /** @hidden */
  12178. _currentLimitVelocity2: number;
  12179. /** @hidden */
  12180. _currentDragGradient: Nullable<FactorGradient>;
  12181. /** @hidden */
  12182. _currentDrag1: number;
  12183. /** @hidden */
  12184. _currentDrag2: number;
  12185. /** @hidden */
  12186. _randomNoiseCoordinates1: Vector3;
  12187. /** @hidden */
  12188. _randomNoiseCoordinates2: Vector3;
  12189. /** @hidden */
  12190. _localPosition?: Vector3;
  12191. /**
  12192. * Creates a new instance Particle
  12193. * @param particleSystem the particle system the particle belongs to
  12194. */
  12195. constructor(
  12196. /**
  12197. * The particle system the particle belongs to.
  12198. */
  12199. particleSystem: ParticleSystem);
  12200. private updateCellInfoFromSystem;
  12201. /**
  12202. * Defines how the sprite cell index is updated for the particle
  12203. */
  12204. updateCellIndex(): void;
  12205. /** @hidden */
  12206. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12207. /** @hidden */
  12208. _inheritParticleInfoToSubEmitters(): void;
  12209. /** @hidden */
  12210. _reset(): void;
  12211. /**
  12212. * Copy the properties of particle to another one.
  12213. * @param other the particle to copy the information to.
  12214. */
  12215. copyTo(other: Particle): void;
  12216. }
  12217. }
  12218. declare module BABYLON {
  12219. /**
  12220. * Particle emitter represents a volume emitting particles.
  12221. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12222. */
  12223. export interface IParticleEmitterType {
  12224. /**
  12225. * Called by the particle System when the direction is computed for the created particle.
  12226. * @param worldMatrix is the world matrix of the particle system
  12227. * @param directionToUpdate is the direction vector to update with the result
  12228. * @param particle is the particle we are computed the direction for
  12229. * @param isLocal defines if the direction should be set in local space
  12230. */
  12231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12232. /**
  12233. * Called by the particle System when the position is computed for the created particle.
  12234. * @param worldMatrix is the world matrix of the particle system
  12235. * @param positionToUpdate is the position vector to update with the result
  12236. * @param particle is the particle we are computed the position for
  12237. * @param isLocal defines if the position should be set in local space
  12238. */
  12239. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12240. /**
  12241. * Clones the current emitter and returns a copy of it
  12242. * @returns the new emitter
  12243. */
  12244. clone(): IParticleEmitterType;
  12245. /**
  12246. * Called by the GPUParticleSystem to setup the update shader
  12247. * @param effect defines the update shader
  12248. */
  12249. applyToShader(effect: Effect): void;
  12250. /**
  12251. * Returns a string to use to update the GPU particles update shader
  12252. * @returns the effect defines string
  12253. */
  12254. getEffectDefines(): string;
  12255. /**
  12256. * Returns a string representing the class name
  12257. * @returns a string containing the class name
  12258. */
  12259. getClassName(): string;
  12260. /**
  12261. * Serializes the particle system to a JSON object.
  12262. * @returns the JSON object
  12263. */
  12264. serialize(): any;
  12265. /**
  12266. * Parse properties from a JSON object
  12267. * @param serializationObject defines the JSON object
  12268. * @param scene defines the hosting scene
  12269. */
  12270. parse(serializationObject: any, scene: Scene): void;
  12271. }
  12272. }
  12273. declare module BABYLON {
  12274. /**
  12275. * Particle emitter emitting particles from the inside of a box.
  12276. * It emits the particles randomly between 2 given directions.
  12277. */
  12278. export class BoxParticleEmitter implements IParticleEmitterType {
  12279. /**
  12280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12281. */
  12282. direction1: Vector3;
  12283. /**
  12284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12285. */
  12286. direction2: Vector3;
  12287. /**
  12288. * 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.
  12289. */
  12290. minEmitBox: Vector3;
  12291. /**
  12292. * 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.
  12293. */
  12294. maxEmitBox: Vector3;
  12295. /**
  12296. * Creates a new instance BoxParticleEmitter
  12297. */
  12298. constructor();
  12299. /**
  12300. * Called by the particle System when the direction is computed for the created particle.
  12301. * @param worldMatrix is the world matrix of the particle system
  12302. * @param directionToUpdate is the direction vector to update with the result
  12303. * @param particle is the particle we are computed the direction for
  12304. * @param isLocal defines if the direction should be set in local space
  12305. */
  12306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12307. /**
  12308. * Called by the particle System when the position is computed for the created particle.
  12309. * @param worldMatrix is the world matrix of the particle system
  12310. * @param positionToUpdate is the position vector to update with the result
  12311. * @param particle is the particle we are computed the position for
  12312. * @param isLocal defines if the position should be set in local space
  12313. */
  12314. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12315. /**
  12316. * Clones the current emitter and returns a copy of it
  12317. * @returns the new emitter
  12318. */
  12319. clone(): BoxParticleEmitter;
  12320. /**
  12321. * Called by the GPUParticleSystem to setup the update shader
  12322. * @param effect defines the update shader
  12323. */
  12324. applyToShader(effect: Effect): void;
  12325. /**
  12326. * Returns a string to use to update the GPU particles update shader
  12327. * @returns a string containng the defines string
  12328. */
  12329. getEffectDefines(): string;
  12330. /**
  12331. * Returns the string "BoxParticleEmitter"
  12332. * @returns a string containing the class name
  12333. */
  12334. getClassName(): string;
  12335. /**
  12336. * Serializes the particle system to a JSON object.
  12337. * @returns the JSON object
  12338. */
  12339. serialize(): any;
  12340. /**
  12341. * Parse properties from a JSON object
  12342. * @param serializationObject defines the JSON object
  12343. */
  12344. parse(serializationObject: any): void;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Particle emitter emitting particles from the inside of a cone.
  12350. * It emits the particles alongside the cone volume from the base to the particle.
  12351. * The emission direction might be randomized.
  12352. */
  12353. export class ConeParticleEmitter implements IParticleEmitterType {
  12354. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12355. directionRandomizer: number;
  12356. private _radius;
  12357. private _angle;
  12358. private _height;
  12359. /**
  12360. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12361. */
  12362. radiusRange: number;
  12363. /**
  12364. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12365. */
  12366. heightRange: number;
  12367. /**
  12368. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12369. */
  12370. emitFromSpawnPointOnly: boolean;
  12371. /**
  12372. * Gets or sets the radius of the emission cone
  12373. */
  12374. get radius(): number;
  12375. set radius(value: number);
  12376. /**
  12377. * Gets or sets the angle of the emission cone
  12378. */
  12379. get angle(): number;
  12380. set angle(value: number);
  12381. private _buildHeight;
  12382. /**
  12383. * Creates a new instance ConeParticleEmitter
  12384. * @param radius the radius of the emission cone (1 by default)
  12385. * @param angle the cone base angle (PI by default)
  12386. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12387. */
  12388. constructor(radius?: number, angle?: number,
  12389. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12390. directionRandomizer?: number);
  12391. /**
  12392. * Called by the particle System when the direction is computed for the created particle.
  12393. * @param worldMatrix is the world matrix of the particle system
  12394. * @param directionToUpdate is the direction vector to update with the result
  12395. * @param particle is the particle we are computed the direction for
  12396. * @param isLocal defines if the direction should be set in local space
  12397. */
  12398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12399. /**
  12400. * Called by the particle System when the position is computed for the created particle.
  12401. * @param worldMatrix is the world matrix of the particle system
  12402. * @param positionToUpdate is the position vector to update with the result
  12403. * @param particle is the particle we are computed the position for
  12404. * @param isLocal defines if the position should be set in local space
  12405. */
  12406. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12407. /**
  12408. * Clones the current emitter and returns a copy of it
  12409. * @returns the new emitter
  12410. */
  12411. clone(): ConeParticleEmitter;
  12412. /**
  12413. * Called by the GPUParticleSystem to setup the update shader
  12414. * @param effect defines the update shader
  12415. */
  12416. applyToShader(effect: Effect): void;
  12417. /**
  12418. * Returns a string to use to update the GPU particles update shader
  12419. * @returns a string containng the defines string
  12420. */
  12421. getEffectDefines(): string;
  12422. /**
  12423. * Returns the string "ConeParticleEmitter"
  12424. * @returns a string containing the class name
  12425. */
  12426. getClassName(): string;
  12427. /**
  12428. * Serializes the particle system to a JSON object.
  12429. * @returns the JSON object
  12430. */
  12431. serialize(): any;
  12432. /**
  12433. * Parse properties from a JSON object
  12434. * @param serializationObject defines the JSON object
  12435. */
  12436. parse(serializationObject: any): void;
  12437. }
  12438. }
  12439. declare module BABYLON {
  12440. /**
  12441. * Particle emitter emitting particles from the inside of a cylinder.
  12442. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12443. */
  12444. export class CylinderParticleEmitter implements IParticleEmitterType {
  12445. /**
  12446. * The radius of the emission cylinder.
  12447. */
  12448. radius: number;
  12449. /**
  12450. * The height of the emission cylinder.
  12451. */
  12452. height: number;
  12453. /**
  12454. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12455. */
  12456. radiusRange: number;
  12457. /**
  12458. * How much to randomize the particle direction [0-1].
  12459. */
  12460. directionRandomizer: number;
  12461. /**
  12462. * Creates a new instance CylinderParticleEmitter
  12463. * @param radius the radius of the emission cylinder (1 by default)
  12464. * @param height the height of the emission cylinder (1 by default)
  12465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12466. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12467. */
  12468. constructor(
  12469. /**
  12470. * The radius of the emission cylinder.
  12471. */
  12472. radius?: number,
  12473. /**
  12474. * The height of the emission cylinder.
  12475. */
  12476. height?: number,
  12477. /**
  12478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12479. */
  12480. radiusRange?: number,
  12481. /**
  12482. * How much to randomize the particle direction [0-1].
  12483. */
  12484. directionRandomizer?: number);
  12485. /**
  12486. * Called by the particle System when the direction is computed for the created particle.
  12487. * @param worldMatrix is the world matrix of the particle system
  12488. * @param directionToUpdate is the direction vector to update with the result
  12489. * @param particle is the particle we are computed the direction for
  12490. * @param isLocal defines if the direction should be set in local space
  12491. */
  12492. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12493. /**
  12494. * Called by the particle System when the position is computed for the created particle.
  12495. * @param worldMatrix is the world matrix of the particle system
  12496. * @param positionToUpdate is the position vector to update with the result
  12497. * @param particle is the particle we are computed the position for
  12498. * @param isLocal defines if the position should be set in local space
  12499. */
  12500. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12501. /**
  12502. * Clones the current emitter and returns a copy of it
  12503. * @returns the new emitter
  12504. */
  12505. clone(): CylinderParticleEmitter;
  12506. /**
  12507. * Called by the GPUParticleSystem to setup the update shader
  12508. * @param effect defines the update shader
  12509. */
  12510. applyToShader(effect: Effect): void;
  12511. /**
  12512. * Returns a string to use to update the GPU particles update shader
  12513. * @returns a string containng the defines string
  12514. */
  12515. getEffectDefines(): string;
  12516. /**
  12517. * Returns the string "CylinderParticleEmitter"
  12518. * @returns a string containing the class name
  12519. */
  12520. getClassName(): string;
  12521. /**
  12522. * Serializes the particle system to a JSON object.
  12523. * @returns the JSON object
  12524. */
  12525. serialize(): any;
  12526. /**
  12527. * Parse properties from a JSON object
  12528. * @param serializationObject defines the JSON object
  12529. */
  12530. parse(serializationObject: any): void;
  12531. }
  12532. /**
  12533. * Particle emitter emitting particles from the inside of a cylinder.
  12534. * It emits the particles randomly between two vectors.
  12535. */
  12536. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12537. /**
  12538. * The min limit of the emission direction.
  12539. */
  12540. direction1: Vector3;
  12541. /**
  12542. * The max limit of the emission direction.
  12543. */
  12544. direction2: Vector3;
  12545. /**
  12546. * Creates a new instance CylinderDirectedParticleEmitter
  12547. * @param radius the radius of the emission cylinder (1 by default)
  12548. * @param height the height of the emission cylinder (1 by default)
  12549. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12550. * @param direction1 the min limit of the emission direction (up vector by default)
  12551. * @param direction2 the max limit of the emission direction (up vector by default)
  12552. */
  12553. constructor(radius?: number, height?: number, radiusRange?: number,
  12554. /**
  12555. * The min limit of the emission direction.
  12556. */
  12557. direction1?: Vector3,
  12558. /**
  12559. * The max limit of the emission direction.
  12560. */
  12561. direction2?: Vector3);
  12562. /**
  12563. * Called by the particle System when the direction is computed for the created particle.
  12564. * @param worldMatrix is the world matrix of the particle system
  12565. * @param directionToUpdate is the direction vector to update with the result
  12566. * @param particle is the particle we are computed the direction for
  12567. */
  12568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12569. /**
  12570. * Clones the current emitter and returns a copy of it
  12571. * @returns the new emitter
  12572. */
  12573. clone(): CylinderDirectedParticleEmitter;
  12574. /**
  12575. * Called by the GPUParticleSystem to setup the update shader
  12576. * @param effect defines the update shader
  12577. */
  12578. applyToShader(effect: Effect): void;
  12579. /**
  12580. * Returns a string to use to update the GPU particles update shader
  12581. * @returns a string containng the defines string
  12582. */
  12583. getEffectDefines(): string;
  12584. /**
  12585. * Returns the string "CylinderDirectedParticleEmitter"
  12586. * @returns a string containing the class name
  12587. */
  12588. getClassName(): string;
  12589. /**
  12590. * Serializes the particle system to a JSON object.
  12591. * @returns the JSON object
  12592. */
  12593. serialize(): any;
  12594. /**
  12595. * Parse properties from a JSON object
  12596. * @param serializationObject defines the JSON object
  12597. */
  12598. parse(serializationObject: any): void;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * Particle emitter emitting particles from the inside of a hemisphere.
  12604. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12605. */
  12606. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12607. /**
  12608. * The radius of the emission hemisphere.
  12609. */
  12610. radius: number;
  12611. /**
  12612. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12613. */
  12614. radiusRange: number;
  12615. /**
  12616. * How much to randomize the particle direction [0-1].
  12617. */
  12618. directionRandomizer: number;
  12619. /**
  12620. * Creates a new instance HemisphericParticleEmitter
  12621. * @param radius the radius of the emission hemisphere (1 by default)
  12622. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12623. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12624. */
  12625. constructor(
  12626. /**
  12627. * The radius of the emission hemisphere.
  12628. */
  12629. radius?: number,
  12630. /**
  12631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12632. */
  12633. radiusRange?: number,
  12634. /**
  12635. * How much to randomize the particle direction [0-1].
  12636. */
  12637. directionRandomizer?: number);
  12638. /**
  12639. * Called by the particle System when the direction is computed for the created particle.
  12640. * @param worldMatrix is the world matrix of the particle system
  12641. * @param directionToUpdate is the direction vector to update with the result
  12642. * @param particle is the particle we are computed the direction for
  12643. * @param isLocal defines if the direction should be set in local space
  12644. */
  12645. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12646. /**
  12647. * Called by the particle System when the position is computed for the created particle.
  12648. * @param worldMatrix is the world matrix of the particle system
  12649. * @param positionToUpdate is the position vector to update with the result
  12650. * @param particle is the particle we are computed the position for
  12651. * @param isLocal defines if the position should be set in local space
  12652. */
  12653. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12654. /**
  12655. * Clones the current emitter and returns a copy of it
  12656. * @returns the new emitter
  12657. */
  12658. clone(): HemisphericParticleEmitter;
  12659. /**
  12660. * Called by the GPUParticleSystem to setup the update shader
  12661. * @param effect defines the update shader
  12662. */
  12663. applyToShader(effect: Effect): void;
  12664. /**
  12665. * Returns a string to use to update the GPU particles update shader
  12666. * @returns a string containng the defines string
  12667. */
  12668. getEffectDefines(): string;
  12669. /**
  12670. * Returns the string "HemisphericParticleEmitter"
  12671. * @returns a string containing the class name
  12672. */
  12673. getClassName(): string;
  12674. /**
  12675. * Serializes the particle system to a JSON object.
  12676. * @returns the JSON object
  12677. */
  12678. serialize(): any;
  12679. /**
  12680. * Parse properties from a JSON object
  12681. * @param serializationObject defines the JSON object
  12682. */
  12683. parse(serializationObject: any): void;
  12684. }
  12685. }
  12686. declare module BABYLON {
  12687. /**
  12688. * Particle emitter emitting particles from a point.
  12689. * It emits the particles randomly between 2 given directions.
  12690. */
  12691. export class PointParticleEmitter implements IParticleEmitterType {
  12692. /**
  12693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12694. */
  12695. direction1: Vector3;
  12696. /**
  12697. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12698. */
  12699. direction2: Vector3;
  12700. /**
  12701. * Creates a new instance PointParticleEmitter
  12702. */
  12703. constructor();
  12704. /**
  12705. * Called by the particle System when the direction is computed for the created particle.
  12706. * @param worldMatrix is the world matrix of the particle system
  12707. * @param directionToUpdate is the direction vector to update with the result
  12708. * @param particle is the particle we are computed the direction for
  12709. * @param isLocal defines if the direction should be set in local space
  12710. */
  12711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12712. /**
  12713. * Called by the particle System when the position is computed for the created particle.
  12714. * @param worldMatrix is the world matrix of the particle system
  12715. * @param positionToUpdate is the position vector to update with the result
  12716. * @param particle is the particle we are computed the position for
  12717. * @param isLocal defines if the position should be set in local space
  12718. */
  12719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12720. /**
  12721. * Clones the current emitter and returns a copy of it
  12722. * @returns the new emitter
  12723. */
  12724. clone(): PointParticleEmitter;
  12725. /**
  12726. * Called by the GPUParticleSystem to setup the update shader
  12727. * @param effect defines the update shader
  12728. */
  12729. applyToShader(effect: Effect): void;
  12730. /**
  12731. * Returns a string to use to update the GPU particles update shader
  12732. * @returns a string containng the defines string
  12733. */
  12734. getEffectDefines(): string;
  12735. /**
  12736. * Returns the string "PointParticleEmitter"
  12737. * @returns a string containing the class name
  12738. */
  12739. getClassName(): string;
  12740. /**
  12741. * Serializes the particle system to a JSON object.
  12742. * @returns the JSON object
  12743. */
  12744. serialize(): any;
  12745. /**
  12746. * Parse properties from a JSON object
  12747. * @param serializationObject defines the JSON object
  12748. */
  12749. parse(serializationObject: any): void;
  12750. }
  12751. }
  12752. declare module BABYLON {
  12753. /**
  12754. * Particle emitter emitting particles from the inside of a sphere.
  12755. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12756. */
  12757. export class SphereParticleEmitter implements IParticleEmitterType {
  12758. /**
  12759. * The radius of the emission sphere.
  12760. */
  12761. radius: number;
  12762. /**
  12763. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12764. */
  12765. radiusRange: number;
  12766. /**
  12767. * How much to randomize the particle direction [0-1].
  12768. */
  12769. directionRandomizer: number;
  12770. /**
  12771. * Creates a new instance SphereParticleEmitter
  12772. * @param radius the radius of the emission sphere (1 by default)
  12773. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12774. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12775. */
  12776. constructor(
  12777. /**
  12778. * The radius of the emission sphere.
  12779. */
  12780. radius?: number,
  12781. /**
  12782. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12783. */
  12784. radiusRange?: number,
  12785. /**
  12786. * How much to randomize the particle direction [0-1].
  12787. */
  12788. directionRandomizer?: number);
  12789. /**
  12790. * Called by the particle System when the direction is computed for the created particle.
  12791. * @param worldMatrix is the world matrix of the particle system
  12792. * @param directionToUpdate is the direction vector to update with the result
  12793. * @param particle is the particle we are computed the direction for
  12794. * @param isLocal defines if the direction should be set in local space
  12795. */
  12796. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12797. /**
  12798. * Called by the particle System when the position is computed for the created particle.
  12799. * @param worldMatrix is the world matrix of the particle system
  12800. * @param positionToUpdate is the position vector to update with the result
  12801. * @param particle is the particle we are computed the position for
  12802. * @param isLocal defines if the position should be set in local space
  12803. */
  12804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12805. /**
  12806. * Clones the current emitter and returns a copy of it
  12807. * @returns the new emitter
  12808. */
  12809. clone(): SphereParticleEmitter;
  12810. /**
  12811. * Called by the GPUParticleSystem to setup the update shader
  12812. * @param effect defines the update shader
  12813. */
  12814. applyToShader(effect: Effect): void;
  12815. /**
  12816. * Returns a string to use to update the GPU particles update shader
  12817. * @returns a string containng the defines string
  12818. */
  12819. getEffectDefines(): string;
  12820. /**
  12821. * Returns the string "SphereParticleEmitter"
  12822. * @returns a string containing the class name
  12823. */
  12824. getClassName(): string;
  12825. /**
  12826. * Serializes the particle system to a JSON object.
  12827. * @returns the JSON object
  12828. */
  12829. serialize(): any;
  12830. /**
  12831. * Parse properties from a JSON object
  12832. * @param serializationObject defines the JSON object
  12833. */
  12834. parse(serializationObject: any): void;
  12835. }
  12836. /**
  12837. * Particle emitter emitting particles from the inside of a sphere.
  12838. * It emits the particles randomly between two vectors.
  12839. */
  12840. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12841. /**
  12842. * The min limit of the emission direction.
  12843. */
  12844. direction1: Vector3;
  12845. /**
  12846. * The max limit of the emission direction.
  12847. */
  12848. direction2: Vector3;
  12849. /**
  12850. * Creates a new instance SphereDirectedParticleEmitter
  12851. * @param radius the radius of the emission sphere (1 by default)
  12852. * @param direction1 the min limit of the emission direction (up vector by default)
  12853. * @param direction2 the max limit of the emission direction (up vector by default)
  12854. */
  12855. constructor(radius?: number,
  12856. /**
  12857. * The min limit of the emission direction.
  12858. */
  12859. direction1?: Vector3,
  12860. /**
  12861. * The max limit of the emission direction.
  12862. */
  12863. direction2?: Vector3);
  12864. /**
  12865. * Called by the particle System when the direction is computed for the created particle.
  12866. * @param worldMatrix is the world matrix of the particle system
  12867. * @param directionToUpdate is the direction vector to update with the result
  12868. * @param particle is the particle we are computed the direction for
  12869. */
  12870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12871. /**
  12872. * Clones the current emitter and returns a copy of it
  12873. * @returns the new emitter
  12874. */
  12875. clone(): SphereDirectedParticleEmitter;
  12876. /**
  12877. * Called by the GPUParticleSystem to setup the update shader
  12878. * @param effect defines the update shader
  12879. */
  12880. applyToShader(effect: Effect): void;
  12881. /**
  12882. * Returns a string to use to update the GPU particles update shader
  12883. * @returns a string containng the defines string
  12884. */
  12885. getEffectDefines(): string;
  12886. /**
  12887. * Returns the string "SphereDirectedParticleEmitter"
  12888. * @returns a string containing the class name
  12889. */
  12890. getClassName(): string;
  12891. /**
  12892. * Serializes the particle system to a JSON object.
  12893. * @returns the JSON object
  12894. */
  12895. serialize(): any;
  12896. /**
  12897. * Parse properties from a JSON object
  12898. * @param serializationObject defines the JSON object
  12899. */
  12900. parse(serializationObject: any): void;
  12901. }
  12902. }
  12903. declare module BABYLON {
  12904. /**
  12905. * Particle emitter emitting particles from a custom list of positions.
  12906. */
  12907. export class CustomParticleEmitter implements IParticleEmitterType {
  12908. /**
  12909. * Gets or sets the position generator that will create the inital position of each particle.
  12910. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12911. */
  12912. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12913. /**
  12914. * Gets or sets the destination generator that will create the final destination of each particle.
  12915. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12916. */
  12917. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12918. /**
  12919. * Creates a new instance CustomParticleEmitter
  12920. */
  12921. constructor();
  12922. /**
  12923. * Called by the particle System when the direction is computed for the created particle.
  12924. * @param worldMatrix is the world matrix of the particle system
  12925. * @param directionToUpdate is the direction vector to update with the result
  12926. * @param particle is the particle we are computed the direction for
  12927. * @param isLocal defines if the direction should be set in local space
  12928. */
  12929. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12930. /**
  12931. * Called by the particle System when the position is computed for the created particle.
  12932. * @param worldMatrix is the world matrix of the particle system
  12933. * @param positionToUpdate is the position vector to update with the result
  12934. * @param particle is the particle we are computed the position for
  12935. * @param isLocal defines if the position should be set in local space
  12936. */
  12937. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12938. /**
  12939. * Clones the current emitter and returns a copy of it
  12940. * @returns the new emitter
  12941. */
  12942. clone(): CustomParticleEmitter;
  12943. /**
  12944. * Called by the GPUParticleSystem to setup the update shader
  12945. * @param effect defines the update shader
  12946. */
  12947. applyToShader(effect: Effect): void;
  12948. /**
  12949. * Returns a string to use to update the GPU particles update shader
  12950. * @returns a string containng the defines string
  12951. */
  12952. getEffectDefines(): string;
  12953. /**
  12954. * Returns the string "PointParticleEmitter"
  12955. * @returns a string containing the class name
  12956. */
  12957. getClassName(): string;
  12958. /**
  12959. * Serializes the particle system to a JSON object.
  12960. * @returns the JSON object
  12961. */
  12962. serialize(): any;
  12963. /**
  12964. * Parse properties from a JSON object
  12965. * @param serializationObject defines the JSON object
  12966. */
  12967. parse(serializationObject: any): void;
  12968. }
  12969. }
  12970. declare module BABYLON {
  12971. /**
  12972. * Particle emitter emitting particles from the inside of a box.
  12973. * It emits the particles randomly between 2 given directions.
  12974. */
  12975. export class MeshParticleEmitter implements IParticleEmitterType {
  12976. private _indices;
  12977. private _positions;
  12978. private _normals;
  12979. private _storedNormal;
  12980. private _mesh;
  12981. /**
  12982. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12983. */
  12984. direction1: Vector3;
  12985. /**
  12986. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12987. */
  12988. direction2: Vector3;
  12989. /**
  12990. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12991. */
  12992. useMeshNormalsForDirection: boolean;
  12993. /** Defines the mesh to use as source */
  12994. get mesh(): Nullable<AbstractMesh>;
  12995. set mesh(value: Nullable<AbstractMesh>);
  12996. /**
  12997. * Creates a new instance MeshParticleEmitter
  12998. * @param mesh defines the mesh to use as source
  12999. */
  13000. constructor(mesh?: Nullable<AbstractMesh>);
  13001. /**
  13002. * Called by the particle System when the direction is computed for the created particle.
  13003. * @param worldMatrix is the world matrix of the particle system
  13004. * @param directionToUpdate is the direction vector to update with the result
  13005. * @param particle is the particle we are computed the direction for
  13006. * @param isLocal defines if the direction should be set in local space
  13007. */
  13008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13009. /**
  13010. * Called by the particle System when the position is computed for the created particle.
  13011. * @param worldMatrix is the world matrix of the particle system
  13012. * @param positionToUpdate is the position vector to update with the result
  13013. * @param particle is the particle we are computed the position for
  13014. * @param isLocal defines if the position should be set in local space
  13015. */
  13016. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13017. /**
  13018. * Clones the current emitter and returns a copy of it
  13019. * @returns the new emitter
  13020. */
  13021. clone(): MeshParticleEmitter;
  13022. /**
  13023. * Called by the GPUParticleSystem to setup the update shader
  13024. * @param effect defines the update shader
  13025. */
  13026. applyToShader(effect: Effect): void;
  13027. /**
  13028. * Returns a string to use to update the GPU particles update shader
  13029. * @returns a string containng the defines string
  13030. */
  13031. getEffectDefines(): string;
  13032. /**
  13033. * Returns the string "BoxParticleEmitter"
  13034. * @returns a string containing the class name
  13035. */
  13036. getClassName(): string;
  13037. /**
  13038. * Serializes the particle system to a JSON object.
  13039. * @returns the JSON object
  13040. */
  13041. serialize(): any;
  13042. /**
  13043. * Parse properties from a JSON object
  13044. * @param serializationObject defines the JSON object
  13045. * @param scene defines the hosting scene
  13046. */
  13047. parse(serializationObject: any, scene: Scene): void;
  13048. }
  13049. }
  13050. declare module BABYLON {
  13051. /**
  13052. * Interface representing a particle system in Babylon.js.
  13053. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13054. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13055. */
  13056. export interface IParticleSystem {
  13057. /**
  13058. * List of animations used by the particle system.
  13059. */
  13060. animations: Animation[];
  13061. /**
  13062. * The id of the Particle system.
  13063. */
  13064. id: string;
  13065. /**
  13066. * The name of the Particle system.
  13067. */
  13068. name: string;
  13069. /**
  13070. * The emitter represents the Mesh or position we are attaching the particle system to.
  13071. */
  13072. emitter: Nullable<AbstractMesh | Vector3>;
  13073. /**
  13074. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13075. */
  13076. isBillboardBased: boolean;
  13077. /**
  13078. * The rendering group used by the Particle system to chose when to render.
  13079. */
  13080. renderingGroupId: number;
  13081. /**
  13082. * The layer mask we are rendering the particles through.
  13083. */
  13084. layerMask: number;
  13085. /**
  13086. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13087. */
  13088. updateSpeed: number;
  13089. /**
  13090. * The amount of time the particle system is running (depends of the overall update speed).
  13091. */
  13092. targetStopDuration: number;
  13093. /**
  13094. * The texture used to render each particle. (this can be a spritesheet)
  13095. */
  13096. particleTexture: Nullable<Texture>;
  13097. /**
  13098. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13099. */
  13100. blendMode: number;
  13101. /**
  13102. * Minimum life time of emitting particles.
  13103. */
  13104. minLifeTime: number;
  13105. /**
  13106. * Maximum life time of emitting particles.
  13107. */
  13108. maxLifeTime: number;
  13109. /**
  13110. * Minimum Size of emitting particles.
  13111. */
  13112. minSize: number;
  13113. /**
  13114. * Maximum Size of emitting particles.
  13115. */
  13116. maxSize: number;
  13117. /**
  13118. * Minimum scale of emitting particles on X axis.
  13119. */
  13120. minScaleX: number;
  13121. /**
  13122. * Maximum scale of emitting particles on X axis.
  13123. */
  13124. maxScaleX: number;
  13125. /**
  13126. * Minimum scale of emitting particles on Y axis.
  13127. */
  13128. minScaleY: number;
  13129. /**
  13130. * Maximum scale of emitting particles on Y axis.
  13131. */
  13132. maxScaleY: number;
  13133. /**
  13134. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13135. */
  13136. color1: Color4;
  13137. /**
  13138. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13139. */
  13140. color2: Color4;
  13141. /**
  13142. * Color the particle will have at the end of its lifetime.
  13143. */
  13144. colorDead: Color4;
  13145. /**
  13146. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13147. */
  13148. emitRate: number;
  13149. /**
  13150. * You can use gravity if you want to give an orientation to your particles.
  13151. */
  13152. gravity: Vector3;
  13153. /**
  13154. * Minimum power of emitting particles.
  13155. */
  13156. minEmitPower: number;
  13157. /**
  13158. * Maximum power of emitting particles.
  13159. */
  13160. maxEmitPower: number;
  13161. /**
  13162. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13163. */
  13164. minAngularSpeed: number;
  13165. /**
  13166. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13167. */
  13168. maxAngularSpeed: number;
  13169. /**
  13170. * Gets or sets the minimal initial rotation in radians.
  13171. */
  13172. minInitialRotation: number;
  13173. /**
  13174. * Gets or sets the maximal initial rotation in radians.
  13175. */
  13176. maxInitialRotation: number;
  13177. /**
  13178. * The particle emitter type defines the emitter used by the particle system.
  13179. * It can be for example box, sphere, or cone...
  13180. */
  13181. particleEmitterType: Nullable<IParticleEmitterType>;
  13182. /**
  13183. * Defines the delay in milliseconds before starting the system (0 by default)
  13184. */
  13185. startDelay: number;
  13186. /**
  13187. * 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
  13188. */
  13189. preWarmCycles: number;
  13190. /**
  13191. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13192. */
  13193. preWarmStepOffset: number;
  13194. /**
  13195. * 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)
  13196. */
  13197. spriteCellChangeSpeed: number;
  13198. /**
  13199. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13200. */
  13201. startSpriteCellID: number;
  13202. /**
  13203. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13204. */
  13205. endSpriteCellID: number;
  13206. /**
  13207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13208. */
  13209. spriteCellWidth: number;
  13210. /**
  13211. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13212. */
  13213. spriteCellHeight: number;
  13214. /**
  13215. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13216. */
  13217. spriteRandomStartCell: boolean;
  13218. /**
  13219. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13220. */
  13221. isAnimationSheetEnabled: boolean;
  13222. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13223. translationPivot: Vector2;
  13224. /**
  13225. * Gets or sets a texture used to add random noise to particle positions
  13226. */
  13227. noiseTexture: Nullable<BaseTexture>;
  13228. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13229. noiseStrength: Vector3;
  13230. /**
  13231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13233. */
  13234. billboardMode: number;
  13235. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13236. limitVelocityDamping: number;
  13237. /**
  13238. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13239. */
  13240. beginAnimationOnStart: boolean;
  13241. /**
  13242. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13243. */
  13244. beginAnimationFrom: number;
  13245. /**
  13246. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13247. */
  13248. beginAnimationTo: number;
  13249. /**
  13250. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13251. */
  13252. beginAnimationLoop: boolean;
  13253. /**
  13254. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13255. */
  13256. disposeOnStop: boolean;
  13257. /**
  13258. * Specifies if the particles are updated in emitter local space or world space
  13259. */
  13260. isLocal: boolean;
  13261. /** Snippet ID if the particle system was created from the snippet server */
  13262. snippetId: string;
  13263. /**
  13264. * Gets the maximum number of particles active at the same time.
  13265. * @returns The max number of active particles.
  13266. */
  13267. getCapacity(): number;
  13268. /**
  13269. * Gets the number of particles active at the same time.
  13270. * @returns The number of active particles.
  13271. */
  13272. getActiveCount(): number;
  13273. /**
  13274. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13275. * @returns True if it has been started, otherwise false.
  13276. */
  13277. isStarted(): boolean;
  13278. /**
  13279. * Animates the particle system for this frame.
  13280. */
  13281. animate(): void;
  13282. /**
  13283. * Renders the particle system in its current state.
  13284. * @returns the current number of particles
  13285. */
  13286. render(): number;
  13287. /**
  13288. * Dispose the particle system and frees its associated resources.
  13289. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13290. */
  13291. dispose(disposeTexture?: boolean): void;
  13292. /**
  13293. * Clones the particle system.
  13294. * @param name The name of the cloned object
  13295. * @param newEmitter The new emitter to use
  13296. * @returns the cloned particle system
  13297. */
  13298. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13299. /**
  13300. * Serializes the particle system to a JSON object
  13301. * @param serializeTexture defines if the texture must be serialized as well
  13302. * @returns the JSON object
  13303. */
  13304. serialize(serializeTexture: boolean): any;
  13305. /**
  13306. * Rebuild the particle system
  13307. */
  13308. rebuild(): void;
  13309. /** Force the system to rebuild all gradients that need to be resync */
  13310. forceRefreshGradients(): void;
  13311. /**
  13312. * Starts the particle system and begins to emit
  13313. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13314. */
  13315. start(delay?: number): void;
  13316. /**
  13317. * Stops the particle system.
  13318. */
  13319. stop(): void;
  13320. /**
  13321. * Remove all active particles
  13322. */
  13323. reset(): void;
  13324. /**
  13325. * Gets a boolean indicating that the system is stopping
  13326. * @returns true if the system is currently stopping
  13327. */
  13328. isStopping(): boolean;
  13329. /**
  13330. * Is this system ready to be used/rendered
  13331. * @return true if the system is ready
  13332. */
  13333. isReady(): boolean;
  13334. /**
  13335. * Returns the string "ParticleSystem"
  13336. * @returns a string containing the class name
  13337. */
  13338. getClassName(): string;
  13339. /**
  13340. * Adds a new color gradient
  13341. * @param gradient defines the gradient to use (between 0 and 1)
  13342. * @param color1 defines the color to affect to the specified gradient
  13343. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13344. * @returns the current particle system
  13345. */
  13346. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13347. /**
  13348. * Remove a specific color gradient
  13349. * @param gradient defines the gradient to remove
  13350. * @returns the current particle system
  13351. */
  13352. removeColorGradient(gradient: number): IParticleSystem;
  13353. /**
  13354. * Adds a new size gradient
  13355. * @param gradient defines the gradient to use (between 0 and 1)
  13356. * @param factor defines the size factor to affect to the specified gradient
  13357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13358. * @returns the current particle system
  13359. */
  13360. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13361. /**
  13362. * Remove a specific size gradient
  13363. * @param gradient defines the gradient to remove
  13364. * @returns the current particle system
  13365. */
  13366. removeSizeGradient(gradient: number): IParticleSystem;
  13367. /**
  13368. * Gets the current list of color gradients.
  13369. * You must use addColorGradient and removeColorGradient to udpate this list
  13370. * @returns the list of color gradients
  13371. */
  13372. getColorGradients(): Nullable<Array<ColorGradient>>;
  13373. /**
  13374. * Gets the current list of size gradients.
  13375. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13376. * @returns the list of size gradients
  13377. */
  13378. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13379. /**
  13380. * Gets the current list of angular speed gradients.
  13381. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13382. * @returns the list of angular speed gradients
  13383. */
  13384. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13385. /**
  13386. * Adds a new angular speed gradient
  13387. * @param gradient defines the gradient to use (between 0 and 1)
  13388. * @param factor defines the angular speed to affect to the specified gradient
  13389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13390. * @returns the current particle system
  13391. */
  13392. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13393. /**
  13394. * Remove a specific angular speed gradient
  13395. * @param gradient defines the gradient to remove
  13396. * @returns the current particle system
  13397. */
  13398. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13399. /**
  13400. * Gets the current list of velocity gradients.
  13401. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13402. * @returns the list of velocity gradients
  13403. */
  13404. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13405. /**
  13406. * Adds a new velocity gradient
  13407. * @param gradient defines the gradient to use (between 0 and 1)
  13408. * @param factor defines the velocity to affect to the specified gradient
  13409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13410. * @returns the current particle system
  13411. */
  13412. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13413. /**
  13414. * Remove a specific velocity gradient
  13415. * @param gradient defines the gradient to remove
  13416. * @returns the current particle system
  13417. */
  13418. removeVelocityGradient(gradient: number): IParticleSystem;
  13419. /**
  13420. * Gets the current list of limit velocity gradients.
  13421. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13422. * @returns the list of limit velocity gradients
  13423. */
  13424. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13425. /**
  13426. * Adds a new limit velocity gradient
  13427. * @param gradient defines the gradient to use (between 0 and 1)
  13428. * @param factor defines the limit velocity to affect to the specified gradient
  13429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13430. * @returns the current particle system
  13431. */
  13432. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13433. /**
  13434. * Remove a specific limit velocity gradient
  13435. * @param gradient defines the gradient to remove
  13436. * @returns the current particle system
  13437. */
  13438. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13439. /**
  13440. * Adds a new drag gradient
  13441. * @param gradient defines the gradient to use (between 0 and 1)
  13442. * @param factor defines the drag to affect to the specified gradient
  13443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13444. * @returns the current particle system
  13445. */
  13446. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13447. /**
  13448. * Remove a specific drag gradient
  13449. * @param gradient defines the gradient to remove
  13450. * @returns the current particle system
  13451. */
  13452. removeDragGradient(gradient: number): IParticleSystem;
  13453. /**
  13454. * Gets the current list of drag gradients.
  13455. * You must use addDragGradient and removeDragGradient to udpate this list
  13456. * @returns the list of drag gradients
  13457. */
  13458. getDragGradients(): Nullable<Array<FactorGradient>>;
  13459. /**
  13460. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13461. * @param gradient defines the gradient to use (between 0 and 1)
  13462. * @param factor defines the emit rate to affect to the specified gradient
  13463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13464. * @returns the current particle system
  13465. */
  13466. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13467. /**
  13468. * Remove a specific emit rate gradient
  13469. * @param gradient defines the gradient to remove
  13470. * @returns the current particle system
  13471. */
  13472. removeEmitRateGradient(gradient: number): IParticleSystem;
  13473. /**
  13474. * Gets the current list of emit rate gradients.
  13475. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13476. * @returns the list of emit rate gradients
  13477. */
  13478. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13479. /**
  13480. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13481. * @param gradient defines the gradient to use (between 0 and 1)
  13482. * @param factor defines the start size to affect to the specified gradient
  13483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13484. * @returns the current particle system
  13485. */
  13486. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13487. /**
  13488. * Remove a specific start size gradient
  13489. * @param gradient defines the gradient to remove
  13490. * @returns the current particle system
  13491. */
  13492. removeStartSizeGradient(gradient: number): IParticleSystem;
  13493. /**
  13494. * Gets the current list of start size gradients.
  13495. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13496. * @returns the list of start size gradients
  13497. */
  13498. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13499. /**
  13500. * Adds a new life time gradient
  13501. * @param gradient defines the gradient to use (between 0 and 1)
  13502. * @param factor defines the life time factor to affect to the specified gradient
  13503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13504. * @returns the current particle system
  13505. */
  13506. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13507. /**
  13508. * Remove a specific life time gradient
  13509. * @param gradient defines the gradient to remove
  13510. * @returns the current particle system
  13511. */
  13512. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13513. /**
  13514. * Gets the current list of life time gradients.
  13515. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13516. * @returns the list of life time gradients
  13517. */
  13518. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13519. /**
  13520. * Gets the current list of color gradients.
  13521. * You must use addColorGradient and removeColorGradient to udpate this list
  13522. * @returns the list of color gradients
  13523. */
  13524. getColorGradients(): Nullable<Array<ColorGradient>>;
  13525. /**
  13526. * Adds a new ramp gradient used to remap particle colors
  13527. * @param gradient defines the gradient to use (between 0 and 1)
  13528. * @param color defines the color to affect to the specified gradient
  13529. * @returns the current particle system
  13530. */
  13531. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13532. /**
  13533. * Gets the current list of ramp gradients.
  13534. * You must use addRampGradient and removeRampGradient to udpate this list
  13535. * @returns the list of ramp gradients
  13536. */
  13537. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13538. /** Gets or sets a boolean indicating that ramp gradients must be used
  13539. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13540. */
  13541. useRampGradients: boolean;
  13542. /**
  13543. * Adds a new color remap gradient
  13544. * @param gradient defines the gradient to use (between 0 and 1)
  13545. * @param min defines the color remap minimal range
  13546. * @param max defines the color remap maximal range
  13547. * @returns the current particle system
  13548. */
  13549. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13550. /**
  13551. * Gets the current list of color remap gradients.
  13552. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13553. * @returns the list of color remap gradients
  13554. */
  13555. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13556. /**
  13557. * Adds a new alpha remap gradient
  13558. * @param gradient defines the gradient to use (between 0 and 1)
  13559. * @param min defines the alpha remap minimal range
  13560. * @param max defines the alpha remap maximal range
  13561. * @returns the current particle system
  13562. */
  13563. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13564. /**
  13565. * Gets the current list of alpha remap gradients.
  13566. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13567. * @returns the list of alpha remap gradients
  13568. */
  13569. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13570. /**
  13571. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13572. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13573. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13574. * @returns the emitter
  13575. */
  13576. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13577. /**
  13578. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13579. * @param radius The radius of the hemisphere to emit from
  13580. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13581. * @returns the emitter
  13582. */
  13583. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13584. /**
  13585. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13586. * @param radius The radius of the sphere to emit from
  13587. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13588. * @returns the emitter
  13589. */
  13590. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13591. /**
  13592. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13593. * @param radius The radius of the sphere to emit from
  13594. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13595. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13596. * @returns the emitter
  13597. */
  13598. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13599. /**
  13600. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13601. * @param radius The radius of the emission cylinder
  13602. * @param height The height of the emission cylinder
  13603. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13604. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13605. * @returns the emitter
  13606. */
  13607. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13608. /**
  13609. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13610. * @param radius The radius of the cylinder to emit from
  13611. * @param height The height of the emission cylinder
  13612. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13615. * @returns the emitter
  13616. */
  13617. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13618. /**
  13619. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13620. * @param radius The radius of the cone to emit from
  13621. * @param angle The base angle of the cone
  13622. * @returns the emitter
  13623. */
  13624. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13625. /**
  13626. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13629. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13630. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13631. * @returns the emitter
  13632. */
  13633. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13634. /**
  13635. * Get hosting scene
  13636. * @returns the scene
  13637. */
  13638. getScene(): Scene;
  13639. }
  13640. }
  13641. declare module BABYLON {
  13642. /**
  13643. * 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.
  13644. * @see https://doc.babylonjs.com/how_to/transformnode
  13645. */
  13646. export class TransformNode extends Node {
  13647. /**
  13648. * Object will not rotate to face the camera
  13649. */
  13650. static BILLBOARDMODE_NONE: number;
  13651. /**
  13652. * Object will rotate to face the camera but only on the x axis
  13653. */
  13654. static BILLBOARDMODE_X: number;
  13655. /**
  13656. * Object will rotate to face the camera but only on the y axis
  13657. */
  13658. static BILLBOARDMODE_Y: number;
  13659. /**
  13660. * Object will rotate to face the camera but only on the z axis
  13661. */
  13662. static BILLBOARDMODE_Z: number;
  13663. /**
  13664. * Object will rotate to face the camera
  13665. */
  13666. static BILLBOARDMODE_ALL: number;
  13667. /**
  13668. * Object will rotate to face the camera's position instead of orientation
  13669. */
  13670. static BILLBOARDMODE_USE_POSITION: number;
  13671. private _forward;
  13672. private _forwardInverted;
  13673. private _up;
  13674. private _right;
  13675. private _rightInverted;
  13676. private _position;
  13677. private _rotation;
  13678. private _rotationQuaternion;
  13679. protected _scaling: Vector3;
  13680. protected _isDirty: boolean;
  13681. private _transformToBoneReferal;
  13682. private _isAbsoluteSynced;
  13683. private _billboardMode;
  13684. /**
  13685. * Gets or sets the billboard mode. Default is 0.
  13686. *
  13687. * | Value | Type | Description |
  13688. * | --- | --- | --- |
  13689. * | 0 | BILLBOARDMODE_NONE | |
  13690. * | 1 | BILLBOARDMODE_X | |
  13691. * | 2 | BILLBOARDMODE_Y | |
  13692. * | 4 | BILLBOARDMODE_Z | |
  13693. * | 7 | BILLBOARDMODE_ALL | |
  13694. *
  13695. */
  13696. get billboardMode(): number;
  13697. set billboardMode(value: number);
  13698. private _preserveParentRotationForBillboard;
  13699. /**
  13700. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13701. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13702. */
  13703. get preserveParentRotationForBillboard(): boolean;
  13704. set preserveParentRotationForBillboard(value: boolean);
  13705. /**
  13706. * 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
  13707. */
  13708. scalingDeterminant: number;
  13709. private _infiniteDistance;
  13710. /**
  13711. * Gets or sets the distance of the object to max, often used by skybox
  13712. */
  13713. get infiniteDistance(): boolean;
  13714. set infiniteDistance(value: boolean);
  13715. /**
  13716. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13717. * By default the system will update normals to compensate
  13718. */
  13719. ignoreNonUniformScaling: boolean;
  13720. /**
  13721. * 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
  13722. */
  13723. reIntegrateRotationIntoRotationQuaternion: boolean;
  13724. /** @hidden */
  13725. _poseMatrix: Nullable<Matrix>;
  13726. /** @hidden */
  13727. _localMatrix: Matrix;
  13728. private _usePivotMatrix;
  13729. private _absolutePosition;
  13730. private _absoluteScaling;
  13731. private _absoluteRotationQuaternion;
  13732. private _pivotMatrix;
  13733. private _pivotMatrixInverse;
  13734. protected _postMultiplyPivotMatrix: boolean;
  13735. protected _isWorldMatrixFrozen: boolean;
  13736. /** @hidden */
  13737. _indexInSceneTransformNodesArray: number;
  13738. /**
  13739. * An event triggered after the world matrix is updated
  13740. */
  13741. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13742. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13743. /**
  13744. * Gets a string identifying the name of the class
  13745. * @returns "TransformNode" string
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13750. */
  13751. get position(): Vector3;
  13752. set position(newPosition: Vector3);
  13753. /**
  13754. * 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)).
  13755. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13756. */
  13757. get rotation(): Vector3;
  13758. set rotation(newRotation: Vector3);
  13759. /**
  13760. * 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)).
  13761. */
  13762. get scaling(): Vector3;
  13763. set scaling(newScaling: Vector3);
  13764. /**
  13765. * 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).
  13766. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13767. */
  13768. get rotationQuaternion(): Nullable<Quaternion>;
  13769. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13770. /**
  13771. * The forward direction of that transform in world space.
  13772. */
  13773. get forward(): Vector3;
  13774. /**
  13775. * The up direction of that transform in world space.
  13776. */
  13777. get up(): Vector3;
  13778. /**
  13779. * The right direction of that transform in world space.
  13780. */
  13781. get right(): Vector3;
  13782. /**
  13783. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13784. * @param matrix the matrix to copy the pose from
  13785. * @returns this TransformNode.
  13786. */
  13787. updatePoseMatrix(matrix: Matrix): TransformNode;
  13788. /**
  13789. * Returns the mesh Pose matrix.
  13790. * @returns the pose matrix
  13791. */
  13792. getPoseMatrix(): Matrix;
  13793. /** @hidden */
  13794. _isSynchronized(): boolean;
  13795. /** @hidden */
  13796. _initCache(): void;
  13797. /**
  13798. * Flag the transform node as dirty (Forcing it to update everything)
  13799. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13800. * @returns this transform node
  13801. */
  13802. markAsDirty(property: string): TransformNode;
  13803. /**
  13804. * Returns the current mesh absolute position.
  13805. * Returns a Vector3.
  13806. */
  13807. get absolutePosition(): Vector3;
  13808. /**
  13809. * Returns the current mesh absolute scaling.
  13810. * Returns a Vector3.
  13811. */
  13812. get absoluteScaling(): Vector3;
  13813. /**
  13814. * Returns the current mesh absolute rotation.
  13815. * Returns a Quaternion.
  13816. */
  13817. get absoluteRotationQuaternion(): Quaternion;
  13818. /**
  13819. * Sets a new matrix to apply before all other transformation
  13820. * @param matrix defines the transform matrix
  13821. * @returns the current TransformNode
  13822. */
  13823. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13824. /**
  13825. * Sets a new pivot matrix to the current node
  13826. * @param matrix defines the new pivot matrix to use
  13827. * @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
  13828. * @returns the current TransformNode
  13829. */
  13830. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13831. /**
  13832. * Returns the mesh pivot matrix.
  13833. * Default : Identity.
  13834. * @returns the matrix
  13835. */
  13836. getPivotMatrix(): Matrix;
  13837. /**
  13838. * Instantiate (when possible) or clone that node with its hierarchy
  13839. * @param newParent defines the new parent to use for the instance (or clone)
  13840. * @param options defines options to configure how copy is done
  13841. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13842. * @returns an instance (or a clone) of the current node with its hiearchy
  13843. */
  13844. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13845. doNotInstantiate: boolean;
  13846. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13847. /**
  13848. * Prevents the World matrix to be computed any longer
  13849. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13850. * @returns the TransformNode.
  13851. */
  13852. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13853. /**
  13854. * Allows back the World matrix computation.
  13855. * @returns the TransformNode.
  13856. */
  13857. unfreezeWorldMatrix(): this;
  13858. /**
  13859. * True if the World matrix has been frozen.
  13860. */
  13861. get isWorldMatrixFrozen(): boolean;
  13862. /**
  13863. * Retuns the mesh absolute position in the World.
  13864. * @returns a Vector3.
  13865. */
  13866. getAbsolutePosition(): Vector3;
  13867. /**
  13868. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13869. * @param absolutePosition the absolute position to set
  13870. * @returns the TransformNode.
  13871. */
  13872. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13873. /**
  13874. * Sets the mesh position in its local space.
  13875. * @param vector3 the position to set in localspace
  13876. * @returns the TransformNode.
  13877. */
  13878. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13879. /**
  13880. * Returns the mesh position in the local space from the current World matrix values.
  13881. * @returns a new Vector3.
  13882. */
  13883. getPositionExpressedInLocalSpace(): Vector3;
  13884. /**
  13885. * Translates the mesh along the passed Vector3 in its local space.
  13886. * @param vector3 the distance to translate in localspace
  13887. * @returns the TransformNode.
  13888. */
  13889. locallyTranslate(vector3: Vector3): TransformNode;
  13890. private static _lookAtVectorCache;
  13891. /**
  13892. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13893. * @param targetPoint the position (must be in same space as current mesh) to look at
  13894. * @param yawCor optional yaw (y-axis) correction in radians
  13895. * @param pitchCor optional pitch (x-axis) correction in radians
  13896. * @param rollCor optional roll (z-axis) correction in radians
  13897. * @param space the choosen space of the target
  13898. * @returns the TransformNode.
  13899. */
  13900. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13901. /**
  13902. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13903. * This Vector3 is expressed in the World space.
  13904. * @param localAxis axis to rotate
  13905. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13906. */
  13907. getDirection(localAxis: Vector3): Vector3;
  13908. /**
  13909. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13910. * localAxis is expressed in the mesh local space.
  13911. * result is computed in the Wordl space from the mesh World matrix.
  13912. * @param localAxis axis to rotate
  13913. * @param result the resulting transformnode
  13914. * @returns this TransformNode.
  13915. */
  13916. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13917. /**
  13918. * Sets this transform node rotation to the given local axis.
  13919. * @param localAxis the axis in local space
  13920. * @param yawCor optional yaw (y-axis) correction in radians
  13921. * @param pitchCor optional pitch (x-axis) correction in radians
  13922. * @param rollCor optional roll (z-axis) correction in radians
  13923. * @returns this TransformNode
  13924. */
  13925. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13926. /**
  13927. * Sets a new pivot point to the current node
  13928. * @param point defines the new pivot point to use
  13929. * @param space defines if the point is in world or local space (local by default)
  13930. * @returns the current TransformNode
  13931. */
  13932. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13933. /**
  13934. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13935. * @returns the pivot point
  13936. */
  13937. getPivotPoint(): Vector3;
  13938. /**
  13939. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13940. * @param result the vector3 to store the result
  13941. * @returns this TransformNode.
  13942. */
  13943. getPivotPointToRef(result: Vector3): TransformNode;
  13944. /**
  13945. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13946. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13947. */
  13948. getAbsolutePivotPoint(): Vector3;
  13949. /**
  13950. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13951. * @param result vector3 to store the result
  13952. * @returns this TransformNode.
  13953. */
  13954. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13955. /**
  13956. * Defines the passed node as the parent of the current node.
  13957. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13958. * @see https://doc.babylonjs.com/how_to/parenting
  13959. * @param node the node ot set as the parent
  13960. * @returns this TransformNode.
  13961. */
  13962. setParent(node: Nullable<Node>): TransformNode;
  13963. private _nonUniformScaling;
  13964. /**
  13965. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13966. */
  13967. get nonUniformScaling(): boolean;
  13968. /** @hidden */
  13969. _updateNonUniformScalingState(value: boolean): boolean;
  13970. /**
  13971. * Attach the current TransformNode to another TransformNode associated with a bone
  13972. * @param bone Bone affecting the TransformNode
  13973. * @param affectedTransformNode TransformNode associated with the bone
  13974. * @returns this object
  13975. */
  13976. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13977. /**
  13978. * Detach the transform node if its associated with a bone
  13979. * @returns this object
  13980. */
  13981. detachFromBone(): TransformNode;
  13982. private static _rotationAxisCache;
  13983. /**
  13984. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13985. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13986. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13987. * The passed axis is also normalized.
  13988. * @param axis the axis to rotate around
  13989. * @param amount the amount to rotate in radians
  13990. * @param space Space to rotate in (Default: local)
  13991. * @returns the TransformNode.
  13992. */
  13993. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13994. /**
  13995. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13996. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13997. * The passed axis is also normalized. .
  13998. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13999. * @param point the point to rotate around
  14000. * @param axis the axis to rotate around
  14001. * @param amount the amount to rotate in radians
  14002. * @returns the TransformNode
  14003. */
  14004. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14005. /**
  14006. * Translates the mesh along the axis vector for the passed distance in the given space.
  14007. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14008. * @param axis the axis to translate in
  14009. * @param distance the distance to translate
  14010. * @param space Space to rotate in (Default: local)
  14011. * @returns the TransformNode.
  14012. */
  14013. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14014. /**
  14015. * Adds a rotation step to the mesh current rotation.
  14016. * x, y, z are Euler angles expressed in radians.
  14017. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14018. * This means this rotation is made in the mesh local space only.
  14019. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14020. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14021. * ```javascript
  14022. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14023. * ```
  14024. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14025. * 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.
  14026. * @param x Rotation to add
  14027. * @param y Rotation to add
  14028. * @param z Rotation to add
  14029. * @returns the TransformNode.
  14030. */
  14031. addRotation(x: number, y: number, z: number): TransformNode;
  14032. /**
  14033. * @hidden
  14034. */
  14035. protected _getEffectiveParent(): Nullable<Node>;
  14036. /**
  14037. * Computes the world matrix of the node
  14038. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14039. * @returns the world matrix
  14040. */
  14041. computeWorldMatrix(force?: boolean): Matrix;
  14042. /**
  14043. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14044. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14045. */
  14046. resetLocalMatrix(independentOfChildren?: boolean): void;
  14047. protected _afterComputeWorldMatrix(): void;
  14048. /**
  14049. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14050. * @param func callback function to add
  14051. *
  14052. * @returns the TransformNode.
  14053. */
  14054. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14055. /**
  14056. * Removes a registered callback function.
  14057. * @param func callback function to remove
  14058. * @returns the TransformNode.
  14059. */
  14060. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14061. /**
  14062. * Gets the position of the current mesh in camera space
  14063. * @param camera defines the camera to use
  14064. * @returns a position
  14065. */
  14066. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14067. /**
  14068. * Returns the distance from the mesh to the active camera
  14069. * @param camera defines the camera to use
  14070. * @returns the distance
  14071. */
  14072. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14073. /**
  14074. * Clone the current transform node
  14075. * @param name Name of the new clone
  14076. * @param newParent New parent for the clone
  14077. * @param doNotCloneChildren Do not clone children hierarchy
  14078. * @returns the new transform node
  14079. */
  14080. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14081. /**
  14082. * Serializes the objects information.
  14083. * @param currentSerializationObject defines the object to serialize in
  14084. * @returns the serialized object
  14085. */
  14086. serialize(currentSerializationObject?: any): any;
  14087. /**
  14088. * Returns a new TransformNode object parsed from the source provided.
  14089. * @param parsedTransformNode is the source.
  14090. * @param scene the scne the object belongs to
  14091. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14092. * @returns a new TransformNode object parsed from the source provided.
  14093. */
  14094. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14095. /**
  14096. * Get all child-transformNodes of this node
  14097. * @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
  14098. * @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
  14099. * @returns an array of TransformNode
  14100. */
  14101. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14102. /**
  14103. * Releases resources associated with this transform node.
  14104. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14105. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14106. */
  14107. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14108. /**
  14109. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14110. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14111. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14112. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14113. * @returns the current mesh
  14114. */
  14115. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14116. private _syncAbsoluteScalingAndRotation;
  14117. }
  14118. }
  14119. declare module BABYLON {
  14120. /**
  14121. * Class used to override all child animations of a given target
  14122. */
  14123. export class AnimationPropertiesOverride {
  14124. /**
  14125. * Gets or sets a value indicating if animation blending must be used
  14126. */
  14127. enableBlending: boolean;
  14128. /**
  14129. * Gets or sets the blending speed to use when enableBlending is true
  14130. */
  14131. blendingSpeed: number;
  14132. /**
  14133. * Gets or sets the default loop mode to use
  14134. */
  14135. loopMode: number;
  14136. }
  14137. }
  14138. declare module BABYLON {
  14139. /**
  14140. * Class used to store bone information
  14141. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14142. */
  14143. export class Bone extends Node {
  14144. /**
  14145. * defines the bone name
  14146. */
  14147. name: string;
  14148. private static _tmpVecs;
  14149. private static _tmpQuat;
  14150. private static _tmpMats;
  14151. /**
  14152. * Gets the list of child bones
  14153. */
  14154. children: Bone[];
  14155. /** Gets the animations associated with this bone */
  14156. animations: Animation[];
  14157. /**
  14158. * Gets or sets bone length
  14159. */
  14160. length: number;
  14161. /**
  14162. * @hidden Internal only
  14163. * Set this value to map this bone to a different index in the transform matrices
  14164. * Set this value to -1 to exclude the bone from the transform matrices
  14165. */
  14166. _index: Nullable<number>;
  14167. private _skeleton;
  14168. private _localMatrix;
  14169. private _restPose;
  14170. private _baseMatrix;
  14171. private _absoluteTransform;
  14172. private _invertedAbsoluteTransform;
  14173. private _parent;
  14174. private _scalingDeterminant;
  14175. private _worldTransform;
  14176. private _localScaling;
  14177. private _localRotation;
  14178. private _localPosition;
  14179. private _needToDecompose;
  14180. private _needToCompose;
  14181. /** @hidden */
  14182. _linkedTransformNode: Nullable<TransformNode>;
  14183. /** @hidden */
  14184. _waitingTransformNodeId: Nullable<string>;
  14185. /** @hidden */
  14186. get _matrix(): Matrix;
  14187. /** @hidden */
  14188. set _matrix(value: Matrix);
  14189. /**
  14190. * Create a new bone
  14191. * @param name defines the bone name
  14192. * @param skeleton defines the parent skeleton
  14193. * @param parentBone defines the parent (can be null if the bone is the root)
  14194. * @param localMatrix defines the local matrix
  14195. * @param restPose defines the rest pose matrix
  14196. * @param baseMatrix defines the base matrix
  14197. * @param index defines index of the bone in the hiearchy
  14198. */
  14199. constructor(
  14200. /**
  14201. * defines the bone name
  14202. */
  14203. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14204. /**
  14205. * Gets the current object class name.
  14206. * @return the class name
  14207. */
  14208. getClassName(): string;
  14209. /**
  14210. * Gets the parent skeleton
  14211. * @returns a skeleton
  14212. */
  14213. getSkeleton(): Skeleton;
  14214. /**
  14215. * Gets parent bone
  14216. * @returns a bone or null if the bone is the root of the bone hierarchy
  14217. */
  14218. getParent(): Nullable<Bone>;
  14219. /**
  14220. * Returns an array containing the root bones
  14221. * @returns an array containing the root bones
  14222. */
  14223. getChildren(): Array<Bone>;
  14224. /**
  14225. * Gets the node index in matrix array generated for rendering
  14226. * @returns the node index
  14227. */
  14228. getIndex(): number;
  14229. /**
  14230. * Sets the parent bone
  14231. * @param parent defines the parent (can be null if the bone is the root)
  14232. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14233. */
  14234. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14235. /**
  14236. * Gets the local matrix
  14237. * @returns a matrix
  14238. */
  14239. getLocalMatrix(): Matrix;
  14240. /**
  14241. * Gets the base matrix (initial matrix which remains unchanged)
  14242. * @returns a matrix
  14243. */
  14244. getBaseMatrix(): Matrix;
  14245. /**
  14246. * Gets the rest pose matrix
  14247. * @returns a matrix
  14248. */
  14249. getRestPose(): Matrix;
  14250. /**
  14251. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14252. */
  14253. getWorldMatrix(): Matrix;
  14254. /**
  14255. * Sets the local matrix to rest pose matrix
  14256. */
  14257. returnToRest(): void;
  14258. /**
  14259. * Gets the inverse of the absolute transform matrix.
  14260. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14261. * @returns a matrix
  14262. */
  14263. getInvertedAbsoluteTransform(): Matrix;
  14264. /**
  14265. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14266. * @returns a matrix
  14267. */
  14268. getAbsoluteTransform(): Matrix;
  14269. /**
  14270. * Links with the given transform node.
  14271. * The local matrix of this bone is copied from the transform node every frame.
  14272. * @param transformNode defines the transform node to link to
  14273. */
  14274. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14275. /**
  14276. * Gets the node used to drive the bone's transformation
  14277. * @returns a transform node or null
  14278. */
  14279. getTransformNode(): Nullable<TransformNode>;
  14280. /** Gets or sets current position (in local space) */
  14281. get position(): Vector3;
  14282. set position(newPosition: Vector3);
  14283. /** Gets or sets current rotation (in local space) */
  14284. get rotation(): Vector3;
  14285. set rotation(newRotation: Vector3);
  14286. /** Gets or sets current rotation quaternion (in local space) */
  14287. get rotationQuaternion(): Quaternion;
  14288. set rotationQuaternion(newRotation: Quaternion);
  14289. /** Gets or sets current scaling (in local space) */
  14290. get scaling(): Vector3;
  14291. set scaling(newScaling: Vector3);
  14292. /**
  14293. * Gets the animation properties override
  14294. */
  14295. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14296. private _decompose;
  14297. private _compose;
  14298. /**
  14299. * Update the base and local matrices
  14300. * @param matrix defines the new base or local matrix
  14301. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14302. * @param updateLocalMatrix defines if the local matrix should be updated
  14303. */
  14304. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14305. /** @hidden */
  14306. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14307. /**
  14308. * Flag the bone as dirty (Forcing it to update everything)
  14309. */
  14310. markAsDirty(): void;
  14311. /** @hidden */
  14312. _markAsDirtyAndCompose(): void;
  14313. private _markAsDirtyAndDecompose;
  14314. /**
  14315. * Translate the bone in local or world space
  14316. * @param vec The amount to translate the bone
  14317. * @param space The space that the translation is in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. */
  14320. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14321. /**
  14322. * Set the postion of the bone in local or world space
  14323. * @param position The position to set the bone
  14324. * @param space The space that the position is in
  14325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14326. */
  14327. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14328. /**
  14329. * Set the absolute position of the bone (world space)
  14330. * @param position The position to set the bone
  14331. * @param mesh The mesh that this bone is attached to
  14332. */
  14333. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14334. /**
  14335. * Scale the bone on the x, y and z axes (in local space)
  14336. * @param x The amount to scale the bone on the x axis
  14337. * @param y The amount to scale the bone on the y axis
  14338. * @param z The amount to scale the bone on the z axis
  14339. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14340. */
  14341. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14342. /**
  14343. * Set the bone scaling in local space
  14344. * @param scale defines the scaling vector
  14345. */
  14346. setScale(scale: Vector3): void;
  14347. /**
  14348. * Gets the current scaling in local space
  14349. * @returns the current scaling vector
  14350. */
  14351. getScale(): Vector3;
  14352. /**
  14353. * Gets the current scaling in local space and stores it in a target vector
  14354. * @param result defines the target vector
  14355. */
  14356. getScaleToRef(result: Vector3): void;
  14357. /**
  14358. * Set the yaw, pitch, and roll of the bone in local or world space
  14359. * @param yaw The rotation of the bone on the y axis
  14360. * @param pitch The rotation of the bone on the x axis
  14361. * @param roll The rotation of the bone on the z axis
  14362. * @param space The space that the axes of rotation are in
  14363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14364. */
  14365. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14366. /**
  14367. * Add a rotation to the bone on an axis in local or world space
  14368. * @param axis The axis to rotate the bone on
  14369. * @param amount The amount to rotate the bone
  14370. * @param space The space that the axis is in
  14371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14372. */
  14373. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14374. /**
  14375. * Set the rotation of the bone to a particular axis angle in local or world space
  14376. * @param axis The axis to rotate the bone on
  14377. * @param angle The angle that the bone should be rotated to
  14378. * @param space The space that the axis is in
  14379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14380. */
  14381. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14382. /**
  14383. * Set the euler rotation of the bone in local of world space
  14384. * @param rotation The euler rotation that the bone should be set to
  14385. * @param space The space that the rotation is in
  14386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14387. */
  14388. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14389. /**
  14390. * Set the quaternion rotation of the bone in local of world space
  14391. * @param quat The quaternion rotation that the bone should be set to
  14392. * @param space The space that the rotation is in
  14393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14394. */
  14395. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14396. /**
  14397. * Set the rotation matrix of the bone in local of world space
  14398. * @param rotMat The rotation matrix that the bone should be set to
  14399. * @param space The space that the rotation is in
  14400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14401. */
  14402. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14403. private _rotateWithMatrix;
  14404. private _getNegativeRotationToRef;
  14405. /**
  14406. * Get the position of the bone in local or world space
  14407. * @param space The space that the returned position is in
  14408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14409. * @returns The position of the bone
  14410. */
  14411. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14412. /**
  14413. * Copy the position of the bone to a vector3 in local or world space
  14414. * @param space The space that the returned position is in
  14415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14416. * @param result The vector3 to copy the position to
  14417. */
  14418. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14419. /**
  14420. * Get the absolute position of the bone (world space)
  14421. * @param mesh The mesh that this bone is attached to
  14422. * @returns The absolute position of the bone
  14423. */
  14424. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14425. /**
  14426. * Copy the absolute position of the bone (world space) to the result param
  14427. * @param mesh The mesh that this bone is attached to
  14428. * @param result The vector3 to copy the absolute position to
  14429. */
  14430. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14431. /**
  14432. * Compute the absolute transforms of this bone and its children
  14433. */
  14434. computeAbsoluteTransforms(): void;
  14435. /**
  14436. * Get the world direction from an axis that is in the local space of the bone
  14437. * @param localAxis The local direction that is used to compute the world direction
  14438. * @param mesh The mesh that this bone is attached to
  14439. * @returns The world direction
  14440. */
  14441. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14442. /**
  14443. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14444. * @param localAxis The local direction that is used to compute the world direction
  14445. * @param mesh The mesh that this bone is attached to
  14446. * @param result The vector3 that the world direction will be copied to
  14447. */
  14448. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14449. /**
  14450. * Get the euler rotation of the bone in local or world space
  14451. * @param space The space that the rotation should be in
  14452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14453. * @returns The euler rotation
  14454. */
  14455. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14456. /**
  14457. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14458. * @param space The space that the rotation should be in
  14459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14460. * @param result The vector3 that the rotation should be copied to
  14461. */
  14462. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14463. /**
  14464. * Get the quaternion rotation of the bone in either local or world space
  14465. * @param space The space that the rotation should be in
  14466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14467. * @returns The quaternion rotation
  14468. */
  14469. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14470. /**
  14471. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14472. * @param space The space that the rotation should be in
  14473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14474. * @param result The quaternion that the rotation should be copied to
  14475. */
  14476. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14477. /**
  14478. * Get the rotation matrix of the bone in local or world space
  14479. * @param space The space that the rotation should be in
  14480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14481. * @returns The rotation matrix
  14482. */
  14483. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14484. /**
  14485. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14486. * @param space The space that the rotation should be in
  14487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14488. * @param result The quaternion that the rotation should be copied to
  14489. */
  14490. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14491. /**
  14492. * Get the world position of a point that is in the local space of the bone
  14493. * @param position The local position
  14494. * @param mesh The mesh that this bone is attached to
  14495. * @returns The world position
  14496. */
  14497. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14498. /**
  14499. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14500. * @param position The local position
  14501. * @param mesh The mesh that this bone is attached to
  14502. * @param result The vector3 that the world position should be copied to
  14503. */
  14504. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14505. /**
  14506. * Get the local position of a point that is in world space
  14507. * @param position The world position
  14508. * @param mesh The mesh that this bone is attached to
  14509. * @returns The local position
  14510. */
  14511. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14512. /**
  14513. * Get the local position of a point that is in world space and copy it to the result param
  14514. * @param position The world position
  14515. * @param mesh The mesh that this bone is attached to
  14516. * @param result The vector3 that the local position should be copied to
  14517. */
  14518. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14519. }
  14520. }
  14521. declare module BABYLON {
  14522. /**
  14523. * Defines a runtime animation
  14524. */
  14525. export class RuntimeAnimation {
  14526. private _events;
  14527. /**
  14528. * The current frame of the runtime animation
  14529. */
  14530. private _currentFrame;
  14531. /**
  14532. * The animation used by the runtime animation
  14533. */
  14534. private _animation;
  14535. /**
  14536. * The target of the runtime animation
  14537. */
  14538. private _target;
  14539. /**
  14540. * The initiating animatable
  14541. */
  14542. private _host;
  14543. /**
  14544. * The original value of the runtime animation
  14545. */
  14546. private _originalValue;
  14547. /**
  14548. * The original blend value of the runtime animation
  14549. */
  14550. private _originalBlendValue;
  14551. /**
  14552. * The offsets cache of the runtime animation
  14553. */
  14554. private _offsetsCache;
  14555. /**
  14556. * The high limits cache of the runtime animation
  14557. */
  14558. private _highLimitsCache;
  14559. /**
  14560. * Specifies if the runtime animation has been stopped
  14561. */
  14562. private _stopped;
  14563. /**
  14564. * The blending factor of the runtime animation
  14565. */
  14566. private _blendingFactor;
  14567. /**
  14568. * The BabylonJS scene
  14569. */
  14570. private _scene;
  14571. /**
  14572. * The current value of the runtime animation
  14573. */
  14574. private _currentValue;
  14575. /** @hidden */
  14576. _animationState: _IAnimationState;
  14577. /**
  14578. * The active target of the runtime animation
  14579. */
  14580. private _activeTargets;
  14581. private _currentActiveTarget;
  14582. private _directTarget;
  14583. /**
  14584. * The target path of the runtime animation
  14585. */
  14586. private _targetPath;
  14587. /**
  14588. * The weight of the runtime animation
  14589. */
  14590. private _weight;
  14591. /**
  14592. * The ratio offset of the runtime animation
  14593. */
  14594. private _ratioOffset;
  14595. /**
  14596. * The previous delay of the runtime animation
  14597. */
  14598. private _previousDelay;
  14599. /**
  14600. * The previous ratio of the runtime animation
  14601. */
  14602. private _previousRatio;
  14603. private _enableBlending;
  14604. private _keys;
  14605. private _minFrame;
  14606. private _maxFrame;
  14607. private _minValue;
  14608. private _maxValue;
  14609. private _targetIsArray;
  14610. /**
  14611. * Gets the current frame of the runtime animation
  14612. */
  14613. get currentFrame(): number;
  14614. /**
  14615. * Gets the weight of the runtime animation
  14616. */
  14617. get weight(): number;
  14618. /**
  14619. * Gets the current value of the runtime animation
  14620. */
  14621. get currentValue(): any;
  14622. /**
  14623. * Gets the target path of the runtime animation
  14624. */
  14625. get targetPath(): string;
  14626. /**
  14627. * Gets the actual target of the runtime animation
  14628. */
  14629. get target(): any;
  14630. /**
  14631. * Gets the additive state of the runtime animation
  14632. */
  14633. get isAdditive(): boolean;
  14634. /** @hidden */
  14635. _onLoop: () => void;
  14636. /**
  14637. * Create a new RuntimeAnimation object
  14638. * @param target defines the target of the animation
  14639. * @param animation defines the source animation object
  14640. * @param scene defines the hosting scene
  14641. * @param host defines the initiating Animatable
  14642. */
  14643. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14644. private _preparePath;
  14645. /**
  14646. * Gets the animation from the runtime animation
  14647. */
  14648. get animation(): Animation;
  14649. /**
  14650. * Resets the runtime animation to the beginning
  14651. * @param restoreOriginal defines whether to restore the target property to the original value
  14652. */
  14653. reset(restoreOriginal?: boolean): void;
  14654. /**
  14655. * Specifies if the runtime animation is stopped
  14656. * @returns Boolean specifying if the runtime animation is stopped
  14657. */
  14658. isStopped(): boolean;
  14659. /**
  14660. * Disposes of the runtime animation
  14661. */
  14662. dispose(): void;
  14663. /**
  14664. * Apply the interpolated value to the target
  14665. * @param currentValue defines the value computed by the animation
  14666. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14667. */
  14668. setValue(currentValue: any, weight: number): void;
  14669. private _getOriginalValues;
  14670. private _setValue;
  14671. /**
  14672. * Gets the loop pmode of the runtime animation
  14673. * @returns Loop Mode
  14674. */
  14675. private _getCorrectLoopMode;
  14676. /**
  14677. * Move the current animation to a given frame
  14678. * @param frame defines the frame to move to
  14679. */
  14680. goToFrame(frame: number): void;
  14681. /**
  14682. * @hidden Internal use only
  14683. */
  14684. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14685. /**
  14686. * Execute the current animation
  14687. * @param delay defines the delay to add to the current frame
  14688. * @param from defines the lower bound of the animation range
  14689. * @param to defines the upper bound of the animation range
  14690. * @param loop defines if the current animation must loop
  14691. * @param speedRatio defines the current speed ratio
  14692. * @param weight defines the weight of the animation (default is -1 so no weight)
  14693. * @param onLoop optional callback called when animation loops
  14694. * @returns a boolean indicating if the animation is running
  14695. */
  14696. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14697. }
  14698. }
  14699. declare module BABYLON {
  14700. /**
  14701. * Class used to store an actual running animation
  14702. */
  14703. export class Animatable {
  14704. /** defines the target object */
  14705. target: any;
  14706. /** defines the starting frame number (default is 0) */
  14707. fromFrame: number;
  14708. /** defines the ending frame number (default is 100) */
  14709. toFrame: number;
  14710. /** defines if the animation must loop (default is false) */
  14711. loopAnimation: boolean;
  14712. /** defines a callback to call when animation ends if it is not looping */
  14713. onAnimationEnd?: (() => void) | null | undefined;
  14714. /** defines a callback to call when animation loops */
  14715. onAnimationLoop?: (() => void) | null | undefined;
  14716. /** defines whether the animation should be evaluated additively */
  14717. isAdditive: boolean;
  14718. private _localDelayOffset;
  14719. private _pausedDelay;
  14720. private _runtimeAnimations;
  14721. private _paused;
  14722. private _scene;
  14723. private _speedRatio;
  14724. private _weight;
  14725. private _syncRoot;
  14726. /**
  14727. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14728. * This will only apply for non looping animation (default is true)
  14729. */
  14730. disposeOnEnd: boolean;
  14731. /**
  14732. * Gets a boolean indicating if the animation has started
  14733. */
  14734. animationStarted: boolean;
  14735. /**
  14736. * Observer raised when the animation ends
  14737. */
  14738. onAnimationEndObservable: Observable<Animatable>;
  14739. /**
  14740. * Observer raised when the animation loops
  14741. */
  14742. onAnimationLoopObservable: Observable<Animatable>;
  14743. /**
  14744. * Gets the root Animatable used to synchronize and normalize animations
  14745. */
  14746. get syncRoot(): Nullable<Animatable>;
  14747. /**
  14748. * Gets the current frame of the first RuntimeAnimation
  14749. * Used to synchronize Animatables
  14750. */
  14751. get masterFrame(): number;
  14752. /**
  14753. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14754. */
  14755. get weight(): number;
  14756. set weight(value: number);
  14757. /**
  14758. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14759. */
  14760. get speedRatio(): number;
  14761. set speedRatio(value: number);
  14762. /**
  14763. * Creates a new Animatable
  14764. * @param scene defines the hosting scene
  14765. * @param target defines the target object
  14766. * @param fromFrame defines the starting frame number (default is 0)
  14767. * @param toFrame defines the ending frame number (default is 100)
  14768. * @param loopAnimation defines if the animation must loop (default is false)
  14769. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14770. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14771. * @param animations defines a group of animation to add to the new Animatable
  14772. * @param onAnimationLoop defines a callback to call when animation loops
  14773. * @param isAdditive defines whether the animation should be evaluated additively
  14774. */
  14775. constructor(scene: Scene,
  14776. /** defines the target object */
  14777. target: any,
  14778. /** defines the starting frame number (default is 0) */
  14779. fromFrame?: number,
  14780. /** defines the ending frame number (default is 100) */
  14781. toFrame?: number,
  14782. /** defines if the animation must loop (default is false) */
  14783. loopAnimation?: boolean, speedRatio?: number,
  14784. /** defines a callback to call when animation ends if it is not looping */
  14785. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14786. /** defines a callback to call when animation loops */
  14787. onAnimationLoop?: (() => void) | null | undefined,
  14788. /** defines whether the animation should be evaluated additively */
  14789. isAdditive?: boolean);
  14790. /**
  14791. * Synchronize and normalize current Animatable with a source Animatable
  14792. * This is useful when using animation weights and when animations are not of the same length
  14793. * @param root defines the root Animatable to synchronize with
  14794. * @returns the current Animatable
  14795. */
  14796. syncWith(root: Animatable): Animatable;
  14797. /**
  14798. * Gets the list of runtime animations
  14799. * @returns an array of RuntimeAnimation
  14800. */
  14801. getAnimations(): RuntimeAnimation[];
  14802. /**
  14803. * Adds more animations to the current animatable
  14804. * @param target defines the target of the animations
  14805. * @param animations defines the new animations to add
  14806. */
  14807. appendAnimations(target: any, animations: Animation[]): void;
  14808. /**
  14809. * Gets the source animation for a specific property
  14810. * @param property defines the propertyu to look for
  14811. * @returns null or the source animation for the given property
  14812. */
  14813. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14814. /**
  14815. * Gets the runtime animation for a specific property
  14816. * @param property defines the propertyu to look for
  14817. * @returns null or the runtime animation for the given property
  14818. */
  14819. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14820. /**
  14821. * Resets the animatable to its original state
  14822. */
  14823. reset(): void;
  14824. /**
  14825. * Allows the animatable to blend with current running animations
  14826. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14827. * @param blendingSpeed defines the blending speed to use
  14828. */
  14829. enableBlending(blendingSpeed: number): void;
  14830. /**
  14831. * Disable animation blending
  14832. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14833. */
  14834. disableBlending(): void;
  14835. /**
  14836. * Jump directly to a given frame
  14837. * @param frame defines the frame to jump to
  14838. */
  14839. goToFrame(frame: number): void;
  14840. /**
  14841. * Pause the animation
  14842. */
  14843. pause(): void;
  14844. /**
  14845. * Restart the animation
  14846. */
  14847. restart(): void;
  14848. private _raiseOnAnimationEnd;
  14849. /**
  14850. * Stop and delete the current animation
  14851. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14852. * @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)
  14853. */
  14854. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14855. /**
  14856. * Wait asynchronously for the animation to end
  14857. * @returns a promise which will be fullfilled when the animation ends
  14858. */
  14859. waitAsync(): Promise<Animatable>;
  14860. /** @hidden */
  14861. _animate(delay: number): boolean;
  14862. }
  14863. interface Scene {
  14864. /** @hidden */
  14865. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14866. /** @hidden */
  14867. _processLateAnimationBindingsForMatrices(holder: {
  14868. totalWeight: number;
  14869. totalAdditiveWeight: number;
  14870. animations: RuntimeAnimation[];
  14871. additiveAnimations: RuntimeAnimation[];
  14872. originalValue: Matrix;
  14873. }): any;
  14874. /** @hidden */
  14875. _processLateAnimationBindingsForQuaternions(holder: {
  14876. totalWeight: number;
  14877. totalAdditiveWeight: number;
  14878. animations: RuntimeAnimation[];
  14879. additiveAnimations: RuntimeAnimation[];
  14880. originalValue: Quaternion;
  14881. }, refQuaternion: Quaternion): Quaternion;
  14882. /** @hidden */
  14883. _processLateAnimationBindings(): void;
  14884. /**
  14885. * Will start the animation sequence of a given target
  14886. * @param target defines the target
  14887. * @param from defines from which frame should animation start
  14888. * @param to defines until which frame should animation run.
  14889. * @param weight defines the weight to apply to the animation (1.0 by default)
  14890. * @param loop defines if the animation loops
  14891. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14892. * @param onAnimationEnd defines the function to be executed when the animation ends
  14893. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14894. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14895. * @param onAnimationLoop defines the callback to call when an animation loops
  14896. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14897. * @returns the animatable object created for this animation
  14898. */
  14899. 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;
  14900. /**
  14901. * Will start the animation sequence of a given target
  14902. * @param target defines the target
  14903. * @param from defines from which frame should animation start
  14904. * @param to defines until which frame should animation run.
  14905. * @param loop defines if the animation loops
  14906. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14907. * @param onAnimationEnd defines the function to be executed when the animation ends
  14908. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14909. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14910. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14911. * @param onAnimationLoop defines the callback to call when an animation loops
  14912. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14913. * @returns the animatable object created for this animation
  14914. */
  14915. 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;
  14916. /**
  14917. * Will start the animation sequence of a given target and its hierarchy
  14918. * @param target defines the target
  14919. * @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.
  14920. * @param from defines from which frame should animation start
  14921. * @param to defines until which frame should animation run.
  14922. * @param loop defines if the animation loops
  14923. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14924. * @param onAnimationEnd defines the function to be executed when the animation ends
  14925. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14926. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14927. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14928. * @param onAnimationLoop defines the callback to call when an animation loops
  14929. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14930. * @returns the list of created animatables
  14931. */
  14932. 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[];
  14933. /**
  14934. * Begin a new animation on a given node
  14935. * @param target defines the target where the animation will take place
  14936. * @param animations defines the list of animations to start
  14937. * @param from defines the initial value
  14938. * @param to defines the final value
  14939. * @param loop defines if you want animation to loop (off by default)
  14940. * @param speedRatio defines the speed ratio to apply to all animations
  14941. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14942. * @param onAnimationLoop defines the callback to call when an animation loops
  14943. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14944. * @returns the list of created animatables
  14945. */
  14946. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14947. /**
  14948. * Begin a new animation on a given node and its hierarchy
  14949. * @param target defines the root node where the animation will take place
  14950. * @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.
  14951. * @param animations defines the list of animations to start
  14952. * @param from defines the initial value
  14953. * @param to defines the final value
  14954. * @param loop defines if you want animation to loop (off by default)
  14955. * @param speedRatio defines the speed ratio to apply to all animations
  14956. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14957. * @param onAnimationLoop defines the callback to call when an animation loops
  14958. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14959. * @returns the list of animatables created for all nodes
  14960. */
  14961. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14962. /**
  14963. * Gets the animatable associated with a specific target
  14964. * @param target defines the target of the animatable
  14965. * @returns the required animatable if found
  14966. */
  14967. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14968. /**
  14969. * Gets all animatables associated with a given target
  14970. * @param target defines the target to look animatables for
  14971. * @returns an array of Animatables
  14972. */
  14973. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14974. /**
  14975. * Stops and removes all animations that have been applied to the scene
  14976. */
  14977. stopAllAnimations(): void;
  14978. /**
  14979. * Gets the current delta time used by animation engine
  14980. */
  14981. deltaTime: number;
  14982. }
  14983. interface Bone {
  14984. /**
  14985. * Copy an animation range from another bone
  14986. * @param source defines the source bone
  14987. * @param rangeName defines the range name to copy
  14988. * @param frameOffset defines the frame offset
  14989. * @param rescaleAsRequired defines if rescaling must be applied if required
  14990. * @param skelDimensionsRatio defines the scaling ratio
  14991. * @returns true if operation was successful
  14992. */
  14993. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14994. }
  14995. }
  14996. declare module BABYLON {
  14997. /**
  14998. * Class used to handle skinning animations
  14999. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15000. */
  15001. export class Skeleton implements IAnimatable {
  15002. /** defines the skeleton name */
  15003. name: string;
  15004. /** defines the skeleton Id */
  15005. id: string;
  15006. /**
  15007. * Defines the list of child bones
  15008. */
  15009. bones: Bone[];
  15010. /**
  15011. * Defines an estimate of the dimension of the skeleton at rest
  15012. */
  15013. dimensionsAtRest: Vector3;
  15014. /**
  15015. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15016. */
  15017. needInitialSkinMatrix: boolean;
  15018. /**
  15019. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15020. */
  15021. overrideMesh: Nullable<AbstractMesh>;
  15022. /**
  15023. * Gets the list of animations attached to this skeleton
  15024. */
  15025. animations: Array<Animation>;
  15026. private _scene;
  15027. private _isDirty;
  15028. private _transformMatrices;
  15029. private _transformMatrixTexture;
  15030. private _meshesWithPoseMatrix;
  15031. private _animatables;
  15032. private _identity;
  15033. private _synchronizedWithMesh;
  15034. private _ranges;
  15035. private _lastAbsoluteTransformsUpdateId;
  15036. private _canUseTextureForBones;
  15037. private _uniqueId;
  15038. /** @hidden */
  15039. _numBonesWithLinkedTransformNode: number;
  15040. /** @hidden */
  15041. _hasWaitingData: Nullable<boolean>;
  15042. /**
  15043. * Specifies if the skeleton should be serialized
  15044. */
  15045. doNotSerialize: boolean;
  15046. private _useTextureToStoreBoneMatrices;
  15047. /**
  15048. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15049. * Please note that this option is not available if the hardware does not support it
  15050. */
  15051. get useTextureToStoreBoneMatrices(): boolean;
  15052. set useTextureToStoreBoneMatrices(value: boolean);
  15053. private _animationPropertiesOverride;
  15054. /**
  15055. * Gets or sets the animation properties override
  15056. */
  15057. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15058. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15059. /**
  15060. * List of inspectable custom properties (used by the Inspector)
  15061. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15062. */
  15063. inspectableCustomProperties: IInspectable[];
  15064. /**
  15065. * An observable triggered before computing the skeleton's matrices
  15066. */
  15067. onBeforeComputeObservable: Observable<Skeleton>;
  15068. /**
  15069. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15070. */
  15071. get isUsingTextureForMatrices(): boolean;
  15072. /**
  15073. * Gets the unique ID of this skeleton
  15074. */
  15075. get uniqueId(): number;
  15076. /**
  15077. * Creates a new skeleton
  15078. * @param name defines the skeleton name
  15079. * @param id defines the skeleton Id
  15080. * @param scene defines the hosting scene
  15081. */
  15082. constructor(
  15083. /** defines the skeleton name */
  15084. name: string,
  15085. /** defines the skeleton Id */
  15086. id: string, scene: Scene);
  15087. /**
  15088. * Gets the current object class name.
  15089. * @return the class name
  15090. */
  15091. getClassName(): string;
  15092. /**
  15093. * Returns an array containing the root bones
  15094. * @returns an array containing the root bones
  15095. */
  15096. getChildren(): Array<Bone>;
  15097. /**
  15098. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15099. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15100. * @returns a Float32Array containing matrices data
  15101. */
  15102. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15103. /**
  15104. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15105. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15106. * @returns a raw texture containing the data
  15107. */
  15108. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15109. /**
  15110. * Gets the current hosting scene
  15111. * @returns a scene object
  15112. */
  15113. getScene(): Scene;
  15114. /**
  15115. * Gets a string representing the current skeleton data
  15116. * @param fullDetails defines a boolean indicating if we want a verbose version
  15117. * @returns a string representing the current skeleton data
  15118. */
  15119. toString(fullDetails?: boolean): string;
  15120. /**
  15121. * Get bone's index searching by name
  15122. * @param name defines bone's name to search for
  15123. * @return the indice of the bone. Returns -1 if not found
  15124. */
  15125. getBoneIndexByName(name: string): number;
  15126. /**
  15127. * Creater a new animation range
  15128. * @param name defines the name of the range
  15129. * @param from defines the start key
  15130. * @param to defines the end key
  15131. */
  15132. createAnimationRange(name: string, from: number, to: number): void;
  15133. /**
  15134. * Delete a specific animation range
  15135. * @param name defines the name of the range
  15136. * @param deleteFrames defines if frames must be removed as well
  15137. */
  15138. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15139. /**
  15140. * Gets a specific animation range
  15141. * @param name defines the name of the range to look for
  15142. * @returns the requested animation range or null if not found
  15143. */
  15144. getAnimationRange(name: string): Nullable<AnimationRange>;
  15145. /**
  15146. * Gets the list of all animation ranges defined on this skeleton
  15147. * @returns an array
  15148. */
  15149. getAnimationRanges(): Nullable<AnimationRange>[];
  15150. /**
  15151. * Copy animation range from a source skeleton.
  15152. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15153. * @param source defines the source skeleton
  15154. * @param name defines the name of the range to copy
  15155. * @param rescaleAsRequired defines if rescaling must be applied if required
  15156. * @returns true if operation was successful
  15157. */
  15158. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15159. /**
  15160. * Forces the skeleton to go to rest pose
  15161. */
  15162. returnToRest(): void;
  15163. private _getHighestAnimationFrame;
  15164. /**
  15165. * Begin a specific animation range
  15166. * @param name defines the name of the range to start
  15167. * @param loop defines if looping must be turned on (false by default)
  15168. * @param speedRatio defines the speed ratio to apply (1 by default)
  15169. * @param onAnimationEnd defines a callback which will be called when animation will end
  15170. * @returns a new animatable
  15171. */
  15172. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15173. /**
  15174. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15175. * @param skeleton defines the Skeleton containing the animation range to convert
  15176. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15177. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15178. * @returns the original skeleton
  15179. */
  15180. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15181. /** @hidden */
  15182. _markAsDirty(): void;
  15183. /** @hidden */
  15184. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15185. /** @hidden */
  15186. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15187. private _computeTransformMatrices;
  15188. /**
  15189. * Build all resources required to render a skeleton
  15190. */
  15191. prepare(): void;
  15192. /**
  15193. * Gets the list of animatables currently running for this skeleton
  15194. * @returns an array of animatables
  15195. */
  15196. getAnimatables(): IAnimatable[];
  15197. /**
  15198. * Clone the current skeleton
  15199. * @param name defines the name of the new skeleton
  15200. * @param id defines the id of the new skeleton
  15201. * @returns the new skeleton
  15202. */
  15203. clone(name: string, id?: string): Skeleton;
  15204. /**
  15205. * Enable animation blending for this skeleton
  15206. * @param blendingSpeed defines the blending speed to apply
  15207. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15208. */
  15209. enableBlending(blendingSpeed?: number): void;
  15210. /**
  15211. * Releases all resources associated with the current skeleton
  15212. */
  15213. dispose(): void;
  15214. /**
  15215. * Serialize the skeleton in a JSON object
  15216. * @returns a JSON object
  15217. */
  15218. serialize(): any;
  15219. /**
  15220. * Creates a new skeleton from serialized data
  15221. * @param parsedSkeleton defines the serialized data
  15222. * @param scene defines the hosting scene
  15223. * @returns a new skeleton
  15224. */
  15225. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15226. /**
  15227. * Compute all node absolute transforms
  15228. * @param forceUpdate defines if computation must be done even if cache is up to date
  15229. */
  15230. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15231. /**
  15232. * Gets the root pose matrix
  15233. * @returns a matrix
  15234. */
  15235. getPoseMatrix(): Nullable<Matrix>;
  15236. /**
  15237. * Sorts bones per internal index
  15238. */
  15239. sortBones(): void;
  15240. private _sortBones;
  15241. }
  15242. }
  15243. declare module BABYLON {
  15244. /**
  15245. * Creates an instance based on a source mesh.
  15246. */
  15247. export class InstancedMesh extends AbstractMesh {
  15248. private _sourceMesh;
  15249. private _currentLOD;
  15250. /** @hidden */
  15251. _indexInSourceMeshInstanceArray: number;
  15252. constructor(name: string, source: Mesh);
  15253. /**
  15254. * Returns the string "InstancedMesh".
  15255. */
  15256. getClassName(): string;
  15257. /** Gets the list of lights affecting that mesh */
  15258. get lightSources(): Light[];
  15259. _resyncLightSources(): void;
  15260. _resyncLightSource(light: Light): void;
  15261. _removeLightSource(light: Light, dispose: boolean): void;
  15262. /**
  15263. * If the source mesh receives shadows
  15264. */
  15265. get receiveShadows(): boolean;
  15266. /**
  15267. * The material of the source mesh
  15268. */
  15269. get material(): Nullable<Material>;
  15270. /**
  15271. * Visibility of the source mesh
  15272. */
  15273. get visibility(): number;
  15274. /**
  15275. * Skeleton of the source mesh
  15276. */
  15277. get skeleton(): Nullable<Skeleton>;
  15278. /**
  15279. * Rendering ground id of the source mesh
  15280. */
  15281. get renderingGroupId(): number;
  15282. set renderingGroupId(value: number);
  15283. /**
  15284. * Returns the total number of vertices (integer).
  15285. */
  15286. getTotalVertices(): number;
  15287. /**
  15288. * Returns a positive integer : the total number of indices in this mesh geometry.
  15289. * @returns the numner of indices or zero if the mesh has no geometry.
  15290. */
  15291. getTotalIndices(): number;
  15292. /**
  15293. * The source mesh of the instance
  15294. */
  15295. get sourceMesh(): Mesh;
  15296. /**
  15297. * Is this node ready to be used/rendered
  15298. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15299. * @return {boolean} is it ready
  15300. */
  15301. isReady(completeCheck?: boolean): boolean;
  15302. /**
  15303. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15304. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15305. * @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.
  15306. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15307. */
  15308. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15309. /**
  15310. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15311. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15312. * The `data` are either a numeric array either a Float32Array.
  15313. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15314. * 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).
  15315. * Note that a new underlying VertexBuffer object is created each call.
  15316. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15317. *
  15318. * Possible `kind` values :
  15319. * - VertexBuffer.PositionKind
  15320. * - VertexBuffer.UVKind
  15321. * - VertexBuffer.UV2Kind
  15322. * - VertexBuffer.UV3Kind
  15323. * - VertexBuffer.UV4Kind
  15324. * - VertexBuffer.UV5Kind
  15325. * - VertexBuffer.UV6Kind
  15326. * - VertexBuffer.ColorKind
  15327. * - VertexBuffer.MatricesIndicesKind
  15328. * - VertexBuffer.MatricesIndicesExtraKind
  15329. * - VertexBuffer.MatricesWeightsKind
  15330. * - VertexBuffer.MatricesWeightsExtraKind
  15331. *
  15332. * Returns the Mesh.
  15333. */
  15334. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15335. /**
  15336. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15337. * If the mesh has no geometry, it is simply returned as it is.
  15338. * The `data` are either a numeric array either a Float32Array.
  15339. * No new underlying VertexBuffer object is created.
  15340. * 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.
  15341. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15342. *
  15343. * Possible `kind` values :
  15344. * - VertexBuffer.PositionKind
  15345. * - VertexBuffer.UVKind
  15346. * - VertexBuffer.UV2Kind
  15347. * - VertexBuffer.UV3Kind
  15348. * - VertexBuffer.UV4Kind
  15349. * - VertexBuffer.UV5Kind
  15350. * - VertexBuffer.UV6Kind
  15351. * - VertexBuffer.ColorKind
  15352. * - VertexBuffer.MatricesIndicesKind
  15353. * - VertexBuffer.MatricesIndicesExtraKind
  15354. * - VertexBuffer.MatricesWeightsKind
  15355. * - VertexBuffer.MatricesWeightsExtraKind
  15356. *
  15357. * Returns the Mesh.
  15358. */
  15359. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15360. /**
  15361. * Sets the mesh indices.
  15362. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15363. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15364. * This method creates a new index buffer each call.
  15365. * Returns the Mesh.
  15366. */
  15367. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15368. /**
  15369. * Boolean : True if the mesh owns the requested kind of data.
  15370. */
  15371. isVerticesDataPresent(kind: string): boolean;
  15372. /**
  15373. * Returns an array of indices (IndicesArray).
  15374. */
  15375. getIndices(): Nullable<IndicesArray>;
  15376. get _positions(): Nullable<Vector3[]>;
  15377. /**
  15378. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15379. * This means the mesh underlying bounding box and sphere are recomputed.
  15380. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15381. * @returns the current mesh
  15382. */
  15383. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15384. /** @hidden */
  15385. _preActivate(): InstancedMesh;
  15386. /** @hidden */
  15387. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15388. /** @hidden */
  15389. _postActivate(): void;
  15390. getWorldMatrix(): Matrix;
  15391. get isAnInstance(): boolean;
  15392. /**
  15393. * Returns the current associated LOD AbstractMesh.
  15394. */
  15395. getLOD(camera: Camera): AbstractMesh;
  15396. /** @hidden */
  15397. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15398. /** @hidden */
  15399. _syncSubMeshes(): InstancedMesh;
  15400. /** @hidden */
  15401. _generatePointsArray(): boolean;
  15402. /**
  15403. * Creates a new InstancedMesh from the current mesh.
  15404. * - name (string) : the cloned mesh name
  15405. * - newParent (optional Node) : the optional Node to parent the clone to.
  15406. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15407. *
  15408. * Returns the clone.
  15409. */
  15410. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15411. /**
  15412. * Disposes the InstancedMesh.
  15413. * Returns nothing.
  15414. */
  15415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15416. }
  15417. interface Mesh {
  15418. /**
  15419. * Register a custom buffer that will be instanced
  15420. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15421. * @param kind defines the buffer kind
  15422. * @param stride defines the stride in floats
  15423. */
  15424. registerInstancedBuffer(kind: string, stride: number): void;
  15425. /** @hidden */
  15426. _userInstancedBuffersStorage: {
  15427. data: {
  15428. [key: string]: Float32Array;
  15429. };
  15430. sizes: {
  15431. [key: string]: number;
  15432. };
  15433. vertexBuffers: {
  15434. [key: string]: Nullable<VertexBuffer>;
  15435. };
  15436. strides: {
  15437. [key: string]: number;
  15438. };
  15439. };
  15440. }
  15441. interface AbstractMesh {
  15442. /**
  15443. * Object used to store instanced buffers defined by user
  15444. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15445. */
  15446. instancedBuffers: {
  15447. [key: string]: any;
  15448. };
  15449. }
  15450. }
  15451. declare module BABYLON {
  15452. /**
  15453. * Defines the options associated with the creation of a shader material.
  15454. */
  15455. export interface IShaderMaterialOptions {
  15456. /**
  15457. * Does the material work in alpha blend mode
  15458. */
  15459. needAlphaBlending: boolean;
  15460. /**
  15461. * Does the material work in alpha test mode
  15462. */
  15463. needAlphaTesting: boolean;
  15464. /**
  15465. * The list of attribute names used in the shader
  15466. */
  15467. attributes: string[];
  15468. /**
  15469. * The list of unifrom names used in the shader
  15470. */
  15471. uniforms: string[];
  15472. /**
  15473. * The list of UBO names used in the shader
  15474. */
  15475. uniformBuffers: string[];
  15476. /**
  15477. * The list of sampler names used in the shader
  15478. */
  15479. samplers: string[];
  15480. /**
  15481. * The list of defines used in the shader
  15482. */
  15483. defines: string[];
  15484. }
  15485. /**
  15486. * 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.
  15487. *
  15488. * This returned material effects how the mesh will look based on the code in the shaders.
  15489. *
  15490. * @see http://doc.babylonjs.com/how_to/shader_material
  15491. */
  15492. export class ShaderMaterial extends Material {
  15493. private _shaderPath;
  15494. private _options;
  15495. private _textures;
  15496. private _textureArrays;
  15497. private _floats;
  15498. private _ints;
  15499. private _floatsArrays;
  15500. private _colors3;
  15501. private _colors3Arrays;
  15502. private _colors4;
  15503. private _colors4Arrays;
  15504. private _vectors2;
  15505. private _vectors3;
  15506. private _vectors4;
  15507. private _matrices;
  15508. private _matrixArrays;
  15509. private _matrices3x3;
  15510. private _matrices2x2;
  15511. private _vectors2Arrays;
  15512. private _vectors3Arrays;
  15513. private _vectors4Arrays;
  15514. private _cachedWorldViewMatrix;
  15515. private _cachedWorldViewProjectionMatrix;
  15516. private _renderId;
  15517. private _multiview;
  15518. private _cachedDefines;
  15519. /**
  15520. * Instantiate a new shader material.
  15521. * 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.
  15522. * This returned material effects how the mesh will look based on the code in the shaders.
  15523. * @see http://doc.babylonjs.com/how_to/shader_material
  15524. * @param name Define the name of the material in the scene
  15525. * @param scene Define the scene the material belongs to
  15526. * @param shaderPath Defines the route to the shader code in one of three ways:
  15527. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15528. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15529. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15530. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15531. * @param options Define the options used to create the shader
  15532. */
  15533. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15534. /**
  15535. * Gets the shader path used to define the shader code
  15536. * It can be modified to trigger a new compilation
  15537. */
  15538. get shaderPath(): any;
  15539. /**
  15540. * Sets the shader path used to define the shader code
  15541. * It can be modified to trigger a new compilation
  15542. */
  15543. set shaderPath(shaderPath: any);
  15544. /**
  15545. * Gets the options used to compile the shader.
  15546. * They can be modified to trigger a new compilation
  15547. */
  15548. get options(): IShaderMaterialOptions;
  15549. /**
  15550. * Gets the current class name of the material e.g. "ShaderMaterial"
  15551. * Mainly use in serialization.
  15552. * @returns the class name
  15553. */
  15554. getClassName(): string;
  15555. /**
  15556. * Specifies if the material will require alpha blending
  15557. * @returns a boolean specifying if alpha blending is needed
  15558. */
  15559. needAlphaBlending(): boolean;
  15560. /**
  15561. * Specifies if this material should be rendered in alpha test mode
  15562. * @returns a boolean specifying if an alpha test is needed.
  15563. */
  15564. needAlphaTesting(): boolean;
  15565. private _checkUniform;
  15566. /**
  15567. * Set a texture in the shader.
  15568. * @param name Define the name of the uniform samplers as defined in the shader
  15569. * @param texture Define the texture to bind to this sampler
  15570. * @return the material itself allowing "fluent" like uniform updates
  15571. */
  15572. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15573. /**
  15574. * Set a texture array in the shader.
  15575. * @param name Define the name of the uniform sampler array as defined in the shader
  15576. * @param textures Define the list of textures to bind to this sampler
  15577. * @return the material itself allowing "fluent" like uniform updates
  15578. */
  15579. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15580. /**
  15581. * Set a float in the shader.
  15582. * @param name Define the name of the uniform as defined in the shader
  15583. * @param value Define the value to give to the uniform
  15584. * @return the material itself allowing "fluent" like uniform updates
  15585. */
  15586. setFloat(name: string, value: number): ShaderMaterial;
  15587. /**
  15588. * Set a int in the shader.
  15589. * @param name Define the name of the uniform as defined in the shader
  15590. * @param value Define the value to give to the uniform
  15591. * @return the material itself allowing "fluent" like uniform updates
  15592. */
  15593. setInt(name: string, value: number): ShaderMaterial;
  15594. /**
  15595. * Set an array of floats in the shader.
  15596. * @param name Define the name of the uniform as defined in the shader
  15597. * @param value Define the value to give to the uniform
  15598. * @return the material itself allowing "fluent" like uniform updates
  15599. */
  15600. setFloats(name: string, value: number[]): ShaderMaterial;
  15601. /**
  15602. * Set a vec3 in the shader from a Color3.
  15603. * @param name Define the name of the uniform as defined in the shader
  15604. * @param value Define the value to give to the uniform
  15605. * @return the material itself allowing "fluent" like uniform updates
  15606. */
  15607. setColor3(name: string, value: Color3): ShaderMaterial;
  15608. /**
  15609. * Set a vec3 array in the shader from a Color3 array.
  15610. * @param name Define the name of the uniform as defined in the shader
  15611. * @param value Define the value to give to the uniform
  15612. * @return the material itself allowing "fluent" like uniform updates
  15613. */
  15614. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15615. /**
  15616. * Set a vec4 in the shader from a Color4.
  15617. * @param name Define the name of the uniform as defined in the shader
  15618. * @param value Define the value to give to the uniform
  15619. * @return the material itself allowing "fluent" like uniform updates
  15620. */
  15621. setColor4(name: string, value: Color4): ShaderMaterial;
  15622. /**
  15623. * Set a vec4 array in the shader from a Color4 array.
  15624. * @param name Define the name of the uniform as defined in the shader
  15625. * @param value Define the value to give to the uniform
  15626. * @return the material itself allowing "fluent" like uniform updates
  15627. */
  15628. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15629. /**
  15630. * Set a vec2 in the shader from a Vector2.
  15631. * @param name Define the name of the uniform as defined in the shader
  15632. * @param value Define the value to give to the uniform
  15633. * @return the material itself allowing "fluent" like uniform updates
  15634. */
  15635. setVector2(name: string, value: Vector2): ShaderMaterial;
  15636. /**
  15637. * Set a vec3 in the shader from a Vector3.
  15638. * @param name Define the name of the uniform as defined in the shader
  15639. * @param value Define the value to give to the uniform
  15640. * @return the material itself allowing "fluent" like uniform updates
  15641. */
  15642. setVector3(name: string, value: Vector3): ShaderMaterial;
  15643. /**
  15644. * Set a vec4 in the shader from a Vector4.
  15645. * @param name Define the name of the uniform as defined in the shader
  15646. * @param value Define the value to give to the uniform
  15647. * @return the material itself allowing "fluent" like uniform updates
  15648. */
  15649. setVector4(name: string, value: Vector4): ShaderMaterial;
  15650. /**
  15651. * Set a mat4 in the shader from a Matrix.
  15652. * @param name Define the name of the uniform as defined in the shader
  15653. * @param value Define the value to give to the uniform
  15654. * @return the material itself allowing "fluent" like uniform updates
  15655. */
  15656. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15657. /**
  15658. * Set a float32Array in the shader from a matrix array.
  15659. * @param name Define the name of the uniform as defined in the shader
  15660. * @param value Define the value to give to the uniform
  15661. * @return the material itself allowing "fluent" like uniform updates
  15662. */
  15663. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15664. /**
  15665. * Set a mat3 in the shader from a Float32Array.
  15666. * @param name Define the name of the uniform as defined in the shader
  15667. * @param value Define the value to give to the uniform
  15668. * @return the material itself allowing "fluent" like uniform updates
  15669. */
  15670. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15671. /**
  15672. * Set a mat2 in the shader from a Float32Array.
  15673. * @param name Define the name of the uniform as defined in the shader
  15674. * @param value Define the value to give to the uniform
  15675. * @return the material itself allowing "fluent" like uniform updates
  15676. */
  15677. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15678. /**
  15679. * Set a vec2 array in the shader from a number array.
  15680. * @param name Define the name of the uniform as defined in the shader
  15681. * @param value Define the value to give to the uniform
  15682. * @return the material itself allowing "fluent" like uniform updates
  15683. */
  15684. setArray2(name: string, value: number[]): ShaderMaterial;
  15685. /**
  15686. * Set a vec3 array in the shader from a number array.
  15687. * @param name Define the name of the uniform as defined in the shader
  15688. * @param value Define the value to give to the uniform
  15689. * @return the material itself allowing "fluent" like uniform updates
  15690. */
  15691. setArray3(name: string, value: number[]): ShaderMaterial;
  15692. /**
  15693. * Set a vec4 array in the shader from a number array.
  15694. * @param name Define the name of the uniform as defined in the shader
  15695. * @param value Define the value to give to the uniform
  15696. * @return the material itself allowing "fluent" like uniform updates
  15697. */
  15698. setArray4(name: string, value: number[]): ShaderMaterial;
  15699. private _checkCache;
  15700. /**
  15701. * Specifies that the submesh is ready to be used
  15702. * @param mesh defines the mesh to check
  15703. * @param subMesh defines which submesh to check
  15704. * @param useInstances specifies that instances should be used
  15705. * @returns a boolean indicating that the submesh is ready or not
  15706. */
  15707. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15708. /**
  15709. * Checks if the material is ready to render the requested mesh
  15710. * @param mesh Define the mesh to render
  15711. * @param useInstances Define whether or not the material is used with instances
  15712. * @returns true if ready, otherwise false
  15713. */
  15714. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15715. /**
  15716. * Binds the world matrix to the material
  15717. * @param world defines the world transformation matrix
  15718. * @param effectOverride - If provided, use this effect instead of internal effect
  15719. */
  15720. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15721. /**
  15722. * Binds the submesh to this material by preparing the effect and shader to draw
  15723. * @param world defines the world transformation matrix
  15724. * @param mesh defines the mesh containing the submesh
  15725. * @param subMesh defines the submesh to bind the material to
  15726. */
  15727. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15728. /**
  15729. * Binds the material to the mesh
  15730. * @param world defines the world transformation matrix
  15731. * @param mesh defines the mesh to bind the material to
  15732. * @param effectOverride - If provided, use this effect instead of internal effect
  15733. */
  15734. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15735. protected _afterBind(mesh?: Mesh): void;
  15736. /**
  15737. * Gets the active textures from the material
  15738. * @returns an array of textures
  15739. */
  15740. getActiveTextures(): BaseTexture[];
  15741. /**
  15742. * Specifies if the material uses a texture
  15743. * @param texture defines the texture to check against the material
  15744. * @returns a boolean specifying if the material uses the texture
  15745. */
  15746. hasTexture(texture: BaseTexture): boolean;
  15747. /**
  15748. * Makes a duplicate of the material, and gives it a new name
  15749. * @param name defines the new name for the duplicated material
  15750. * @returns the cloned material
  15751. */
  15752. clone(name: string): ShaderMaterial;
  15753. /**
  15754. * Disposes the material
  15755. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15756. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15757. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15758. */
  15759. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15760. /**
  15761. * Serializes this material in a JSON representation
  15762. * @returns the serialized material object
  15763. */
  15764. serialize(): any;
  15765. /**
  15766. * Creates a shader material from parsed shader material data
  15767. * @param source defines the JSON represnetation of the material
  15768. * @param scene defines the hosting scene
  15769. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15770. * @returns a new material
  15771. */
  15772. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15773. }
  15774. }
  15775. declare module BABYLON {
  15776. /** @hidden */
  15777. export var colorPixelShader: {
  15778. name: string;
  15779. shader: string;
  15780. };
  15781. }
  15782. declare module BABYLON {
  15783. /** @hidden */
  15784. export var colorVertexShader: {
  15785. name: string;
  15786. shader: string;
  15787. };
  15788. }
  15789. declare module BABYLON {
  15790. /**
  15791. * Line mesh
  15792. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15793. */
  15794. export class LinesMesh extends Mesh {
  15795. /**
  15796. * If vertex color should be applied to the mesh
  15797. */
  15798. readonly useVertexColor?: boolean | undefined;
  15799. /**
  15800. * If vertex alpha should be applied to the mesh
  15801. */
  15802. readonly useVertexAlpha?: boolean | undefined;
  15803. /**
  15804. * Color of the line (Default: White)
  15805. */
  15806. color: Color3;
  15807. /**
  15808. * Alpha of the line (Default: 1)
  15809. */
  15810. alpha: number;
  15811. /**
  15812. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15813. * This margin is expressed in world space coordinates, so its value may vary.
  15814. * Default value is 0.1
  15815. */
  15816. intersectionThreshold: number;
  15817. private _colorShader;
  15818. private color4;
  15819. /**
  15820. * Creates a new LinesMesh
  15821. * @param name defines the name
  15822. * @param scene defines the hosting scene
  15823. * @param parent defines the parent mesh if any
  15824. * @param source defines the optional source LinesMesh used to clone data from
  15825. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15826. * When false, achieved by calling a clone(), also passing False.
  15827. * This will make creation of children, recursive.
  15828. * @param useVertexColor defines if this LinesMesh supports vertex color
  15829. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15830. */
  15831. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15832. /**
  15833. * If vertex color should be applied to the mesh
  15834. */
  15835. useVertexColor?: boolean | undefined,
  15836. /**
  15837. * If vertex alpha should be applied to the mesh
  15838. */
  15839. useVertexAlpha?: boolean | undefined);
  15840. private _addClipPlaneDefine;
  15841. private _removeClipPlaneDefine;
  15842. isReady(): boolean;
  15843. /**
  15844. * Returns the string "LineMesh"
  15845. */
  15846. getClassName(): string;
  15847. /**
  15848. * @hidden
  15849. */
  15850. get material(): Material;
  15851. /**
  15852. * @hidden
  15853. */
  15854. set material(value: Material);
  15855. /**
  15856. * @hidden
  15857. */
  15858. get checkCollisions(): boolean;
  15859. /** @hidden */
  15860. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15861. /** @hidden */
  15862. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15863. /**
  15864. * Disposes of the line mesh
  15865. * @param doNotRecurse If children should be disposed
  15866. */
  15867. dispose(doNotRecurse?: boolean): void;
  15868. /**
  15869. * Returns a new LineMesh object cloned from the current one.
  15870. */
  15871. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15872. /**
  15873. * Creates a new InstancedLinesMesh object from the mesh model.
  15874. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15875. * @param name defines the name of the new instance
  15876. * @returns a new InstancedLinesMesh
  15877. */
  15878. createInstance(name: string): InstancedLinesMesh;
  15879. }
  15880. /**
  15881. * Creates an instance based on a source LinesMesh
  15882. */
  15883. export class InstancedLinesMesh extends InstancedMesh {
  15884. /**
  15885. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15886. * This margin is expressed in world space coordinates, so its value may vary.
  15887. * Initilized with the intersectionThreshold value of the source LinesMesh
  15888. */
  15889. intersectionThreshold: number;
  15890. constructor(name: string, source: LinesMesh);
  15891. /**
  15892. * Returns the string "InstancedLinesMesh".
  15893. */
  15894. getClassName(): string;
  15895. }
  15896. }
  15897. declare module BABYLON {
  15898. /** @hidden */
  15899. export var linePixelShader: {
  15900. name: string;
  15901. shader: string;
  15902. };
  15903. }
  15904. declare module BABYLON {
  15905. /** @hidden */
  15906. export var lineVertexShader: {
  15907. name: string;
  15908. shader: string;
  15909. };
  15910. }
  15911. declare module BABYLON {
  15912. interface AbstractMesh {
  15913. /**
  15914. * Gets the edgesRenderer associated with the mesh
  15915. */
  15916. edgesRenderer: Nullable<EdgesRenderer>;
  15917. }
  15918. interface LinesMesh {
  15919. /**
  15920. * Enables the edge rendering mode on the mesh.
  15921. * This mode makes the mesh edges visible
  15922. * @param epsilon defines the maximal distance between two angles to detect a face
  15923. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15924. * @returns the currentAbstractMesh
  15925. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15926. */
  15927. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15928. }
  15929. interface InstancedLinesMesh {
  15930. /**
  15931. * Enables the edge rendering mode on the mesh.
  15932. * This mode makes the mesh edges visible
  15933. * @param epsilon defines the maximal distance between two angles to detect a face
  15934. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15935. * @returns the current InstancedLinesMesh
  15936. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15937. */
  15938. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15939. }
  15940. /**
  15941. * Defines the minimum contract an Edges renderer should follow.
  15942. */
  15943. export interface IEdgesRenderer extends IDisposable {
  15944. /**
  15945. * Gets or sets a boolean indicating if the edgesRenderer is active
  15946. */
  15947. isEnabled: boolean;
  15948. /**
  15949. * Renders the edges of the attached mesh,
  15950. */
  15951. render(): void;
  15952. /**
  15953. * Checks wether or not the edges renderer is ready to render.
  15954. * @return true if ready, otherwise false.
  15955. */
  15956. isReady(): boolean;
  15957. }
  15958. /**
  15959. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15960. */
  15961. export class EdgesRenderer implements IEdgesRenderer {
  15962. /**
  15963. * Define the size of the edges with an orthographic camera
  15964. */
  15965. edgesWidthScalerForOrthographic: number;
  15966. /**
  15967. * Define the size of the edges with a perspective camera
  15968. */
  15969. edgesWidthScalerForPerspective: number;
  15970. protected _source: AbstractMesh;
  15971. protected _linesPositions: number[];
  15972. protected _linesNormals: number[];
  15973. protected _linesIndices: number[];
  15974. protected _epsilon: number;
  15975. protected _indicesCount: number;
  15976. protected _lineShader: ShaderMaterial;
  15977. protected _ib: DataBuffer;
  15978. protected _buffers: {
  15979. [key: string]: Nullable<VertexBuffer>;
  15980. };
  15981. protected _checkVerticesInsteadOfIndices: boolean;
  15982. private _meshRebuildObserver;
  15983. private _meshDisposeObserver;
  15984. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15985. isEnabled: boolean;
  15986. /**
  15987. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15988. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15989. * @param source Mesh used to create edges
  15990. * @param epsilon sum of angles in adjacency to check for edge
  15991. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15992. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15993. */
  15994. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15995. protected _prepareRessources(): void;
  15996. /** @hidden */
  15997. _rebuild(): void;
  15998. /**
  15999. * Releases the required resources for the edges renderer
  16000. */
  16001. dispose(): void;
  16002. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16003. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16004. /**
  16005. * Checks if the pair of p0 and p1 is en edge
  16006. * @param faceIndex
  16007. * @param edge
  16008. * @param faceNormals
  16009. * @param p0
  16010. * @param p1
  16011. * @private
  16012. */
  16013. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16014. /**
  16015. * push line into the position, normal and index buffer
  16016. * @protected
  16017. */
  16018. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16019. /**
  16020. * Generates lines edges from adjacencjes
  16021. * @private
  16022. */
  16023. _generateEdgesLines(): void;
  16024. /**
  16025. * Checks wether or not the edges renderer is ready to render.
  16026. * @return true if ready, otherwise false.
  16027. */
  16028. isReady(): boolean;
  16029. /**
  16030. * Renders the edges of the attached mesh,
  16031. */
  16032. render(): void;
  16033. }
  16034. /**
  16035. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16036. */
  16037. export class LineEdgesRenderer extends EdgesRenderer {
  16038. /**
  16039. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16040. * @param source LineMesh used to generate edges
  16041. * @param epsilon not important (specified angle for edge detection)
  16042. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16043. */
  16044. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16045. /**
  16046. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16047. */
  16048. _generateEdgesLines(): void;
  16049. }
  16050. }
  16051. declare module BABYLON {
  16052. /**
  16053. * This represents the object necessary to create a rendering group.
  16054. * This is exclusively used and created by the rendering manager.
  16055. * To modify the behavior, you use the available helpers in your scene or meshes.
  16056. * @hidden
  16057. */
  16058. export class RenderingGroup {
  16059. index: number;
  16060. private static _zeroVector;
  16061. private _scene;
  16062. private _opaqueSubMeshes;
  16063. private _transparentSubMeshes;
  16064. private _alphaTestSubMeshes;
  16065. private _depthOnlySubMeshes;
  16066. private _particleSystems;
  16067. private _spriteManagers;
  16068. private _opaqueSortCompareFn;
  16069. private _alphaTestSortCompareFn;
  16070. private _transparentSortCompareFn;
  16071. private _renderOpaque;
  16072. private _renderAlphaTest;
  16073. private _renderTransparent;
  16074. /** @hidden */
  16075. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16076. onBeforeTransparentRendering: () => void;
  16077. /**
  16078. * Set the opaque sort comparison function.
  16079. * If null the sub meshes will be render in the order they were created
  16080. */
  16081. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16082. /**
  16083. * Set the alpha test sort comparison function.
  16084. * If null the sub meshes will be render in the order they were created
  16085. */
  16086. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16087. /**
  16088. * Set the transparent sort comparison function.
  16089. * If null the sub meshes will be render in the order they were created
  16090. */
  16091. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16092. /**
  16093. * Creates a new rendering group.
  16094. * @param index The rendering group index
  16095. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16096. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16097. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16098. */
  16099. 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>);
  16100. /**
  16101. * Render all the sub meshes contained in the group.
  16102. * @param customRenderFunction Used to override the default render behaviour of the group.
  16103. * @returns true if rendered some submeshes.
  16104. */
  16105. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16106. /**
  16107. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16108. * @param subMeshes The submeshes to render
  16109. */
  16110. private renderOpaqueSorted;
  16111. /**
  16112. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16113. * @param subMeshes The submeshes to render
  16114. */
  16115. private renderAlphaTestSorted;
  16116. /**
  16117. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16118. * @param subMeshes The submeshes to render
  16119. */
  16120. private renderTransparentSorted;
  16121. /**
  16122. * Renders the submeshes in a specified order.
  16123. * @param subMeshes The submeshes to sort before render
  16124. * @param sortCompareFn The comparison function use to sort
  16125. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16126. * @param transparent Specifies to activate blending if true
  16127. */
  16128. private static renderSorted;
  16129. /**
  16130. * Renders the submeshes in the order they were dispatched (no sort applied).
  16131. * @param subMeshes The submeshes to render
  16132. */
  16133. private static renderUnsorted;
  16134. /**
  16135. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16136. * are rendered back to front if in the same alpha index.
  16137. *
  16138. * @param a The first submesh
  16139. * @param b The second submesh
  16140. * @returns The result of the comparison
  16141. */
  16142. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16143. /**
  16144. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16145. * are rendered back to front.
  16146. *
  16147. * @param a The first submesh
  16148. * @param b The second submesh
  16149. * @returns The result of the comparison
  16150. */
  16151. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16152. /**
  16153. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16154. * are rendered front to back (prevent overdraw).
  16155. *
  16156. * @param a The first submesh
  16157. * @param b The second submesh
  16158. * @returns The result of the comparison
  16159. */
  16160. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16161. /**
  16162. * Resets the different lists of submeshes to prepare a new frame.
  16163. */
  16164. prepare(): void;
  16165. dispose(): void;
  16166. /**
  16167. * Inserts the submesh in its correct queue depending on its material.
  16168. * @param subMesh The submesh to dispatch
  16169. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16170. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16171. */
  16172. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16173. dispatchSprites(spriteManager: ISpriteManager): void;
  16174. dispatchParticles(particleSystem: IParticleSystem): void;
  16175. private _renderParticles;
  16176. private _renderSprites;
  16177. }
  16178. }
  16179. declare module BABYLON {
  16180. /**
  16181. * Interface describing the different options available in the rendering manager
  16182. * regarding Auto Clear between groups.
  16183. */
  16184. export interface IRenderingManagerAutoClearSetup {
  16185. /**
  16186. * Defines whether or not autoclear is enable.
  16187. */
  16188. autoClear: boolean;
  16189. /**
  16190. * Defines whether or not to autoclear the depth buffer.
  16191. */
  16192. depth: boolean;
  16193. /**
  16194. * Defines whether or not to autoclear the stencil buffer.
  16195. */
  16196. stencil: boolean;
  16197. }
  16198. /**
  16199. * This class is used by the onRenderingGroupObservable
  16200. */
  16201. export class RenderingGroupInfo {
  16202. /**
  16203. * The Scene that being rendered
  16204. */
  16205. scene: Scene;
  16206. /**
  16207. * The camera currently used for the rendering pass
  16208. */
  16209. camera: Nullable<Camera>;
  16210. /**
  16211. * The ID of the renderingGroup being processed
  16212. */
  16213. renderingGroupId: number;
  16214. }
  16215. /**
  16216. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16217. * It is enable to manage the different groups as well as the different necessary sort functions.
  16218. * This should not be used directly aside of the few static configurations
  16219. */
  16220. export class RenderingManager {
  16221. /**
  16222. * The max id used for rendering groups (not included)
  16223. */
  16224. static MAX_RENDERINGGROUPS: number;
  16225. /**
  16226. * The min id used for rendering groups (included)
  16227. */
  16228. static MIN_RENDERINGGROUPS: number;
  16229. /**
  16230. * Used to globally prevent autoclearing scenes.
  16231. */
  16232. static AUTOCLEAR: boolean;
  16233. /**
  16234. * @hidden
  16235. */
  16236. _useSceneAutoClearSetup: boolean;
  16237. private _scene;
  16238. private _renderingGroups;
  16239. private _depthStencilBufferAlreadyCleaned;
  16240. private _autoClearDepthStencil;
  16241. private _customOpaqueSortCompareFn;
  16242. private _customAlphaTestSortCompareFn;
  16243. private _customTransparentSortCompareFn;
  16244. private _renderingGroupInfo;
  16245. /**
  16246. * Instantiates a new rendering group for a particular scene
  16247. * @param scene Defines the scene the groups belongs to
  16248. */
  16249. constructor(scene: Scene);
  16250. private _clearDepthStencilBuffer;
  16251. /**
  16252. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16253. * @hidden
  16254. */
  16255. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16256. /**
  16257. * Resets the different information of the group to prepare a new frame
  16258. * @hidden
  16259. */
  16260. reset(): void;
  16261. /**
  16262. * Dispose and release the group and its associated resources.
  16263. * @hidden
  16264. */
  16265. dispose(): void;
  16266. /**
  16267. * Clear the info related to rendering groups preventing retention points during dispose.
  16268. */
  16269. freeRenderingGroups(): void;
  16270. private _prepareRenderingGroup;
  16271. /**
  16272. * Add a sprite manager to the rendering manager in order to render it this frame.
  16273. * @param spriteManager Define the sprite manager to render
  16274. */
  16275. dispatchSprites(spriteManager: ISpriteManager): void;
  16276. /**
  16277. * Add a particle system to the rendering manager in order to render it this frame.
  16278. * @param particleSystem Define the particle system to render
  16279. */
  16280. dispatchParticles(particleSystem: IParticleSystem): void;
  16281. /**
  16282. * Add a submesh to the manager in order to render it this frame
  16283. * @param subMesh The submesh to dispatch
  16284. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16285. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16286. */
  16287. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16288. /**
  16289. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16290. * This allowed control for front to back rendering or reversly depending of the special needs.
  16291. *
  16292. * @param renderingGroupId The rendering group id corresponding to its index
  16293. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16294. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16295. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16296. */
  16297. 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;
  16298. /**
  16299. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16300. *
  16301. * @param renderingGroupId The rendering group id corresponding to its index
  16302. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16303. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16304. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16305. */
  16306. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16307. /**
  16308. * Gets the current auto clear configuration for one rendering group of the rendering
  16309. * manager.
  16310. * @param index the rendering group index to get the information for
  16311. * @returns The auto clear setup for the requested rendering group
  16312. */
  16313. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16314. }
  16315. }
  16316. declare module BABYLON {
  16317. /**
  16318. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16319. */
  16320. export interface ICustomShaderOptions {
  16321. /**
  16322. * Gets or sets the custom shader name to use
  16323. */
  16324. shaderName: string;
  16325. /**
  16326. * The list of attribute names used in the shader
  16327. */
  16328. attributes?: string[];
  16329. /**
  16330. * The list of unifrom names used in the shader
  16331. */
  16332. uniforms?: string[];
  16333. /**
  16334. * The list of sampler names used in the shader
  16335. */
  16336. samplers?: string[];
  16337. /**
  16338. * The list of defines used in the shader
  16339. */
  16340. defines?: string[];
  16341. }
  16342. /**
  16343. * Interface to implement to create a shadow generator compatible with BJS.
  16344. */
  16345. export interface IShadowGenerator {
  16346. /**
  16347. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16348. * @returns The render target texture if present otherwise, null
  16349. */
  16350. getShadowMap(): Nullable<RenderTargetTexture>;
  16351. /**
  16352. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16353. * @param subMesh The submesh we want to render in the shadow map
  16354. * @param useInstances Defines wether will draw in the map using instances
  16355. * @returns true if ready otherwise, false
  16356. */
  16357. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16358. /**
  16359. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16360. * @param defines Defines of the material we want to update
  16361. * @param lightIndex Index of the light in the enabled light list of the material
  16362. */
  16363. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16364. /**
  16365. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16366. * defined in the generator but impacting the effect).
  16367. * It implies the unifroms available on the materials are the standard BJS ones.
  16368. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16369. * @param effect The effect we are binfing the information for
  16370. */
  16371. bindShadowLight(lightIndex: string, effect: Effect): void;
  16372. /**
  16373. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16374. * (eq to shadow prjection matrix * light transform matrix)
  16375. * @returns The transform matrix used to create the shadow map
  16376. */
  16377. getTransformMatrix(): Matrix;
  16378. /**
  16379. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16380. * Cube and 2D textures for instance.
  16381. */
  16382. recreateShadowMap(): void;
  16383. /**
  16384. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16385. * @param onCompiled Callback triggered at the and of the effects compilation
  16386. * @param options Sets of optional options forcing the compilation with different modes
  16387. */
  16388. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16389. useInstances: boolean;
  16390. }>): void;
  16391. /**
  16392. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16393. * @param options Sets of optional options forcing the compilation with different modes
  16394. * @returns A promise that resolves when the compilation completes
  16395. */
  16396. forceCompilationAsync(options?: Partial<{
  16397. useInstances: boolean;
  16398. }>): Promise<void>;
  16399. /**
  16400. * Serializes the shadow generator setup to a json object.
  16401. * @returns The serialized JSON object
  16402. */
  16403. serialize(): any;
  16404. /**
  16405. * Disposes the Shadow map and related Textures and effects.
  16406. */
  16407. dispose(): void;
  16408. }
  16409. /**
  16410. * Default implementation IShadowGenerator.
  16411. * This is the main object responsible of generating shadows in the framework.
  16412. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16413. */
  16414. export class ShadowGenerator implements IShadowGenerator {
  16415. /**
  16416. * Name of the shadow generator class
  16417. */
  16418. static CLASSNAME: string;
  16419. /**
  16420. * Shadow generator mode None: no filtering applied.
  16421. */
  16422. static readonly FILTER_NONE: number;
  16423. /**
  16424. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16425. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16426. */
  16427. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16428. /**
  16429. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16430. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16431. */
  16432. static readonly FILTER_POISSONSAMPLING: number;
  16433. /**
  16434. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16436. */
  16437. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16438. /**
  16439. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16440. * edge artifacts on steep falloff.
  16441. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16442. */
  16443. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16444. /**
  16445. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16446. * edge artifacts on steep falloff.
  16447. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16448. */
  16449. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16450. /**
  16451. * Shadow generator mode PCF: Percentage Closer Filtering
  16452. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16453. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16454. */
  16455. static readonly FILTER_PCF: number;
  16456. /**
  16457. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16458. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16459. * Contact Hardening
  16460. */
  16461. static readonly FILTER_PCSS: number;
  16462. /**
  16463. * Reserved for PCF and PCSS
  16464. * Highest Quality.
  16465. *
  16466. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16467. *
  16468. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16469. */
  16470. static readonly QUALITY_HIGH: number;
  16471. /**
  16472. * Reserved for PCF and PCSS
  16473. * Good tradeoff for quality/perf cross devices
  16474. *
  16475. * Execute PCF on a 3*3 kernel.
  16476. *
  16477. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16478. */
  16479. static readonly QUALITY_MEDIUM: number;
  16480. /**
  16481. * Reserved for PCF and PCSS
  16482. * The lowest quality but the fastest.
  16483. *
  16484. * Execute PCF on a 1*1 kernel.
  16485. *
  16486. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16487. */
  16488. static readonly QUALITY_LOW: number;
  16489. /** Gets or sets the custom shader name to use */
  16490. customShaderOptions: ICustomShaderOptions;
  16491. /**
  16492. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16493. */
  16494. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16495. /**
  16496. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16497. */
  16498. onAfterShadowMapRenderObservable: Observable<Effect>;
  16499. /**
  16500. * Observable triggered before a mesh is rendered in the shadow map.
  16501. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16502. */
  16503. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16504. /**
  16505. * Observable triggered after a mesh is rendered in the shadow map.
  16506. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16507. */
  16508. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16509. protected _bias: number;
  16510. /**
  16511. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16512. */
  16513. get bias(): number;
  16514. /**
  16515. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16516. */
  16517. set bias(bias: number);
  16518. protected _normalBias: number;
  16519. /**
  16520. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16521. */
  16522. get normalBias(): number;
  16523. /**
  16524. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16525. */
  16526. set normalBias(normalBias: number);
  16527. protected _blurBoxOffset: number;
  16528. /**
  16529. * Gets the blur box offset: offset applied during the blur pass.
  16530. * Only useful if useKernelBlur = false
  16531. */
  16532. get blurBoxOffset(): number;
  16533. /**
  16534. * Sets the blur box offset: offset applied during the blur pass.
  16535. * Only useful if useKernelBlur = false
  16536. */
  16537. set blurBoxOffset(value: number);
  16538. protected _blurScale: number;
  16539. /**
  16540. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16541. * 2 means half of the size.
  16542. */
  16543. get blurScale(): number;
  16544. /**
  16545. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16546. * 2 means half of the size.
  16547. */
  16548. set blurScale(value: number);
  16549. protected _blurKernel: number;
  16550. /**
  16551. * Gets the blur kernel: kernel size of the blur pass.
  16552. * Only useful if useKernelBlur = true
  16553. */
  16554. get blurKernel(): number;
  16555. /**
  16556. * Sets the blur kernel: kernel size of the blur pass.
  16557. * Only useful if useKernelBlur = true
  16558. */
  16559. set blurKernel(value: number);
  16560. protected _useKernelBlur: boolean;
  16561. /**
  16562. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16563. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16564. */
  16565. get useKernelBlur(): boolean;
  16566. /**
  16567. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16568. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16569. */
  16570. set useKernelBlur(value: boolean);
  16571. protected _depthScale: number;
  16572. /**
  16573. * Gets the depth scale used in ESM mode.
  16574. */
  16575. get depthScale(): number;
  16576. /**
  16577. * Sets the depth scale used in ESM mode.
  16578. * This can override the scale stored on the light.
  16579. */
  16580. set depthScale(value: number);
  16581. protected _validateFilter(filter: number): number;
  16582. protected _filter: number;
  16583. /**
  16584. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16585. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16586. */
  16587. get filter(): number;
  16588. /**
  16589. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16590. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16591. */
  16592. set filter(value: number);
  16593. /**
  16594. * Gets if the current filter is set to Poisson Sampling.
  16595. */
  16596. get usePoissonSampling(): boolean;
  16597. /**
  16598. * Sets the current filter to Poisson Sampling.
  16599. */
  16600. set usePoissonSampling(value: boolean);
  16601. /**
  16602. * Gets if the current filter is set to ESM.
  16603. */
  16604. get useExponentialShadowMap(): boolean;
  16605. /**
  16606. * Sets the current filter is to ESM.
  16607. */
  16608. set useExponentialShadowMap(value: boolean);
  16609. /**
  16610. * Gets if the current filter is set to filtered ESM.
  16611. */
  16612. get useBlurExponentialShadowMap(): boolean;
  16613. /**
  16614. * Gets if the current filter is set to filtered ESM.
  16615. */
  16616. set useBlurExponentialShadowMap(value: boolean);
  16617. /**
  16618. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16619. * exponential to prevent steep falloff artifacts).
  16620. */
  16621. get useCloseExponentialShadowMap(): boolean;
  16622. /**
  16623. * Sets the current filter to "close ESM" (using the inverse of the
  16624. * exponential to prevent steep falloff artifacts).
  16625. */
  16626. set useCloseExponentialShadowMap(value: boolean);
  16627. /**
  16628. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16629. * exponential to prevent steep falloff artifacts).
  16630. */
  16631. get useBlurCloseExponentialShadowMap(): boolean;
  16632. /**
  16633. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16634. * exponential to prevent steep falloff artifacts).
  16635. */
  16636. set useBlurCloseExponentialShadowMap(value: boolean);
  16637. /**
  16638. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16639. */
  16640. get usePercentageCloserFiltering(): boolean;
  16641. /**
  16642. * Sets the current filter to "PCF" (percentage closer filtering).
  16643. */
  16644. set usePercentageCloserFiltering(value: boolean);
  16645. protected _filteringQuality: number;
  16646. /**
  16647. * Gets the PCF or PCSS Quality.
  16648. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16649. */
  16650. get filteringQuality(): number;
  16651. /**
  16652. * Sets the PCF or PCSS Quality.
  16653. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16654. */
  16655. set filteringQuality(filteringQuality: number);
  16656. /**
  16657. * Gets if the current filter is set to "PCSS" (contact hardening).
  16658. */
  16659. get useContactHardeningShadow(): boolean;
  16660. /**
  16661. * Sets the current filter to "PCSS" (contact hardening).
  16662. */
  16663. set useContactHardeningShadow(value: boolean);
  16664. protected _contactHardeningLightSizeUVRatio: number;
  16665. /**
  16666. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16667. * Using a ratio helps keeping shape stability independently of the map size.
  16668. *
  16669. * It does not account for the light projection as it was having too much
  16670. * instability during the light setup or during light position changes.
  16671. *
  16672. * Only valid if useContactHardeningShadow is true.
  16673. */
  16674. get contactHardeningLightSizeUVRatio(): number;
  16675. /**
  16676. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16677. * Using a ratio helps keeping shape stability independently of the map size.
  16678. *
  16679. * It does not account for the light projection as it was having too much
  16680. * instability during the light setup or during light position changes.
  16681. *
  16682. * Only valid if useContactHardeningShadow is true.
  16683. */
  16684. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16685. protected _darkness: number;
  16686. /** Gets or sets the actual darkness of a shadow */
  16687. get darkness(): number;
  16688. set darkness(value: number);
  16689. /**
  16690. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16691. * 0 means strongest and 1 would means no shadow.
  16692. * @returns the darkness.
  16693. */
  16694. getDarkness(): number;
  16695. /**
  16696. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16697. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16698. * @returns the shadow generator allowing fluent coding.
  16699. */
  16700. setDarkness(darkness: number): ShadowGenerator;
  16701. protected _transparencyShadow: boolean;
  16702. /** Gets or sets the ability to have transparent shadow */
  16703. get transparencyShadow(): boolean;
  16704. set transparencyShadow(value: boolean);
  16705. /**
  16706. * Sets the ability to have transparent shadow (boolean).
  16707. * @param transparent True if transparent else False
  16708. * @returns the shadow generator allowing fluent coding
  16709. */
  16710. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16711. protected _shadowMap: Nullable<RenderTargetTexture>;
  16712. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16713. /**
  16714. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16715. * @returns The render target texture if present otherwise, null
  16716. */
  16717. getShadowMap(): Nullable<RenderTargetTexture>;
  16718. /**
  16719. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16720. * @returns The render target texture if the shadow map is present otherwise, null
  16721. */
  16722. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16723. /**
  16724. * Gets the class name of that object
  16725. * @returns "ShadowGenerator"
  16726. */
  16727. getClassName(): string;
  16728. /**
  16729. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16730. * @param mesh Mesh to add
  16731. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16732. * @returns the Shadow Generator itself
  16733. */
  16734. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16735. /**
  16736. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16737. * @param mesh Mesh to remove
  16738. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16739. * @returns the Shadow Generator itself
  16740. */
  16741. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16742. /**
  16743. * Controls the extent to which the shadows fade out at the edge of the frustum
  16744. */
  16745. frustumEdgeFalloff: number;
  16746. protected _light: IShadowLight;
  16747. /**
  16748. * Returns the associated light object.
  16749. * @returns the light generating the shadow
  16750. */
  16751. getLight(): IShadowLight;
  16752. /**
  16753. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16754. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16755. * It might on the other hand introduce peter panning.
  16756. */
  16757. forceBackFacesOnly: boolean;
  16758. protected _scene: Scene;
  16759. protected _lightDirection: Vector3;
  16760. protected _effect: Effect;
  16761. protected _viewMatrix: Matrix;
  16762. protected _projectionMatrix: Matrix;
  16763. protected _transformMatrix: Matrix;
  16764. protected _cachedPosition: Vector3;
  16765. protected _cachedDirection: Vector3;
  16766. protected _cachedDefines: string;
  16767. protected _currentRenderID: number;
  16768. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16769. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16770. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16771. protected _blurPostProcesses: PostProcess[];
  16772. protected _mapSize: number;
  16773. protected _currentFaceIndex: number;
  16774. protected _currentFaceIndexCache: number;
  16775. protected _textureType: number;
  16776. protected _defaultTextureMatrix: Matrix;
  16777. protected _storedUniqueId: Nullable<number>;
  16778. /** @hidden */
  16779. static _SceneComponentInitialization: (scene: Scene) => void;
  16780. /**
  16781. * Creates a ShadowGenerator object.
  16782. * A ShadowGenerator is the required tool to use the shadows.
  16783. * Each light casting shadows needs to use its own ShadowGenerator.
  16784. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16785. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16786. * @param light The light object generating the shadows.
  16787. * @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.
  16788. */
  16789. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16790. protected _initializeGenerator(): void;
  16791. protected _createTargetRenderTexture(): void;
  16792. protected _initializeShadowMap(): void;
  16793. protected _initializeBlurRTTAndPostProcesses(): void;
  16794. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16795. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16796. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16797. protected _applyFilterValues(): void;
  16798. /**
  16799. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16800. * @param onCompiled Callback triggered at the and of the effects compilation
  16801. * @param options Sets of optional options forcing the compilation with different modes
  16802. */
  16803. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16804. useInstances: boolean;
  16805. }>): void;
  16806. /**
  16807. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16808. * @param options Sets of optional options forcing the compilation with different modes
  16809. * @returns A promise that resolves when the compilation completes
  16810. */
  16811. forceCompilationAsync(options?: Partial<{
  16812. useInstances: boolean;
  16813. }>): Promise<void>;
  16814. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16815. private _prepareShadowDefines;
  16816. /**
  16817. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16818. * @param subMesh The submesh we want to render in the shadow map
  16819. * @param useInstances Defines wether will draw in the map using instances
  16820. * @returns true if ready otherwise, false
  16821. */
  16822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16823. /**
  16824. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16825. * @param defines Defines of the material we want to update
  16826. * @param lightIndex Index of the light in the enabled light list of the material
  16827. */
  16828. prepareDefines(defines: any, lightIndex: number): void;
  16829. /**
  16830. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16831. * defined in the generator but impacting the effect).
  16832. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16833. * @param effect The effect we are binfing the information for
  16834. */
  16835. bindShadowLight(lightIndex: string, effect: Effect): void;
  16836. /**
  16837. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16838. * (eq to shadow prjection matrix * light transform matrix)
  16839. * @returns The transform matrix used to create the shadow map
  16840. */
  16841. getTransformMatrix(): Matrix;
  16842. /**
  16843. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16844. * Cube and 2D textures for instance.
  16845. */
  16846. recreateShadowMap(): void;
  16847. protected _disposeBlurPostProcesses(): void;
  16848. protected _disposeRTTandPostProcesses(): void;
  16849. /**
  16850. * Disposes the ShadowGenerator.
  16851. * Returns nothing.
  16852. */
  16853. dispose(): void;
  16854. /**
  16855. * Serializes the shadow generator setup to a json object.
  16856. * @returns The serialized JSON object
  16857. */
  16858. serialize(): any;
  16859. /**
  16860. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16861. * @param parsedShadowGenerator The JSON object to parse
  16862. * @param scene The scene to create the shadow map for
  16863. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16864. * @returns The parsed shadow generator
  16865. */
  16866. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16867. }
  16868. }
  16869. declare module BABYLON {
  16870. /**
  16871. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16872. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16873. * 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.
  16874. */
  16875. export abstract class Light extends Node {
  16876. /**
  16877. * Falloff Default: light is falling off following the material specification:
  16878. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16879. */
  16880. static readonly FALLOFF_DEFAULT: number;
  16881. /**
  16882. * Falloff Physical: light is falling off following the inverse squared distance law.
  16883. */
  16884. static readonly FALLOFF_PHYSICAL: number;
  16885. /**
  16886. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16887. * to enhance interoperability with other engines.
  16888. */
  16889. static readonly FALLOFF_GLTF: number;
  16890. /**
  16891. * Falloff Standard: light is falling off like in the standard material
  16892. * to enhance interoperability with other materials.
  16893. */
  16894. static readonly FALLOFF_STANDARD: number;
  16895. /**
  16896. * If every light affecting the material is in this lightmapMode,
  16897. * material.lightmapTexture adds or multiplies
  16898. * (depends on material.useLightmapAsShadowmap)
  16899. * after every other light calculations.
  16900. */
  16901. static readonly LIGHTMAP_DEFAULT: number;
  16902. /**
  16903. * material.lightmapTexture as only diffuse lighting from this light
  16904. * adds only specular lighting from this light
  16905. * adds dynamic shadows
  16906. */
  16907. static readonly LIGHTMAP_SPECULAR: number;
  16908. /**
  16909. * material.lightmapTexture as only lighting
  16910. * no light calculation from this light
  16911. * only adds dynamic shadows from this light
  16912. */
  16913. static readonly LIGHTMAP_SHADOWSONLY: number;
  16914. /**
  16915. * Each light type uses the default quantity according to its type:
  16916. * point/spot lights use luminous intensity
  16917. * directional lights use illuminance
  16918. */
  16919. static readonly INTENSITYMODE_AUTOMATIC: number;
  16920. /**
  16921. * lumen (lm)
  16922. */
  16923. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16924. /**
  16925. * candela (lm/sr)
  16926. */
  16927. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16928. /**
  16929. * lux (lm/m^2)
  16930. */
  16931. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16932. /**
  16933. * nit (cd/m^2)
  16934. */
  16935. static readonly INTENSITYMODE_LUMINANCE: number;
  16936. /**
  16937. * Light type const id of the point light.
  16938. */
  16939. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16940. /**
  16941. * Light type const id of the directional light.
  16942. */
  16943. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16944. /**
  16945. * Light type const id of the spot light.
  16946. */
  16947. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16948. /**
  16949. * Light type const id of the hemispheric light.
  16950. */
  16951. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16952. /**
  16953. * Diffuse gives the basic color to an object.
  16954. */
  16955. diffuse: Color3;
  16956. /**
  16957. * Specular produces a highlight color on an object.
  16958. * Note: This is note affecting PBR materials.
  16959. */
  16960. specular: Color3;
  16961. /**
  16962. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16963. * falling off base on range or angle.
  16964. * This can be set to any values in Light.FALLOFF_x.
  16965. *
  16966. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16967. * other types of materials.
  16968. */
  16969. falloffType: number;
  16970. /**
  16971. * Strength of the light.
  16972. * Note: By default it is define in the framework own unit.
  16973. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16974. */
  16975. intensity: number;
  16976. private _range;
  16977. protected _inverseSquaredRange: number;
  16978. /**
  16979. * Defines how far from the source the light is impacting in scene units.
  16980. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16981. */
  16982. get range(): number;
  16983. /**
  16984. * Defines how far from the source the light is impacting in scene units.
  16985. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16986. */
  16987. set range(value: number);
  16988. /**
  16989. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16990. * of light.
  16991. */
  16992. private _photometricScale;
  16993. private _intensityMode;
  16994. /**
  16995. * Gets the photometric scale used to interpret the intensity.
  16996. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16997. */
  16998. get intensityMode(): number;
  16999. /**
  17000. * Sets the photometric scale used to interpret the intensity.
  17001. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17002. */
  17003. set intensityMode(value: number);
  17004. private _radius;
  17005. /**
  17006. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17007. */
  17008. get radius(): number;
  17009. /**
  17010. * sets the light radius used by PBR Materials to simulate soft area lights.
  17011. */
  17012. set radius(value: number);
  17013. private _renderPriority;
  17014. /**
  17015. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17016. * exceeding the number allowed of the materials.
  17017. */
  17018. renderPriority: number;
  17019. private _shadowEnabled;
  17020. /**
  17021. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17022. * the current shadow generator.
  17023. */
  17024. get shadowEnabled(): boolean;
  17025. /**
  17026. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17027. * the current shadow generator.
  17028. */
  17029. set shadowEnabled(value: boolean);
  17030. private _includedOnlyMeshes;
  17031. /**
  17032. * Gets the only meshes impacted by this light.
  17033. */
  17034. get includedOnlyMeshes(): AbstractMesh[];
  17035. /**
  17036. * Sets the only meshes impacted by this light.
  17037. */
  17038. set includedOnlyMeshes(value: AbstractMesh[]);
  17039. private _excludedMeshes;
  17040. /**
  17041. * Gets the meshes not impacted by this light.
  17042. */
  17043. get excludedMeshes(): AbstractMesh[];
  17044. /**
  17045. * Sets the meshes not impacted by this light.
  17046. */
  17047. set excludedMeshes(value: AbstractMesh[]);
  17048. private _excludeWithLayerMask;
  17049. /**
  17050. * Gets the layer id use to find what meshes are not impacted by the light.
  17051. * Inactive if 0
  17052. */
  17053. get excludeWithLayerMask(): number;
  17054. /**
  17055. * Sets the layer id use to find what meshes are not impacted by the light.
  17056. * Inactive if 0
  17057. */
  17058. set excludeWithLayerMask(value: number);
  17059. private _includeOnlyWithLayerMask;
  17060. /**
  17061. * Gets the layer id use to find what meshes are impacted by the light.
  17062. * Inactive if 0
  17063. */
  17064. get includeOnlyWithLayerMask(): number;
  17065. /**
  17066. * Sets the layer id use to find what meshes are impacted by the light.
  17067. * Inactive if 0
  17068. */
  17069. set includeOnlyWithLayerMask(value: number);
  17070. private _lightmapMode;
  17071. /**
  17072. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17073. */
  17074. get lightmapMode(): number;
  17075. /**
  17076. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17077. */
  17078. set lightmapMode(value: number);
  17079. /**
  17080. * Shadow generator associted to the light.
  17081. * @hidden Internal use only.
  17082. */
  17083. _shadowGenerator: Nullable<IShadowGenerator>;
  17084. /**
  17085. * @hidden Internal use only.
  17086. */
  17087. _excludedMeshesIds: string[];
  17088. /**
  17089. * @hidden Internal use only.
  17090. */
  17091. _includedOnlyMeshesIds: string[];
  17092. /**
  17093. * The current light unifom buffer.
  17094. * @hidden Internal use only.
  17095. */
  17096. _uniformBuffer: UniformBuffer;
  17097. /** @hidden */
  17098. _renderId: number;
  17099. /**
  17100. * Creates a Light object in the scene.
  17101. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17102. * @param name The firendly name of the light
  17103. * @param scene The scene the light belongs too
  17104. */
  17105. constructor(name: string, scene: Scene);
  17106. protected abstract _buildUniformLayout(): void;
  17107. /**
  17108. * Sets the passed Effect "effect" with the Light information.
  17109. * @param effect The effect to update
  17110. * @param lightIndex The index of the light in the effect to update
  17111. * @returns The light
  17112. */
  17113. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17114. /**
  17115. * Sets the passed Effect "effect" with the Light textures.
  17116. * @param effect The effect to update
  17117. * @param lightIndex The index of the light in the effect to update
  17118. * @returns The light
  17119. */
  17120. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17121. /**
  17122. * Binds the lights information from the scene to the effect for the given mesh.
  17123. * @param lightIndex Light index
  17124. * @param scene The scene where the light belongs to
  17125. * @param effect The effect we are binding the data to
  17126. * @param useSpecular Defines if specular is supported
  17127. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17128. */
  17129. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17130. /**
  17131. * Sets the passed Effect "effect" with the Light information.
  17132. * @param effect The effect to update
  17133. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17134. * @returns The light
  17135. */
  17136. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17137. /**
  17138. * Returns the string "Light".
  17139. * @returns the class name
  17140. */
  17141. getClassName(): string;
  17142. /** @hidden */
  17143. readonly _isLight: boolean;
  17144. /**
  17145. * Converts the light information to a readable string for debug purpose.
  17146. * @param fullDetails Supports for multiple levels of logging within scene loading
  17147. * @returns the human readable light info
  17148. */
  17149. toString(fullDetails?: boolean): string;
  17150. /** @hidden */
  17151. protected _syncParentEnabledState(): void;
  17152. /**
  17153. * Set the enabled state of this node.
  17154. * @param value - the new enabled state
  17155. */
  17156. setEnabled(value: boolean): void;
  17157. /**
  17158. * Returns the Light associated shadow generator if any.
  17159. * @return the associated shadow generator.
  17160. */
  17161. getShadowGenerator(): Nullable<IShadowGenerator>;
  17162. /**
  17163. * Returns a Vector3, the absolute light position in the World.
  17164. * @returns the world space position of the light
  17165. */
  17166. getAbsolutePosition(): Vector3;
  17167. /**
  17168. * Specifies if the light will affect the passed mesh.
  17169. * @param mesh The mesh to test against the light
  17170. * @return true the mesh is affected otherwise, false.
  17171. */
  17172. canAffectMesh(mesh: AbstractMesh): boolean;
  17173. /**
  17174. * Sort function to order lights for rendering.
  17175. * @param a First Light object to compare to second.
  17176. * @param b Second Light object to compare first.
  17177. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17178. */
  17179. static CompareLightsPriority(a: Light, b: Light): number;
  17180. /**
  17181. * Releases resources associated with this node.
  17182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17184. */
  17185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17186. /**
  17187. * Returns the light type ID (integer).
  17188. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17189. */
  17190. getTypeID(): number;
  17191. /**
  17192. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17193. * @returns the scaled intensity in intensity mode unit
  17194. */
  17195. getScaledIntensity(): number;
  17196. /**
  17197. * Returns a new Light object, named "name", from the current one.
  17198. * @param name The name of the cloned light
  17199. * @returns the new created light
  17200. */
  17201. clone(name: string): Nullable<Light>;
  17202. /**
  17203. * Serializes the current light into a Serialization object.
  17204. * @returns the serialized object.
  17205. */
  17206. serialize(): any;
  17207. /**
  17208. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17209. * This new light is named "name" and added to the passed scene.
  17210. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17211. * @param name The friendly name of the light
  17212. * @param scene The scene the new light will belong to
  17213. * @returns the constructor function
  17214. */
  17215. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17216. /**
  17217. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17218. * @param parsedLight The JSON representation of the light
  17219. * @param scene The scene to create the parsed light in
  17220. * @returns the created light after parsing
  17221. */
  17222. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17223. private _hookArrayForExcluded;
  17224. private _hookArrayForIncludedOnly;
  17225. private _resyncMeshes;
  17226. /**
  17227. * Forces the meshes to update their light related information in their rendering used effects
  17228. * @hidden Internal Use Only
  17229. */
  17230. _markMeshesAsLightDirty(): void;
  17231. /**
  17232. * Recomputes the cached photometric scale if needed.
  17233. */
  17234. private _computePhotometricScale;
  17235. /**
  17236. * Returns the Photometric Scale according to the light type and intensity mode.
  17237. */
  17238. private _getPhotometricScale;
  17239. /**
  17240. * Reorder the light in the scene according to their defined priority.
  17241. * @hidden Internal Use Only
  17242. */
  17243. _reorderLightsInScene(): void;
  17244. /**
  17245. * Prepares the list of defines specific to the light type.
  17246. * @param defines the list of defines
  17247. * @param lightIndex defines the index of the light for the effect
  17248. */
  17249. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17250. }
  17251. }
  17252. declare module BABYLON {
  17253. /**
  17254. * Interface used to define Action
  17255. */
  17256. export interface IAction {
  17257. /**
  17258. * Trigger for the action
  17259. */
  17260. trigger: number;
  17261. /** Options of the trigger */
  17262. triggerOptions: any;
  17263. /**
  17264. * Gets the trigger parameters
  17265. * @returns the trigger parameters
  17266. */
  17267. getTriggerParameter(): any;
  17268. /**
  17269. * Internal only - executes current action event
  17270. * @hidden
  17271. */
  17272. _executeCurrent(evt?: ActionEvent): void;
  17273. /**
  17274. * Serialize placeholder for child classes
  17275. * @param parent of child
  17276. * @returns the serialized object
  17277. */
  17278. serialize(parent: any): any;
  17279. /**
  17280. * Internal only
  17281. * @hidden
  17282. */
  17283. _prepare(): void;
  17284. /**
  17285. * Internal only - manager for action
  17286. * @hidden
  17287. */
  17288. _actionManager: AbstractActionManager;
  17289. /**
  17290. * Adds action to chain of actions, may be a DoNothingAction
  17291. * @param action defines the next action to execute
  17292. * @returns The action passed in
  17293. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17294. */
  17295. then(action: IAction): IAction;
  17296. }
  17297. /**
  17298. * The action to be carried out following a trigger
  17299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17300. */
  17301. export class Action implements IAction {
  17302. /** the trigger, with or without parameters, for the action */
  17303. triggerOptions: any;
  17304. /**
  17305. * Trigger for the action
  17306. */
  17307. trigger: number;
  17308. /**
  17309. * Internal only - manager for action
  17310. * @hidden
  17311. */
  17312. _actionManager: ActionManager;
  17313. private _nextActiveAction;
  17314. private _child;
  17315. private _condition?;
  17316. private _triggerParameter;
  17317. /**
  17318. * An event triggered prior to action being executed.
  17319. */
  17320. onBeforeExecuteObservable: Observable<Action>;
  17321. /**
  17322. * Creates a new Action
  17323. * @param triggerOptions the trigger, with or without parameters, for the action
  17324. * @param condition an optional determinant of action
  17325. */
  17326. constructor(
  17327. /** the trigger, with or without parameters, for the action */
  17328. triggerOptions: any, condition?: Condition);
  17329. /**
  17330. * Internal only
  17331. * @hidden
  17332. */
  17333. _prepare(): void;
  17334. /**
  17335. * Gets the trigger parameters
  17336. * @returns the trigger parameters
  17337. */
  17338. getTriggerParameter(): any;
  17339. /**
  17340. * Internal only - executes current action event
  17341. * @hidden
  17342. */
  17343. _executeCurrent(evt?: ActionEvent): void;
  17344. /**
  17345. * Execute placeholder for child classes
  17346. * @param evt optional action event
  17347. */
  17348. execute(evt?: ActionEvent): void;
  17349. /**
  17350. * Skips to next active action
  17351. */
  17352. skipToNextActiveAction(): void;
  17353. /**
  17354. * Adds action to chain of actions, may be a DoNothingAction
  17355. * @param action defines the next action to execute
  17356. * @returns The action passed in
  17357. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17358. */
  17359. then(action: Action): Action;
  17360. /**
  17361. * Internal only
  17362. * @hidden
  17363. */
  17364. _getProperty(propertyPath: string): string;
  17365. /**
  17366. * Internal only
  17367. * @hidden
  17368. */
  17369. _getEffectiveTarget(target: any, propertyPath: string): any;
  17370. /**
  17371. * Serialize placeholder for child classes
  17372. * @param parent of child
  17373. * @returns the serialized object
  17374. */
  17375. serialize(parent: any): any;
  17376. /**
  17377. * Internal only called by serialize
  17378. * @hidden
  17379. */
  17380. protected _serialize(serializedAction: any, parent?: any): any;
  17381. /**
  17382. * Internal only
  17383. * @hidden
  17384. */
  17385. static _SerializeValueAsString: (value: any) => string;
  17386. /**
  17387. * Internal only
  17388. * @hidden
  17389. */
  17390. static _GetTargetProperty: (target: Node | Scene) => {
  17391. name: string;
  17392. targetType: string;
  17393. value: string;
  17394. };
  17395. }
  17396. }
  17397. declare module BABYLON {
  17398. /**
  17399. * A Condition applied to an Action
  17400. */
  17401. export class Condition {
  17402. /**
  17403. * Internal only - manager for action
  17404. * @hidden
  17405. */
  17406. _actionManager: ActionManager;
  17407. /**
  17408. * Internal only
  17409. * @hidden
  17410. */
  17411. _evaluationId: number;
  17412. /**
  17413. * Internal only
  17414. * @hidden
  17415. */
  17416. _currentResult: boolean;
  17417. /**
  17418. * Creates a new Condition
  17419. * @param actionManager the manager of the action the condition is applied to
  17420. */
  17421. constructor(actionManager: ActionManager);
  17422. /**
  17423. * Check if the current condition is valid
  17424. * @returns a boolean
  17425. */
  17426. isValid(): boolean;
  17427. /**
  17428. * Internal only
  17429. * @hidden
  17430. */
  17431. _getProperty(propertyPath: string): string;
  17432. /**
  17433. * Internal only
  17434. * @hidden
  17435. */
  17436. _getEffectiveTarget(target: any, propertyPath: string): any;
  17437. /**
  17438. * Serialize placeholder for child classes
  17439. * @returns the serialized object
  17440. */
  17441. serialize(): any;
  17442. /**
  17443. * Internal only
  17444. * @hidden
  17445. */
  17446. protected _serialize(serializedCondition: any): any;
  17447. }
  17448. /**
  17449. * Defines specific conditional operators as extensions of Condition
  17450. */
  17451. export class ValueCondition extends Condition {
  17452. /** path to specify the property of the target the conditional operator uses */
  17453. propertyPath: string;
  17454. /** the value compared by the conditional operator against the current value of the property */
  17455. value: any;
  17456. /** the conditional operator, default ValueCondition.IsEqual */
  17457. operator: number;
  17458. /**
  17459. * Internal only
  17460. * @hidden
  17461. */
  17462. private static _IsEqual;
  17463. /**
  17464. * Internal only
  17465. * @hidden
  17466. */
  17467. private static _IsDifferent;
  17468. /**
  17469. * Internal only
  17470. * @hidden
  17471. */
  17472. private static _IsGreater;
  17473. /**
  17474. * Internal only
  17475. * @hidden
  17476. */
  17477. private static _IsLesser;
  17478. /**
  17479. * returns the number for IsEqual
  17480. */
  17481. static get IsEqual(): number;
  17482. /**
  17483. * Returns the number for IsDifferent
  17484. */
  17485. static get IsDifferent(): number;
  17486. /**
  17487. * Returns the number for IsGreater
  17488. */
  17489. static get IsGreater(): number;
  17490. /**
  17491. * Returns the number for IsLesser
  17492. */
  17493. static get IsLesser(): number;
  17494. /**
  17495. * Internal only The action manager for the condition
  17496. * @hidden
  17497. */
  17498. _actionManager: ActionManager;
  17499. /**
  17500. * Internal only
  17501. * @hidden
  17502. */
  17503. private _target;
  17504. /**
  17505. * Internal only
  17506. * @hidden
  17507. */
  17508. private _effectiveTarget;
  17509. /**
  17510. * Internal only
  17511. * @hidden
  17512. */
  17513. private _property;
  17514. /**
  17515. * Creates a new ValueCondition
  17516. * @param actionManager manager for the action the condition applies to
  17517. * @param target for the action
  17518. * @param propertyPath path to specify the property of the target the conditional operator uses
  17519. * @param value the value compared by the conditional operator against the current value of the property
  17520. * @param operator the conditional operator, default ValueCondition.IsEqual
  17521. */
  17522. constructor(actionManager: ActionManager, target: any,
  17523. /** path to specify the property of the target the conditional operator uses */
  17524. propertyPath: string,
  17525. /** the value compared by the conditional operator against the current value of the property */
  17526. value: any,
  17527. /** the conditional operator, default ValueCondition.IsEqual */
  17528. operator?: number);
  17529. /**
  17530. * Compares the given value with the property value for the specified conditional operator
  17531. * @returns the result of the comparison
  17532. */
  17533. isValid(): boolean;
  17534. /**
  17535. * Serialize the ValueCondition into a JSON compatible object
  17536. * @returns serialization object
  17537. */
  17538. serialize(): any;
  17539. /**
  17540. * Gets the name of the conditional operator for the ValueCondition
  17541. * @param operator the conditional operator
  17542. * @returns the name
  17543. */
  17544. static GetOperatorName(operator: number): string;
  17545. }
  17546. /**
  17547. * Defines a predicate condition as an extension of Condition
  17548. */
  17549. export class PredicateCondition extends Condition {
  17550. /** defines the predicate function used to validate the condition */
  17551. predicate: () => boolean;
  17552. /**
  17553. * Internal only - manager for action
  17554. * @hidden
  17555. */
  17556. _actionManager: ActionManager;
  17557. /**
  17558. * Creates a new PredicateCondition
  17559. * @param actionManager manager for the action the condition applies to
  17560. * @param predicate defines the predicate function used to validate the condition
  17561. */
  17562. constructor(actionManager: ActionManager,
  17563. /** defines the predicate function used to validate the condition */
  17564. predicate: () => boolean);
  17565. /**
  17566. * @returns the validity of the predicate condition
  17567. */
  17568. isValid(): boolean;
  17569. }
  17570. /**
  17571. * Defines a state condition as an extension of Condition
  17572. */
  17573. export class StateCondition extends Condition {
  17574. /** Value to compare with target state */
  17575. value: string;
  17576. /**
  17577. * Internal only - manager for action
  17578. * @hidden
  17579. */
  17580. _actionManager: ActionManager;
  17581. /**
  17582. * Internal only
  17583. * @hidden
  17584. */
  17585. private _target;
  17586. /**
  17587. * Creates a new StateCondition
  17588. * @param actionManager manager for the action the condition applies to
  17589. * @param target of the condition
  17590. * @param value to compare with target state
  17591. */
  17592. constructor(actionManager: ActionManager, target: any,
  17593. /** Value to compare with target state */
  17594. value: string);
  17595. /**
  17596. * Gets a boolean indicating if the current condition is met
  17597. * @returns the validity of the state
  17598. */
  17599. isValid(): boolean;
  17600. /**
  17601. * Serialize the StateCondition into a JSON compatible object
  17602. * @returns serialization object
  17603. */
  17604. serialize(): any;
  17605. }
  17606. }
  17607. declare module BABYLON {
  17608. /**
  17609. * This defines an action responsible to toggle a boolean once triggered.
  17610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17611. */
  17612. export class SwitchBooleanAction extends Action {
  17613. /**
  17614. * The path to the boolean property in the target object
  17615. */
  17616. propertyPath: string;
  17617. private _target;
  17618. private _effectiveTarget;
  17619. private _property;
  17620. /**
  17621. * Instantiate the action
  17622. * @param triggerOptions defines the trigger options
  17623. * @param target defines the object containing the boolean
  17624. * @param propertyPath defines the path to the boolean property in the target object
  17625. * @param condition defines the trigger related conditions
  17626. */
  17627. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17628. /** @hidden */
  17629. _prepare(): void;
  17630. /**
  17631. * Execute the action toggle the boolean value.
  17632. */
  17633. execute(): void;
  17634. /**
  17635. * Serializes the actions and its related information.
  17636. * @param parent defines the object to serialize in
  17637. * @returns the serialized object
  17638. */
  17639. serialize(parent: any): any;
  17640. }
  17641. /**
  17642. * This defines an action responsible to set a the state field of the target
  17643. * to a desired value once triggered.
  17644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17645. */
  17646. export class SetStateAction extends Action {
  17647. /**
  17648. * The value to store in the state field.
  17649. */
  17650. value: string;
  17651. private _target;
  17652. /**
  17653. * Instantiate the action
  17654. * @param triggerOptions defines the trigger options
  17655. * @param target defines the object containing the state property
  17656. * @param value defines the value to store in the state field
  17657. * @param condition defines the trigger related conditions
  17658. */
  17659. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17660. /**
  17661. * Execute the action and store the value on the target state property.
  17662. */
  17663. execute(): void;
  17664. /**
  17665. * Serializes the actions and its related information.
  17666. * @param parent defines the object to serialize in
  17667. * @returns the serialized object
  17668. */
  17669. serialize(parent: any): any;
  17670. }
  17671. /**
  17672. * This defines an action responsible to set a property of the target
  17673. * to a desired value once triggered.
  17674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17675. */
  17676. export class SetValueAction extends Action {
  17677. /**
  17678. * The path of the property to set in the target.
  17679. */
  17680. propertyPath: string;
  17681. /**
  17682. * The value to set in the property
  17683. */
  17684. value: any;
  17685. private _target;
  17686. private _effectiveTarget;
  17687. private _property;
  17688. /**
  17689. * Instantiate the action
  17690. * @param triggerOptions defines the trigger options
  17691. * @param target defines the object containing the property
  17692. * @param propertyPath defines the path of the property to set in the target
  17693. * @param value defines the value to set in the property
  17694. * @param condition defines the trigger related conditions
  17695. */
  17696. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17697. /** @hidden */
  17698. _prepare(): void;
  17699. /**
  17700. * Execute the action and set the targetted property to the desired value.
  17701. */
  17702. execute(): void;
  17703. /**
  17704. * Serializes the actions and its related information.
  17705. * @param parent defines the object to serialize in
  17706. * @returns the serialized object
  17707. */
  17708. serialize(parent: any): any;
  17709. }
  17710. /**
  17711. * This defines an action responsible to increment the target value
  17712. * to a desired value once triggered.
  17713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17714. */
  17715. export class IncrementValueAction extends Action {
  17716. /**
  17717. * The path of the property to increment in the target.
  17718. */
  17719. propertyPath: string;
  17720. /**
  17721. * The value we should increment the property by.
  17722. */
  17723. value: any;
  17724. private _target;
  17725. private _effectiveTarget;
  17726. private _property;
  17727. /**
  17728. * Instantiate the action
  17729. * @param triggerOptions defines the trigger options
  17730. * @param target defines the object containing the property
  17731. * @param propertyPath defines the path of the property to increment in the target
  17732. * @param value defines the value value we should increment the property by
  17733. * @param condition defines the trigger related conditions
  17734. */
  17735. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17736. /** @hidden */
  17737. _prepare(): void;
  17738. /**
  17739. * Execute the action and increment the target of the value amount.
  17740. */
  17741. execute(): void;
  17742. /**
  17743. * Serializes the actions and its related information.
  17744. * @param parent defines the object to serialize in
  17745. * @returns the serialized object
  17746. */
  17747. serialize(parent: any): any;
  17748. }
  17749. /**
  17750. * This defines an action responsible to start an animation once triggered.
  17751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17752. */
  17753. export class PlayAnimationAction extends Action {
  17754. /**
  17755. * Where the animation should start (animation frame)
  17756. */
  17757. from: number;
  17758. /**
  17759. * Where the animation should stop (animation frame)
  17760. */
  17761. to: number;
  17762. /**
  17763. * Define if the animation should loop or stop after the first play.
  17764. */
  17765. loop?: boolean;
  17766. private _target;
  17767. /**
  17768. * Instantiate the action
  17769. * @param triggerOptions defines the trigger options
  17770. * @param target defines the target animation or animation name
  17771. * @param from defines from where the animation should start (animation frame)
  17772. * @param end defines where the animation should stop (animation frame)
  17773. * @param loop defines if the animation should loop or stop after the first play
  17774. * @param condition defines the trigger related conditions
  17775. */
  17776. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17777. /** @hidden */
  17778. _prepare(): void;
  17779. /**
  17780. * Execute the action and play the animation.
  17781. */
  17782. execute(): void;
  17783. /**
  17784. * Serializes the actions and its related information.
  17785. * @param parent defines the object to serialize in
  17786. * @returns the serialized object
  17787. */
  17788. serialize(parent: any): any;
  17789. }
  17790. /**
  17791. * This defines an action responsible to stop an animation once triggered.
  17792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17793. */
  17794. export class StopAnimationAction extends Action {
  17795. private _target;
  17796. /**
  17797. * Instantiate the action
  17798. * @param triggerOptions defines the trigger options
  17799. * @param target defines the target animation or animation name
  17800. * @param condition defines the trigger related conditions
  17801. */
  17802. constructor(triggerOptions: any, target: any, condition?: Condition);
  17803. /** @hidden */
  17804. _prepare(): void;
  17805. /**
  17806. * Execute the action and stop the animation.
  17807. */
  17808. execute(): void;
  17809. /**
  17810. * Serializes the actions and its related information.
  17811. * @param parent defines the object to serialize in
  17812. * @returns the serialized object
  17813. */
  17814. serialize(parent: any): any;
  17815. }
  17816. /**
  17817. * This defines an action responsible that does nothing once triggered.
  17818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17819. */
  17820. export class DoNothingAction extends Action {
  17821. /**
  17822. * Instantiate the action
  17823. * @param triggerOptions defines the trigger options
  17824. * @param condition defines the trigger related conditions
  17825. */
  17826. constructor(triggerOptions?: any, condition?: Condition);
  17827. /**
  17828. * Execute the action and do nothing.
  17829. */
  17830. execute(): void;
  17831. /**
  17832. * Serializes the actions and its related information.
  17833. * @param parent defines the object to serialize in
  17834. * @returns the serialized object
  17835. */
  17836. serialize(parent: any): any;
  17837. }
  17838. /**
  17839. * This defines an action responsible to trigger several actions once triggered.
  17840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17841. */
  17842. export class CombineAction extends Action {
  17843. /**
  17844. * The list of aggregated animations to run.
  17845. */
  17846. children: Action[];
  17847. /**
  17848. * Instantiate the action
  17849. * @param triggerOptions defines the trigger options
  17850. * @param children defines the list of aggregated animations to run
  17851. * @param condition defines the trigger related conditions
  17852. */
  17853. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17854. /** @hidden */
  17855. _prepare(): void;
  17856. /**
  17857. * Execute the action and executes all the aggregated actions.
  17858. */
  17859. execute(evt: ActionEvent): void;
  17860. /**
  17861. * Serializes the actions and its related information.
  17862. * @param parent defines the object to serialize in
  17863. * @returns the serialized object
  17864. */
  17865. serialize(parent: any): any;
  17866. }
  17867. /**
  17868. * This defines an action responsible to run code (external event) once triggered.
  17869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17870. */
  17871. export class ExecuteCodeAction extends Action {
  17872. /**
  17873. * The callback function to run.
  17874. */
  17875. func: (evt: ActionEvent) => void;
  17876. /**
  17877. * Instantiate the action
  17878. * @param triggerOptions defines the trigger options
  17879. * @param func defines the callback function to run
  17880. * @param condition defines the trigger related conditions
  17881. */
  17882. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17883. /**
  17884. * Execute the action and run the attached code.
  17885. */
  17886. execute(evt: ActionEvent): void;
  17887. }
  17888. /**
  17889. * This defines an action responsible to set the parent property of the target once triggered.
  17890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17891. */
  17892. export class SetParentAction extends Action {
  17893. private _parent;
  17894. private _target;
  17895. /**
  17896. * Instantiate the action
  17897. * @param triggerOptions defines the trigger options
  17898. * @param target defines the target containing the parent property
  17899. * @param parent defines from where the animation should start (animation frame)
  17900. * @param condition defines the trigger related conditions
  17901. */
  17902. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17903. /** @hidden */
  17904. _prepare(): void;
  17905. /**
  17906. * Execute the action and set the parent property.
  17907. */
  17908. execute(): void;
  17909. /**
  17910. * Serializes the actions and its related information.
  17911. * @param parent defines the object to serialize in
  17912. * @returns the serialized object
  17913. */
  17914. serialize(parent: any): any;
  17915. }
  17916. }
  17917. declare module BABYLON {
  17918. /**
  17919. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17920. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17922. */
  17923. export class ActionManager extends AbstractActionManager {
  17924. /**
  17925. * Nothing
  17926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17927. */
  17928. static readonly NothingTrigger: number;
  17929. /**
  17930. * On pick
  17931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17932. */
  17933. static readonly OnPickTrigger: number;
  17934. /**
  17935. * On left pick
  17936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17937. */
  17938. static readonly OnLeftPickTrigger: number;
  17939. /**
  17940. * On right pick
  17941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17942. */
  17943. static readonly OnRightPickTrigger: number;
  17944. /**
  17945. * On center pick
  17946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17947. */
  17948. static readonly OnCenterPickTrigger: number;
  17949. /**
  17950. * On pick down
  17951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17952. */
  17953. static readonly OnPickDownTrigger: number;
  17954. /**
  17955. * On double pick
  17956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17957. */
  17958. static readonly OnDoublePickTrigger: number;
  17959. /**
  17960. * On pick up
  17961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17962. */
  17963. static readonly OnPickUpTrigger: number;
  17964. /**
  17965. * On pick out.
  17966. * This trigger will only be raised if you also declared a OnPickDown
  17967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17968. */
  17969. static readonly OnPickOutTrigger: number;
  17970. /**
  17971. * On long press
  17972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17973. */
  17974. static readonly OnLongPressTrigger: number;
  17975. /**
  17976. * On pointer over
  17977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17978. */
  17979. static readonly OnPointerOverTrigger: number;
  17980. /**
  17981. * On pointer out
  17982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17983. */
  17984. static readonly OnPointerOutTrigger: number;
  17985. /**
  17986. * On every frame
  17987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17988. */
  17989. static readonly OnEveryFrameTrigger: number;
  17990. /**
  17991. * On intersection enter
  17992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17993. */
  17994. static readonly OnIntersectionEnterTrigger: number;
  17995. /**
  17996. * On intersection exit
  17997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17998. */
  17999. static readonly OnIntersectionExitTrigger: number;
  18000. /**
  18001. * On key down
  18002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18003. */
  18004. static readonly OnKeyDownTrigger: number;
  18005. /**
  18006. * On key up
  18007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18008. */
  18009. static readonly OnKeyUpTrigger: number;
  18010. private _scene;
  18011. /**
  18012. * Creates a new action manager
  18013. * @param scene defines the hosting scene
  18014. */
  18015. constructor(scene: Scene);
  18016. /**
  18017. * Releases all associated resources
  18018. */
  18019. dispose(): void;
  18020. /**
  18021. * Gets hosting scene
  18022. * @returns the hosting scene
  18023. */
  18024. getScene(): Scene;
  18025. /**
  18026. * Does this action manager handles actions of any of the given triggers
  18027. * @param triggers defines the triggers to be tested
  18028. * @return a boolean indicating whether one (or more) of the triggers is handled
  18029. */
  18030. hasSpecificTriggers(triggers: number[]): boolean;
  18031. /**
  18032. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18033. * speed.
  18034. * @param triggerA defines the trigger to be tested
  18035. * @param triggerB defines the trigger to be tested
  18036. * @return a boolean indicating whether one (or more) of the triggers is handled
  18037. */
  18038. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18039. /**
  18040. * Does this action manager handles actions of a given trigger
  18041. * @param trigger defines the trigger to be tested
  18042. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18043. * @return whether the trigger is handled
  18044. */
  18045. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18046. /**
  18047. * Does this action manager has pointer triggers
  18048. */
  18049. get hasPointerTriggers(): boolean;
  18050. /**
  18051. * Does this action manager has pick triggers
  18052. */
  18053. get hasPickTriggers(): boolean;
  18054. /**
  18055. * Registers an action to this action manager
  18056. * @param action defines the action to be registered
  18057. * @return the action amended (prepared) after registration
  18058. */
  18059. registerAction(action: IAction): Nullable<IAction>;
  18060. /**
  18061. * Unregisters an action to this action manager
  18062. * @param action defines the action to be unregistered
  18063. * @return a boolean indicating whether the action has been unregistered
  18064. */
  18065. unregisterAction(action: IAction): Boolean;
  18066. /**
  18067. * Process a specific trigger
  18068. * @param trigger defines the trigger to process
  18069. * @param evt defines the event details to be processed
  18070. */
  18071. processTrigger(trigger: number, evt?: IActionEvent): void;
  18072. /** @hidden */
  18073. _getEffectiveTarget(target: any, propertyPath: string): any;
  18074. /** @hidden */
  18075. _getProperty(propertyPath: string): string;
  18076. /**
  18077. * Serialize this manager to a JSON object
  18078. * @param name defines the property name to store this manager
  18079. * @returns a JSON representation of this manager
  18080. */
  18081. serialize(name: string): any;
  18082. /**
  18083. * Creates a new ActionManager from a JSON data
  18084. * @param parsedActions defines the JSON data to read from
  18085. * @param object defines the hosting mesh
  18086. * @param scene defines the hosting scene
  18087. */
  18088. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18089. /**
  18090. * Get a trigger name by index
  18091. * @param trigger defines the trigger index
  18092. * @returns a trigger name
  18093. */
  18094. static GetTriggerName(trigger: number): string;
  18095. }
  18096. }
  18097. declare module BABYLON {
  18098. /**
  18099. * Class used to represent a sprite
  18100. * @see http://doc.babylonjs.com/babylon101/sprites
  18101. */
  18102. export class Sprite {
  18103. /** defines the name */
  18104. name: string;
  18105. /** Gets or sets the current world position */
  18106. position: Vector3;
  18107. /** Gets or sets the main color */
  18108. color: Color4;
  18109. /** Gets or sets the width */
  18110. width: number;
  18111. /** Gets or sets the height */
  18112. height: number;
  18113. /** Gets or sets rotation angle */
  18114. angle: number;
  18115. /** Gets or sets the cell index in the sprite sheet */
  18116. cellIndex: number;
  18117. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18118. cellRef: string;
  18119. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18120. invertU: number;
  18121. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18122. invertV: number;
  18123. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18124. disposeWhenFinishedAnimating: boolean;
  18125. /** Gets the list of attached animations */
  18126. animations: Animation[];
  18127. /** Gets or sets a boolean indicating if the sprite can be picked */
  18128. isPickable: boolean;
  18129. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18130. useAlphaForPicking: boolean;
  18131. /** @hidden */
  18132. _xOffset: number;
  18133. /** @hidden */
  18134. _yOffset: number;
  18135. /** @hidden */
  18136. _xSize: number;
  18137. /** @hidden */
  18138. _ySize: number;
  18139. /**
  18140. * Gets or sets the associated action manager
  18141. */
  18142. actionManager: Nullable<ActionManager>;
  18143. private _animationStarted;
  18144. private _loopAnimation;
  18145. private _fromIndex;
  18146. private _toIndex;
  18147. private _delay;
  18148. private _direction;
  18149. private _manager;
  18150. private _time;
  18151. private _onAnimationEnd;
  18152. /**
  18153. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18154. */
  18155. isVisible: boolean;
  18156. /**
  18157. * Gets or sets the sprite size
  18158. */
  18159. get size(): number;
  18160. set size(value: number);
  18161. /**
  18162. * Creates a new Sprite
  18163. * @param name defines the name
  18164. * @param manager defines the manager
  18165. */
  18166. constructor(
  18167. /** defines the name */
  18168. name: string, manager: ISpriteManager);
  18169. /**
  18170. * Starts an animation
  18171. * @param from defines the initial key
  18172. * @param to defines the end key
  18173. * @param loop defines if the animation must loop
  18174. * @param delay defines the start delay (in ms)
  18175. * @param onAnimationEnd defines a callback to call when animation ends
  18176. */
  18177. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18178. /** Stops current animation (if any) */
  18179. stopAnimation(): void;
  18180. /** @hidden */
  18181. _animate(deltaTime: number): void;
  18182. /** Release associated resources */
  18183. dispose(): void;
  18184. }
  18185. }
  18186. declare module BABYLON {
  18187. /**
  18188. * Information about the result of picking within a scene
  18189. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18190. */
  18191. export class PickingInfo {
  18192. /** @hidden */
  18193. _pickingUnavailable: boolean;
  18194. /**
  18195. * If the pick collided with an object
  18196. */
  18197. hit: boolean;
  18198. /**
  18199. * Distance away where the pick collided
  18200. */
  18201. distance: number;
  18202. /**
  18203. * The location of pick collision
  18204. */
  18205. pickedPoint: Nullable<Vector3>;
  18206. /**
  18207. * The mesh corresponding the the pick collision
  18208. */
  18209. pickedMesh: Nullable<AbstractMesh>;
  18210. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18211. bu: number;
  18212. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18213. bv: number;
  18214. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18215. faceId: number;
  18216. /** Id of the the submesh that was picked */
  18217. subMeshId: number;
  18218. /** If a sprite was picked, this will be the sprite the pick collided with */
  18219. pickedSprite: Nullable<Sprite>;
  18220. /**
  18221. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18222. */
  18223. originMesh: Nullable<AbstractMesh>;
  18224. /**
  18225. * The ray that was used to perform the picking.
  18226. */
  18227. ray: Nullable<Ray>;
  18228. /**
  18229. * Gets the normal correspodning to the face the pick collided with
  18230. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18231. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18232. * @returns The normal correspodning to the face the pick collided with
  18233. */
  18234. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18235. /**
  18236. * Gets the texture coordinates of where the pick occured
  18237. * @returns the vector containing the coordnates of the texture
  18238. */
  18239. getTextureCoordinates(): Nullable<Vector2>;
  18240. }
  18241. }
  18242. declare module BABYLON {
  18243. /**
  18244. * Gather the list of pointer event types as constants.
  18245. */
  18246. export class PointerEventTypes {
  18247. /**
  18248. * 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.
  18249. */
  18250. static readonly POINTERDOWN: number;
  18251. /**
  18252. * The pointerup event is fired when a pointer is no longer active.
  18253. */
  18254. static readonly POINTERUP: number;
  18255. /**
  18256. * The pointermove event is fired when a pointer changes coordinates.
  18257. */
  18258. static readonly POINTERMOVE: number;
  18259. /**
  18260. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18261. */
  18262. static readonly POINTERWHEEL: number;
  18263. /**
  18264. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18265. */
  18266. static readonly POINTERPICK: number;
  18267. /**
  18268. * The pointertap event is fired when a the object has been touched and released without drag.
  18269. */
  18270. static readonly POINTERTAP: number;
  18271. /**
  18272. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18273. */
  18274. static readonly POINTERDOUBLETAP: number;
  18275. }
  18276. /**
  18277. * Base class of pointer info types.
  18278. */
  18279. export class PointerInfoBase {
  18280. /**
  18281. * Defines the type of event (PointerEventTypes)
  18282. */
  18283. type: number;
  18284. /**
  18285. * Defines the related dom event
  18286. */
  18287. event: PointerEvent | MouseWheelEvent;
  18288. /**
  18289. * Instantiates the base class of pointers info.
  18290. * @param type Defines the type of event (PointerEventTypes)
  18291. * @param event Defines the related dom event
  18292. */
  18293. constructor(
  18294. /**
  18295. * Defines the type of event (PointerEventTypes)
  18296. */
  18297. type: number,
  18298. /**
  18299. * Defines the related dom event
  18300. */
  18301. event: PointerEvent | MouseWheelEvent);
  18302. }
  18303. /**
  18304. * This class is used to store pointer related info for the onPrePointerObservable event.
  18305. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18306. */
  18307. export class PointerInfoPre extends PointerInfoBase {
  18308. /**
  18309. * Ray from a pointer if availible (eg. 6dof controller)
  18310. */
  18311. ray: Nullable<Ray>;
  18312. /**
  18313. * Defines the local position of the pointer on the canvas.
  18314. */
  18315. localPosition: Vector2;
  18316. /**
  18317. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18318. */
  18319. skipOnPointerObservable: boolean;
  18320. /**
  18321. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18322. * @param type Defines the type of event (PointerEventTypes)
  18323. * @param event Defines the related dom event
  18324. * @param localX Defines the local x coordinates of the pointer when the event occured
  18325. * @param localY Defines the local y coordinates of the pointer when the event occured
  18326. */
  18327. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18328. }
  18329. /**
  18330. * This type contains all the data related to a pointer event in Babylon.js.
  18331. * 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.
  18332. */
  18333. export class PointerInfo extends PointerInfoBase {
  18334. /**
  18335. * Defines the picking info associated to the info (if any)\
  18336. */
  18337. pickInfo: Nullable<PickingInfo>;
  18338. /**
  18339. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18340. * @param type Defines the type of event (PointerEventTypes)
  18341. * @param event Defines the related dom event
  18342. * @param pickInfo Defines the picking info associated to the info (if any)\
  18343. */
  18344. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18345. /**
  18346. * Defines the picking info associated to the info (if any)\
  18347. */
  18348. pickInfo: Nullable<PickingInfo>);
  18349. }
  18350. /**
  18351. * Data relating to a touch event on the screen.
  18352. */
  18353. export interface PointerTouch {
  18354. /**
  18355. * X coordinate of touch.
  18356. */
  18357. x: number;
  18358. /**
  18359. * Y coordinate of touch.
  18360. */
  18361. y: number;
  18362. /**
  18363. * Id of touch. Unique for each finger.
  18364. */
  18365. pointerId: number;
  18366. /**
  18367. * Event type passed from DOM.
  18368. */
  18369. type: any;
  18370. }
  18371. }
  18372. declare module BABYLON {
  18373. /**
  18374. * Manage the mouse inputs to control the movement of a free camera.
  18375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18376. */
  18377. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18378. /**
  18379. * Define if touch is enabled in the mouse input
  18380. */
  18381. touchEnabled: boolean;
  18382. /**
  18383. * Defines the camera the input is attached to.
  18384. */
  18385. camera: FreeCamera;
  18386. /**
  18387. * Defines the buttons associated with the input to handle camera move.
  18388. */
  18389. buttons: number[];
  18390. /**
  18391. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18392. */
  18393. angularSensibility: number;
  18394. private _pointerInput;
  18395. private _onMouseMove;
  18396. private _observer;
  18397. private previousPosition;
  18398. /**
  18399. * Observable for when a pointer move event occurs containing the move offset
  18400. */
  18401. onPointerMovedObservable: Observable<{
  18402. offsetX: number;
  18403. offsetY: number;
  18404. }>;
  18405. /**
  18406. * @hidden
  18407. * If the camera should be rotated automatically based on pointer movement
  18408. */
  18409. _allowCameraRotation: boolean;
  18410. /**
  18411. * Manage the mouse inputs to control the movement of a free camera.
  18412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18413. * @param touchEnabled Defines if touch is enabled or not
  18414. */
  18415. constructor(
  18416. /**
  18417. * Define if touch is enabled in the mouse input
  18418. */
  18419. touchEnabled?: boolean);
  18420. /**
  18421. * Attach the input controls to a specific dom element to get the input from.
  18422. * @param element Defines the element the controls should be listened from
  18423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18424. */
  18425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18426. /**
  18427. * Called on JS contextmenu event.
  18428. * Override this method to provide functionality.
  18429. */
  18430. protected onContextMenu(evt: PointerEvent): void;
  18431. /**
  18432. * Detach the current controls from the specified dom element.
  18433. * @param element Defines the element to stop listening the inputs from
  18434. */
  18435. detachControl(element: Nullable<HTMLElement>): void;
  18436. /**
  18437. * Gets the class name of the current intput.
  18438. * @returns the class name
  18439. */
  18440. getClassName(): string;
  18441. /**
  18442. * Get the friendly name associated with the input class.
  18443. * @returns the input friendly name
  18444. */
  18445. getSimpleName(): string;
  18446. }
  18447. }
  18448. declare module BABYLON {
  18449. /**
  18450. * Manage the touch inputs to control the movement of a free camera.
  18451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18452. */
  18453. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18454. /**
  18455. * Defines the camera the input is attached to.
  18456. */
  18457. camera: FreeCamera;
  18458. /**
  18459. * Defines the touch sensibility for rotation.
  18460. * The higher the faster.
  18461. */
  18462. touchAngularSensibility: number;
  18463. /**
  18464. * Defines the touch sensibility for move.
  18465. * The higher the faster.
  18466. */
  18467. touchMoveSensibility: number;
  18468. private _offsetX;
  18469. private _offsetY;
  18470. private _pointerPressed;
  18471. private _pointerInput;
  18472. private _observer;
  18473. private _onLostFocus;
  18474. /**
  18475. * Attach the input controls to a specific dom element to get the input from.
  18476. * @param element Defines the element the controls should be listened from
  18477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18478. */
  18479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18480. /**
  18481. * Detach the current controls from the specified dom element.
  18482. * @param element Defines the element to stop listening the inputs from
  18483. */
  18484. detachControl(element: Nullable<HTMLElement>): void;
  18485. /**
  18486. * Update the current camera state depending on the inputs that have been used this frame.
  18487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18488. */
  18489. checkInputs(): void;
  18490. /**
  18491. * Gets the class name of the current intput.
  18492. * @returns the class name
  18493. */
  18494. getClassName(): string;
  18495. /**
  18496. * Get the friendly name associated with the input class.
  18497. * @returns the input friendly name
  18498. */
  18499. getSimpleName(): string;
  18500. }
  18501. }
  18502. declare module BABYLON {
  18503. /**
  18504. * Default Inputs manager for the FreeCamera.
  18505. * It groups all the default supported inputs for ease of use.
  18506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18507. */
  18508. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18509. /**
  18510. * @hidden
  18511. */
  18512. _mouseInput: Nullable<FreeCameraMouseInput>;
  18513. /**
  18514. * Instantiates a new FreeCameraInputsManager.
  18515. * @param camera Defines the camera the inputs belong to
  18516. */
  18517. constructor(camera: FreeCamera);
  18518. /**
  18519. * Add keyboard input support to the input manager.
  18520. * @returns the current input manager
  18521. */
  18522. addKeyboard(): FreeCameraInputsManager;
  18523. /**
  18524. * Add mouse input support to the input manager.
  18525. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18526. * @returns the current input manager
  18527. */
  18528. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18529. /**
  18530. * Removes the mouse input support from the manager
  18531. * @returns the current input manager
  18532. */
  18533. removeMouse(): FreeCameraInputsManager;
  18534. /**
  18535. * Add touch input support to the input manager.
  18536. * @returns the current input manager
  18537. */
  18538. addTouch(): FreeCameraInputsManager;
  18539. /**
  18540. * Remove all attached input methods from a camera
  18541. */
  18542. clear(): void;
  18543. }
  18544. }
  18545. declare module BABYLON {
  18546. /**
  18547. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18548. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18549. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18550. */
  18551. export class FreeCamera extends TargetCamera {
  18552. /**
  18553. * Define the collision ellipsoid of the camera.
  18554. * This is helpful to simulate a camera body like the player body around the camera
  18555. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18556. */
  18557. ellipsoid: Vector3;
  18558. /**
  18559. * Define an offset for the position of the ellipsoid around the camera.
  18560. * This can be helpful to determine the center of the body near the gravity center of the body
  18561. * instead of its head.
  18562. */
  18563. ellipsoidOffset: Vector3;
  18564. /**
  18565. * Enable or disable collisions of the camera with the rest of the scene objects.
  18566. */
  18567. checkCollisions: boolean;
  18568. /**
  18569. * Enable or disable gravity on the camera.
  18570. */
  18571. applyGravity: boolean;
  18572. /**
  18573. * Define the input manager associated to the camera.
  18574. */
  18575. inputs: FreeCameraInputsManager;
  18576. /**
  18577. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18578. * Higher values reduce sensitivity.
  18579. */
  18580. get angularSensibility(): number;
  18581. /**
  18582. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18583. * Higher values reduce sensitivity.
  18584. */
  18585. set angularSensibility(value: number);
  18586. /**
  18587. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18588. */
  18589. get keysUp(): number[];
  18590. set keysUp(value: number[]);
  18591. /**
  18592. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18593. */
  18594. get keysUpward(): number[];
  18595. set keysUpward(value: number[]);
  18596. /**
  18597. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18598. */
  18599. get keysDown(): number[];
  18600. set keysDown(value: number[]);
  18601. /**
  18602. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18603. */
  18604. get keysDownward(): number[];
  18605. set keysDownward(value: number[]);
  18606. /**
  18607. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18608. */
  18609. get keysLeft(): number[];
  18610. set keysLeft(value: number[]);
  18611. /**
  18612. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18613. */
  18614. get keysRight(): number[];
  18615. set keysRight(value: number[]);
  18616. /**
  18617. * Event raised when the camera collide with a mesh in the scene.
  18618. */
  18619. onCollide: (collidedMesh: AbstractMesh) => void;
  18620. private _collider;
  18621. private _needMoveForGravity;
  18622. private _oldPosition;
  18623. private _diffPosition;
  18624. private _newPosition;
  18625. /** @hidden */
  18626. _localDirection: Vector3;
  18627. /** @hidden */
  18628. _transformedDirection: Vector3;
  18629. /**
  18630. * Instantiates a Free Camera.
  18631. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18632. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18634. * @param name Define the name of the camera in the scene
  18635. * @param position Define the start position of the camera in the scene
  18636. * @param scene Define the scene the camera belongs to
  18637. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18638. */
  18639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18640. /**
  18641. * Attached controls to the current camera.
  18642. * @param element Defines the element the controls should be listened from
  18643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18644. */
  18645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18646. /**
  18647. * Detach the current controls from the camera.
  18648. * The camera will stop reacting to inputs.
  18649. * @param element Defines the element to stop listening the inputs from
  18650. */
  18651. detachControl(element: HTMLElement): void;
  18652. private _collisionMask;
  18653. /**
  18654. * Define a collision mask to limit the list of object the camera can collide with
  18655. */
  18656. get collisionMask(): number;
  18657. set collisionMask(mask: number);
  18658. /** @hidden */
  18659. _collideWithWorld(displacement: Vector3): void;
  18660. private _onCollisionPositionChange;
  18661. /** @hidden */
  18662. _checkInputs(): void;
  18663. /** @hidden */
  18664. _decideIfNeedsToMove(): boolean;
  18665. /** @hidden */
  18666. _updatePosition(): void;
  18667. /**
  18668. * Destroy the camera and release the current resources hold by it.
  18669. */
  18670. dispose(): void;
  18671. /**
  18672. * Gets the current object class name.
  18673. * @return the class name
  18674. */
  18675. getClassName(): string;
  18676. }
  18677. }
  18678. declare module BABYLON {
  18679. /**
  18680. * Represents a gamepad control stick position
  18681. */
  18682. export class StickValues {
  18683. /**
  18684. * The x component of the control stick
  18685. */
  18686. x: number;
  18687. /**
  18688. * The y component of the control stick
  18689. */
  18690. y: number;
  18691. /**
  18692. * Initializes the gamepad x and y control stick values
  18693. * @param x The x component of the gamepad control stick value
  18694. * @param y The y component of the gamepad control stick value
  18695. */
  18696. constructor(
  18697. /**
  18698. * The x component of the control stick
  18699. */
  18700. x: number,
  18701. /**
  18702. * The y component of the control stick
  18703. */
  18704. y: number);
  18705. }
  18706. /**
  18707. * An interface which manages callbacks for gamepad button changes
  18708. */
  18709. export interface GamepadButtonChanges {
  18710. /**
  18711. * Called when a gamepad has been changed
  18712. */
  18713. changed: boolean;
  18714. /**
  18715. * Called when a gamepad press event has been triggered
  18716. */
  18717. pressChanged: boolean;
  18718. /**
  18719. * Called when a touch event has been triggered
  18720. */
  18721. touchChanged: boolean;
  18722. /**
  18723. * Called when a value has changed
  18724. */
  18725. valueChanged: boolean;
  18726. }
  18727. /**
  18728. * Represents a gamepad
  18729. */
  18730. export class Gamepad {
  18731. /**
  18732. * The id of the gamepad
  18733. */
  18734. id: string;
  18735. /**
  18736. * The index of the gamepad
  18737. */
  18738. index: number;
  18739. /**
  18740. * The browser gamepad
  18741. */
  18742. browserGamepad: any;
  18743. /**
  18744. * Specifies what type of gamepad this represents
  18745. */
  18746. type: number;
  18747. private _leftStick;
  18748. private _rightStick;
  18749. /** @hidden */
  18750. _isConnected: boolean;
  18751. private _leftStickAxisX;
  18752. private _leftStickAxisY;
  18753. private _rightStickAxisX;
  18754. private _rightStickAxisY;
  18755. /**
  18756. * Triggered when the left control stick has been changed
  18757. */
  18758. private _onleftstickchanged;
  18759. /**
  18760. * Triggered when the right control stick has been changed
  18761. */
  18762. private _onrightstickchanged;
  18763. /**
  18764. * Represents a gamepad controller
  18765. */
  18766. static GAMEPAD: number;
  18767. /**
  18768. * Represents a generic controller
  18769. */
  18770. static GENERIC: number;
  18771. /**
  18772. * Represents an XBox controller
  18773. */
  18774. static XBOX: number;
  18775. /**
  18776. * Represents a pose-enabled controller
  18777. */
  18778. static POSE_ENABLED: number;
  18779. /**
  18780. * Represents an Dual Shock controller
  18781. */
  18782. static DUALSHOCK: number;
  18783. /**
  18784. * Specifies whether the left control stick should be Y-inverted
  18785. */
  18786. protected _invertLeftStickY: boolean;
  18787. /**
  18788. * Specifies if the gamepad has been connected
  18789. */
  18790. get isConnected(): boolean;
  18791. /**
  18792. * Initializes the gamepad
  18793. * @param id The id of the gamepad
  18794. * @param index The index of the gamepad
  18795. * @param browserGamepad The browser gamepad
  18796. * @param leftStickX The x component of the left joystick
  18797. * @param leftStickY The y component of the left joystick
  18798. * @param rightStickX The x component of the right joystick
  18799. * @param rightStickY The y component of the right joystick
  18800. */
  18801. constructor(
  18802. /**
  18803. * The id of the gamepad
  18804. */
  18805. id: string,
  18806. /**
  18807. * The index of the gamepad
  18808. */
  18809. index: number,
  18810. /**
  18811. * The browser gamepad
  18812. */
  18813. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18814. /**
  18815. * Callback triggered when the left joystick has changed
  18816. * @param callback
  18817. */
  18818. onleftstickchanged(callback: (values: StickValues) => void): void;
  18819. /**
  18820. * Callback triggered when the right joystick has changed
  18821. * @param callback
  18822. */
  18823. onrightstickchanged(callback: (values: StickValues) => void): void;
  18824. /**
  18825. * Gets the left joystick
  18826. */
  18827. get leftStick(): StickValues;
  18828. /**
  18829. * Sets the left joystick values
  18830. */
  18831. set leftStick(newValues: StickValues);
  18832. /**
  18833. * Gets the right joystick
  18834. */
  18835. get rightStick(): StickValues;
  18836. /**
  18837. * Sets the right joystick value
  18838. */
  18839. set rightStick(newValues: StickValues);
  18840. /**
  18841. * Updates the gamepad joystick positions
  18842. */
  18843. update(): void;
  18844. /**
  18845. * Disposes the gamepad
  18846. */
  18847. dispose(): void;
  18848. }
  18849. /**
  18850. * Represents a generic gamepad
  18851. */
  18852. export class GenericPad extends Gamepad {
  18853. private _buttons;
  18854. private _onbuttondown;
  18855. private _onbuttonup;
  18856. /**
  18857. * Observable triggered when a button has been pressed
  18858. */
  18859. onButtonDownObservable: Observable<number>;
  18860. /**
  18861. * Observable triggered when a button has been released
  18862. */
  18863. onButtonUpObservable: Observable<number>;
  18864. /**
  18865. * Callback triggered when a button has been pressed
  18866. * @param callback Called when a button has been pressed
  18867. */
  18868. onbuttondown(callback: (buttonPressed: number) => void): void;
  18869. /**
  18870. * Callback triggered when a button has been released
  18871. * @param callback Called when a button has been released
  18872. */
  18873. onbuttonup(callback: (buttonReleased: number) => void): void;
  18874. /**
  18875. * Initializes the generic gamepad
  18876. * @param id The id of the generic gamepad
  18877. * @param index The index of the generic gamepad
  18878. * @param browserGamepad The browser gamepad
  18879. */
  18880. constructor(id: string, index: number, browserGamepad: any);
  18881. private _setButtonValue;
  18882. /**
  18883. * Updates the generic gamepad
  18884. */
  18885. update(): void;
  18886. /**
  18887. * Disposes the generic gamepad
  18888. */
  18889. dispose(): void;
  18890. }
  18891. }
  18892. declare module BABYLON {
  18893. /**
  18894. * Defines the types of pose enabled controllers that are supported
  18895. */
  18896. export enum PoseEnabledControllerType {
  18897. /**
  18898. * HTC Vive
  18899. */
  18900. VIVE = 0,
  18901. /**
  18902. * Oculus Rift
  18903. */
  18904. OCULUS = 1,
  18905. /**
  18906. * Windows mixed reality
  18907. */
  18908. WINDOWS = 2,
  18909. /**
  18910. * Samsung gear VR
  18911. */
  18912. GEAR_VR = 3,
  18913. /**
  18914. * Google Daydream
  18915. */
  18916. DAYDREAM = 4,
  18917. /**
  18918. * Generic
  18919. */
  18920. GENERIC = 5
  18921. }
  18922. /**
  18923. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18924. */
  18925. export interface MutableGamepadButton {
  18926. /**
  18927. * Value of the button/trigger
  18928. */
  18929. value: number;
  18930. /**
  18931. * If the button/trigger is currently touched
  18932. */
  18933. touched: boolean;
  18934. /**
  18935. * If the button/trigger is currently pressed
  18936. */
  18937. pressed: boolean;
  18938. }
  18939. /**
  18940. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18941. * @hidden
  18942. */
  18943. export interface ExtendedGamepadButton extends GamepadButton {
  18944. /**
  18945. * If the button/trigger is currently pressed
  18946. */
  18947. readonly pressed: boolean;
  18948. /**
  18949. * If the button/trigger is currently touched
  18950. */
  18951. readonly touched: boolean;
  18952. /**
  18953. * Value of the button/trigger
  18954. */
  18955. readonly value: number;
  18956. }
  18957. /** @hidden */
  18958. export interface _GamePadFactory {
  18959. /**
  18960. * Returns whether or not the current gamepad can be created for this type of controller.
  18961. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18962. * @returns true if it can be created, otherwise false
  18963. */
  18964. canCreate(gamepadInfo: any): boolean;
  18965. /**
  18966. * Creates a new instance of the Gamepad.
  18967. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18968. * @returns the new gamepad instance
  18969. */
  18970. create(gamepadInfo: any): Gamepad;
  18971. }
  18972. /**
  18973. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18974. */
  18975. export class PoseEnabledControllerHelper {
  18976. /** @hidden */
  18977. static _ControllerFactories: _GamePadFactory[];
  18978. /** @hidden */
  18979. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18980. /**
  18981. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18982. * @param vrGamepad the gamepad to initialized
  18983. * @returns a vr controller of the type the gamepad identified as
  18984. */
  18985. static InitiateController(vrGamepad: any): Gamepad;
  18986. }
  18987. /**
  18988. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18989. */
  18990. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18991. /**
  18992. * If the controller is used in a webXR session
  18993. */
  18994. isXR: boolean;
  18995. private _deviceRoomPosition;
  18996. private _deviceRoomRotationQuaternion;
  18997. /**
  18998. * The device position in babylon space
  18999. */
  19000. devicePosition: Vector3;
  19001. /**
  19002. * The device rotation in babylon space
  19003. */
  19004. deviceRotationQuaternion: Quaternion;
  19005. /**
  19006. * The scale factor of the device in babylon space
  19007. */
  19008. deviceScaleFactor: number;
  19009. /**
  19010. * (Likely devicePosition should be used instead) The device position in its room space
  19011. */
  19012. position: Vector3;
  19013. /**
  19014. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19015. */
  19016. rotationQuaternion: Quaternion;
  19017. /**
  19018. * The type of controller (Eg. Windows mixed reality)
  19019. */
  19020. controllerType: PoseEnabledControllerType;
  19021. protected _calculatedPosition: Vector3;
  19022. private _calculatedRotation;
  19023. /**
  19024. * The raw pose from the device
  19025. */
  19026. rawPose: DevicePose;
  19027. private _trackPosition;
  19028. private _maxRotationDistFromHeadset;
  19029. private _draggedRoomRotation;
  19030. /**
  19031. * @hidden
  19032. */
  19033. _disableTrackPosition(fixedPosition: Vector3): void;
  19034. /**
  19035. * Internal, the mesh attached to the controller
  19036. * @hidden
  19037. */
  19038. _mesh: Nullable<AbstractMesh>;
  19039. private _poseControlledCamera;
  19040. private _leftHandSystemQuaternion;
  19041. /**
  19042. * Internal, matrix used to convert room space to babylon space
  19043. * @hidden
  19044. */
  19045. _deviceToWorld: Matrix;
  19046. /**
  19047. * Node to be used when casting a ray from the controller
  19048. * @hidden
  19049. */
  19050. _pointingPoseNode: Nullable<TransformNode>;
  19051. /**
  19052. * Name of the child mesh that can be used to cast a ray from the controller
  19053. */
  19054. static readonly POINTING_POSE: string;
  19055. /**
  19056. * Creates a new PoseEnabledController from a gamepad
  19057. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19058. */
  19059. constructor(browserGamepad: any);
  19060. private _workingMatrix;
  19061. /**
  19062. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19063. */
  19064. update(): void;
  19065. /**
  19066. * Updates only the pose device and mesh without doing any button event checking
  19067. */
  19068. protected _updatePoseAndMesh(): void;
  19069. /**
  19070. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19071. * @param poseData raw pose fromthe device
  19072. */
  19073. updateFromDevice(poseData: DevicePose): void;
  19074. /**
  19075. * @hidden
  19076. */
  19077. _meshAttachedObservable: Observable<AbstractMesh>;
  19078. /**
  19079. * Attaches a mesh to the controller
  19080. * @param mesh the mesh to be attached
  19081. */
  19082. attachToMesh(mesh: AbstractMesh): void;
  19083. /**
  19084. * Attaches the controllers mesh to a camera
  19085. * @param camera the camera the mesh should be attached to
  19086. */
  19087. attachToPoseControlledCamera(camera: TargetCamera): void;
  19088. /**
  19089. * Disposes of the controller
  19090. */
  19091. dispose(): void;
  19092. /**
  19093. * The mesh that is attached to the controller
  19094. */
  19095. get mesh(): Nullable<AbstractMesh>;
  19096. /**
  19097. * Gets the ray of the controller in the direction the controller is pointing
  19098. * @param length the length the resulting ray should be
  19099. * @returns a ray in the direction the controller is pointing
  19100. */
  19101. getForwardRay(length?: number): Ray;
  19102. }
  19103. }
  19104. declare module BABYLON {
  19105. /**
  19106. * Defines the WebVRController object that represents controllers tracked in 3D space
  19107. */
  19108. export abstract class WebVRController extends PoseEnabledController {
  19109. /**
  19110. * Internal, the default controller model for the controller
  19111. */
  19112. protected _defaultModel: Nullable<AbstractMesh>;
  19113. /**
  19114. * Fired when the trigger state has changed
  19115. */
  19116. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19117. /**
  19118. * Fired when the main button state has changed
  19119. */
  19120. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19121. /**
  19122. * Fired when the secondary button state has changed
  19123. */
  19124. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19125. /**
  19126. * Fired when the pad state has changed
  19127. */
  19128. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19129. /**
  19130. * Fired when controllers stick values have changed
  19131. */
  19132. onPadValuesChangedObservable: Observable<StickValues>;
  19133. /**
  19134. * Array of button availible on the controller
  19135. */
  19136. protected _buttons: Array<MutableGamepadButton>;
  19137. private _onButtonStateChange;
  19138. /**
  19139. * Fired when a controller button's state has changed
  19140. * @param callback the callback containing the button that was modified
  19141. */
  19142. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19143. /**
  19144. * X and Y axis corresponding to the controllers joystick
  19145. */
  19146. pad: StickValues;
  19147. /**
  19148. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19149. */
  19150. hand: string;
  19151. /**
  19152. * The default controller model for the controller
  19153. */
  19154. get defaultModel(): Nullable<AbstractMesh>;
  19155. /**
  19156. * Creates a new WebVRController from a gamepad
  19157. * @param vrGamepad the gamepad that the WebVRController should be created from
  19158. */
  19159. constructor(vrGamepad: any);
  19160. /**
  19161. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19162. */
  19163. update(): void;
  19164. /**
  19165. * Function to be called when a button is modified
  19166. */
  19167. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19168. /**
  19169. * Loads a mesh and attaches it to the controller
  19170. * @param scene the scene the mesh should be added to
  19171. * @param meshLoaded callback for when the mesh has been loaded
  19172. */
  19173. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19174. private _setButtonValue;
  19175. private _changes;
  19176. private _checkChanges;
  19177. /**
  19178. * Disposes of th webVRCOntroller
  19179. */
  19180. dispose(): void;
  19181. }
  19182. }
  19183. declare module BABYLON {
  19184. /**
  19185. * The HemisphericLight simulates the ambient environment light,
  19186. * so the passed direction is the light reflection direction, not the incoming direction.
  19187. */
  19188. export class HemisphericLight extends Light {
  19189. /**
  19190. * The groundColor is the light in the opposite direction to the one specified during creation.
  19191. * 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.
  19192. */
  19193. groundColor: Color3;
  19194. /**
  19195. * The light reflection direction, not the incoming direction.
  19196. */
  19197. direction: Vector3;
  19198. /**
  19199. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19200. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19201. * The HemisphericLight can't cast shadows.
  19202. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19203. * @param name The friendly name of the light
  19204. * @param direction The direction of the light reflection
  19205. * @param scene The scene the light belongs to
  19206. */
  19207. constructor(name: string, direction: Vector3, scene: Scene);
  19208. protected _buildUniformLayout(): void;
  19209. /**
  19210. * Returns the string "HemisphericLight".
  19211. * @return The class name
  19212. */
  19213. getClassName(): string;
  19214. /**
  19215. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19216. * Returns the updated direction.
  19217. * @param target The target the direction should point to
  19218. * @return The computed direction
  19219. */
  19220. setDirectionToTarget(target: Vector3): Vector3;
  19221. /**
  19222. * Returns the shadow generator associated to the light.
  19223. * @returns Always null for hemispheric lights because it does not support shadows.
  19224. */
  19225. getShadowGenerator(): Nullable<IShadowGenerator>;
  19226. /**
  19227. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19228. * @param effect The effect to update
  19229. * @param lightIndex The index of the light in the effect to update
  19230. * @returns The hemispheric light
  19231. */
  19232. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19233. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19234. /**
  19235. * Computes the world matrix of the node
  19236. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19237. * @param useWasUpdatedFlag defines a reserved property
  19238. * @returns the world matrix
  19239. */
  19240. computeWorldMatrix(): Matrix;
  19241. /**
  19242. * Returns the integer 3.
  19243. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19244. */
  19245. getTypeID(): number;
  19246. /**
  19247. * Prepares the list of defines specific to the light type.
  19248. * @param defines the list of defines
  19249. * @param lightIndex defines the index of the light for the effect
  19250. */
  19251. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19252. }
  19253. }
  19254. declare module BABYLON {
  19255. /** @hidden */
  19256. export var vrMultiviewToSingleviewPixelShader: {
  19257. name: string;
  19258. shader: string;
  19259. };
  19260. }
  19261. declare module BABYLON {
  19262. /**
  19263. * Renders to multiple views with a single draw call
  19264. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19265. */
  19266. export class MultiviewRenderTarget extends RenderTargetTexture {
  19267. /**
  19268. * Creates a multiview render target
  19269. * @param scene scene used with the render target
  19270. * @param size the size of the render target (used for each view)
  19271. */
  19272. constructor(scene: Scene, size?: number | {
  19273. width: number;
  19274. height: number;
  19275. } | {
  19276. ratio: number;
  19277. });
  19278. /**
  19279. * @hidden
  19280. * @param faceIndex the face index, if its a cube texture
  19281. */
  19282. _bindFrameBuffer(faceIndex?: number): void;
  19283. /**
  19284. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19285. * @returns the view count
  19286. */
  19287. getViewCount(): number;
  19288. }
  19289. }
  19290. declare module BABYLON {
  19291. /**
  19292. * Represents a camera frustum
  19293. */
  19294. export class Frustum {
  19295. /**
  19296. * Gets the planes representing the frustum
  19297. * @param transform matrix to be applied to the returned planes
  19298. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19299. */
  19300. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19301. /**
  19302. * Gets the near frustum plane transformed by the transform matrix
  19303. * @param transform transformation matrix to be applied to the resulting frustum plane
  19304. * @param frustumPlane the resuling frustum plane
  19305. */
  19306. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19307. /**
  19308. * Gets the far frustum plane transformed by the transform matrix
  19309. * @param transform transformation matrix to be applied to the resulting frustum plane
  19310. * @param frustumPlane the resuling frustum plane
  19311. */
  19312. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19313. /**
  19314. * Gets the left frustum plane transformed by the transform matrix
  19315. * @param transform transformation matrix to be applied to the resulting frustum plane
  19316. * @param frustumPlane the resuling frustum plane
  19317. */
  19318. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19319. /**
  19320. * Gets the right frustum plane transformed by the transform matrix
  19321. * @param transform transformation matrix to be applied to the resulting frustum plane
  19322. * @param frustumPlane the resuling frustum plane
  19323. */
  19324. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19325. /**
  19326. * Gets the top frustum plane transformed by the transform matrix
  19327. * @param transform transformation matrix to be applied to the resulting frustum plane
  19328. * @param frustumPlane the resuling frustum plane
  19329. */
  19330. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19331. /**
  19332. * Gets the bottom frustum plane transformed by the transform matrix
  19333. * @param transform transformation matrix to be applied to the resulting frustum plane
  19334. * @param frustumPlane the resuling frustum plane
  19335. */
  19336. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19337. /**
  19338. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19339. * @param transform transformation matrix to be applied to the resulting frustum planes
  19340. * @param frustumPlanes the resuling frustum planes
  19341. */
  19342. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19343. }
  19344. }
  19345. declare module BABYLON {
  19346. interface Engine {
  19347. /**
  19348. * Creates a new multiview render target
  19349. * @param width defines the width of the texture
  19350. * @param height defines the height of the texture
  19351. * @returns the created multiview texture
  19352. */
  19353. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19354. /**
  19355. * Binds a multiview framebuffer to be drawn to
  19356. * @param multiviewTexture texture to bind
  19357. */
  19358. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19359. }
  19360. interface Camera {
  19361. /**
  19362. * @hidden
  19363. * 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)
  19364. */
  19365. _useMultiviewToSingleView: boolean;
  19366. /**
  19367. * @hidden
  19368. * 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)
  19369. */
  19370. _multiviewTexture: Nullable<RenderTargetTexture>;
  19371. /**
  19372. * @hidden
  19373. * ensures the multiview texture of the camera exists and has the specified width/height
  19374. * @param width height to set on the multiview texture
  19375. * @param height width to set on the multiview texture
  19376. */
  19377. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19378. }
  19379. interface Scene {
  19380. /** @hidden */
  19381. _transformMatrixR: Matrix;
  19382. /** @hidden */
  19383. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19384. /** @hidden */
  19385. _createMultiviewUbo(): void;
  19386. /** @hidden */
  19387. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19388. /** @hidden */
  19389. _renderMultiviewToSingleView(camera: Camera): void;
  19390. }
  19391. }
  19392. declare module BABYLON {
  19393. /**
  19394. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19395. * This will not be used for webXR as it supports displaying texture arrays directly
  19396. */
  19397. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19398. /**
  19399. * Initializes a VRMultiviewToSingleview
  19400. * @param name name of the post process
  19401. * @param camera camera to be applied to
  19402. * @param scaleFactor scaling factor to the size of the output texture
  19403. */
  19404. constructor(name: string, camera: Camera, scaleFactor: number);
  19405. }
  19406. }
  19407. declare module BABYLON {
  19408. /**
  19409. * Interface used to define additional presentation attributes
  19410. */
  19411. export interface IVRPresentationAttributes {
  19412. /**
  19413. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19414. */
  19415. highRefreshRate: boolean;
  19416. /**
  19417. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19418. */
  19419. foveationLevel: number;
  19420. }
  19421. interface Engine {
  19422. /** @hidden */
  19423. _vrDisplay: any;
  19424. /** @hidden */
  19425. _vrSupported: boolean;
  19426. /** @hidden */
  19427. _oldSize: Size;
  19428. /** @hidden */
  19429. _oldHardwareScaleFactor: number;
  19430. /** @hidden */
  19431. _vrExclusivePointerMode: boolean;
  19432. /** @hidden */
  19433. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19434. /** @hidden */
  19435. _onVRDisplayPointerRestricted: () => void;
  19436. /** @hidden */
  19437. _onVRDisplayPointerUnrestricted: () => void;
  19438. /** @hidden */
  19439. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19440. /** @hidden */
  19441. _onVrDisplayDisconnect: Nullable<() => void>;
  19442. /** @hidden */
  19443. _onVrDisplayPresentChange: Nullable<() => void>;
  19444. /**
  19445. * Observable signaled when VR display mode changes
  19446. */
  19447. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19448. /**
  19449. * Observable signaled when VR request present is complete
  19450. */
  19451. onVRRequestPresentComplete: Observable<boolean>;
  19452. /**
  19453. * Observable signaled when VR request present starts
  19454. */
  19455. onVRRequestPresentStart: Observable<Engine>;
  19456. /**
  19457. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19458. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19459. */
  19460. isInVRExclusivePointerMode: boolean;
  19461. /**
  19462. * Gets a boolean indicating if a webVR device was detected
  19463. * @returns true if a webVR device was detected
  19464. */
  19465. isVRDevicePresent(): boolean;
  19466. /**
  19467. * Gets the current webVR device
  19468. * @returns the current webVR device (or null)
  19469. */
  19470. getVRDevice(): any;
  19471. /**
  19472. * Initializes a webVR display and starts listening to display change events
  19473. * The onVRDisplayChangedObservable will be notified upon these changes
  19474. * @returns A promise containing a VRDisplay and if vr is supported
  19475. */
  19476. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19477. /** @hidden */
  19478. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19479. /**
  19480. * Gets or sets the presentation attributes used to configure VR rendering
  19481. */
  19482. vrPresentationAttributes?: IVRPresentationAttributes;
  19483. /**
  19484. * Call this function to switch to webVR mode
  19485. * Will do nothing if webVR is not supported or if there is no webVR device
  19486. * @param options the webvr options provided to the camera. mainly used for multiview
  19487. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19488. */
  19489. enableVR(options: WebVROptions): void;
  19490. /** @hidden */
  19491. _onVRFullScreenTriggered(): void;
  19492. }
  19493. }
  19494. declare module BABYLON {
  19495. /**
  19496. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19497. * IMPORTANT!! The data is right-hand data.
  19498. * @export
  19499. * @interface DevicePose
  19500. */
  19501. export interface DevicePose {
  19502. /**
  19503. * The position of the device, values in array are [x,y,z].
  19504. */
  19505. readonly position: Nullable<Float32Array>;
  19506. /**
  19507. * The linearVelocity of the device, values in array are [x,y,z].
  19508. */
  19509. readonly linearVelocity: Nullable<Float32Array>;
  19510. /**
  19511. * The linearAcceleration of the device, values in array are [x,y,z].
  19512. */
  19513. readonly linearAcceleration: Nullable<Float32Array>;
  19514. /**
  19515. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19516. */
  19517. readonly orientation: Nullable<Float32Array>;
  19518. /**
  19519. * The angularVelocity of the device, values in array are [x,y,z].
  19520. */
  19521. readonly angularVelocity: Nullable<Float32Array>;
  19522. /**
  19523. * The angularAcceleration of the device, values in array are [x,y,z].
  19524. */
  19525. readonly angularAcceleration: Nullable<Float32Array>;
  19526. }
  19527. /**
  19528. * Interface representing a pose controlled object in Babylon.
  19529. * A pose controlled object has both regular pose values as well as pose values
  19530. * from an external device such as a VR head mounted display
  19531. */
  19532. export interface PoseControlled {
  19533. /**
  19534. * The position of the object in babylon space.
  19535. */
  19536. position: Vector3;
  19537. /**
  19538. * The rotation quaternion of the object in babylon space.
  19539. */
  19540. rotationQuaternion: Quaternion;
  19541. /**
  19542. * The position of the device in babylon space.
  19543. */
  19544. devicePosition?: Vector3;
  19545. /**
  19546. * The rotation quaternion of the device in babylon space.
  19547. */
  19548. deviceRotationQuaternion: Quaternion;
  19549. /**
  19550. * The raw pose coming from the device.
  19551. */
  19552. rawPose: Nullable<DevicePose>;
  19553. /**
  19554. * The scale of the device to be used when translating from device space to babylon space.
  19555. */
  19556. deviceScaleFactor: number;
  19557. /**
  19558. * Updates the poseControlled values based on the input device pose.
  19559. * @param poseData the pose data to update the object with
  19560. */
  19561. updateFromDevice(poseData: DevicePose): void;
  19562. }
  19563. /**
  19564. * Set of options to customize the webVRCamera
  19565. */
  19566. export interface WebVROptions {
  19567. /**
  19568. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19569. */
  19570. trackPosition?: boolean;
  19571. /**
  19572. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19573. */
  19574. positionScale?: number;
  19575. /**
  19576. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19577. */
  19578. displayName?: string;
  19579. /**
  19580. * Should the native controller meshes be initialized. (default: true)
  19581. */
  19582. controllerMeshes?: boolean;
  19583. /**
  19584. * Creating a default HemiLight only on controllers. (default: true)
  19585. */
  19586. defaultLightingOnControllers?: boolean;
  19587. /**
  19588. * If you don't want to use the default VR button of the helper. (default: false)
  19589. */
  19590. useCustomVRButton?: boolean;
  19591. /**
  19592. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19593. */
  19594. customVRButton?: HTMLButtonElement;
  19595. /**
  19596. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19597. */
  19598. rayLength?: number;
  19599. /**
  19600. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19601. */
  19602. defaultHeight?: number;
  19603. /**
  19604. * If multiview should be used if availible (default: false)
  19605. */
  19606. useMultiview?: boolean;
  19607. }
  19608. /**
  19609. * This represents a WebVR camera.
  19610. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19611. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19612. */
  19613. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19614. private webVROptions;
  19615. /**
  19616. * @hidden
  19617. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19618. */
  19619. _vrDevice: any;
  19620. /**
  19621. * The rawPose of the vrDevice.
  19622. */
  19623. rawPose: Nullable<DevicePose>;
  19624. private _onVREnabled;
  19625. private _specsVersion;
  19626. private _attached;
  19627. private _frameData;
  19628. protected _descendants: Array<Node>;
  19629. private _deviceRoomPosition;
  19630. /** @hidden */
  19631. _deviceRoomRotationQuaternion: Quaternion;
  19632. private _standingMatrix;
  19633. /**
  19634. * Represents device position in babylon space.
  19635. */
  19636. devicePosition: Vector3;
  19637. /**
  19638. * Represents device rotation in babylon space.
  19639. */
  19640. deviceRotationQuaternion: Quaternion;
  19641. /**
  19642. * The scale of the device to be used when translating from device space to babylon space.
  19643. */
  19644. deviceScaleFactor: number;
  19645. private _deviceToWorld;
  19646. private _worldToDevice;
  19647. /**
  19648. * References to the webVR controllers for the vrDevice.
  19649. */
  19650. controllers: Array<WebVRController>;
  19651. /**
  19652. * Emits an event when a controller is attached.
  19653. */
  19654. onControllersAttachedObservable: Observable<WebVRController[]>;
  19655. /**
  19656. * Emits an event when a controller's mesh has been loaded;
  19657. */
  19658. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19659. /**
  19660. * Emits an event when the HMD's pose has been updated.
  19661. */
  19662. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19663. private _poseSet;
  19664. /**
  19665. * If the rig cameras be used as parent instead of this camera.
  19666. */
  19667. rigParenting: boolean;
  19668. private _lightOnControllers;
  19669. private _defaultHeight?;
  19670. /**
  19671. * Instantiates a WebVRFreeCamera.
  19672. * @param name The name of the WebVRFreeCamera
  19673. * @param position The starting anchor position for the camera
  19674. * @param scene The scene the camera belongs to
  19675. * @param webVROptions a set of customizable options for the webVRCamera
  19676. */
  19677. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19678. /**
  19679. * Gets the device distance from the ground in meters.
  19680. * @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.
  19681. */
  19682. deviceDistanceToRoomGround(): number;
  19683. /**
  19684. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19685. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19686. */
  19687. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19688. /**
  19689. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19690. * @returns A promise with a boolean set to if the standing matrix is supported.
  19691. */
  19692. useStandingMatrixAsync(): Promise<boolean>;
  19693. /**
  19694. * Disposes the camera
  19695. */
  19696. dispose(): void;
  19697. /**
  19698. * Gets a vrController by name.
  19699. * @param name The name of the controller to retreive
  19700. * @returns the controller matching the name specified or null if not found
  19701. */
  19702. getControllerByName(name: string): Nullable<WebVRController>;
  19703. private _leftController;
  19704. /**
  19705. * The controller corresponding to the users left hand.
  19706. */
  19707. get leftController(): Nullable<WebVRController>;
  19708. private _rightController;
  19709. /**
  19710. * The controller corresponding to the users right hand.
  19711. */
  19712. get rightController(): Nullable<WebVRController>;
  19713. /**
  19714. * Casts a ray forward from the vrCamera's gaze.
  19715. * @param length Length of the ray (default: 100)
  19716. * @returns the ray corresponding to the gaze
  19717. */
  19718. getForwardRay(length?: number): Ray;
  19719. /**
  19720. * @hidden
  19721. * Updates the camera based on device's frame data
  19722. */
  19723. _checkInputs(): void;
  19724. /**
  19725. * Updates the poseControlled values based on the input device pose.
  19726. * @param poseData Pose coming from the device
  19727. */
  19728. updateFromDevice(poseData: DevicePose): void;
  19729. private _htmlElementAttached;
  19730. private _detachIfAttached;
  19731. /**
  19732. * WebVR's attach control will start broadcasting frames to the device.
  19733. * Note that in certain browsers (chrome for example) this function must be called
  19734. * within a user-interaction callback. Example:
  19735. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19736. *
  19737. * @param element html element to attach the vrDevice to
  19738. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19739. */
  19740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19741. /**
  19742. * Detaches the camera from the html element and disables VR
  19743. *
  19744. * @param element html element to detach from
  19745. */
  19746. detachControl(element: HTMLElement): void;
  19747. /**
  19748. * @returns the name of this class
  19749. */
  19750. getClassName(): string;
  19751. /**
  19752. * Calls resetPose on the vrDisplay
  19753. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19754. */
  19755. resetToCurrentRotation(): void;
  19756. /**
  19757. * @hidden
  19758. * Updates the rig cameras (left and right eye)
  19759. */
  19760. _updateRigCameras(): void;
  19761. private _workingVector;
  19762. private _oneVector;
  19763. private _workingMatrix;
  19764. private updateCacheCalled;
  19765. private _correctPositionIfNotTrackPosition;
  19766. /**
  19767. * @hidden
  19768. * Updates the cached values of the camera
  19769. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19770. */
  19771. _updateCache(ignoreParentClass?: boolean): void;
  19772. /**
  19773. * @hidden
  19774. * Get current device position in babylon world
  19775. */
  19776. _computeDevicePosition(): void;
  19777. /**
  19778. * Updates the current device position and rotation in the babylon world
  19779. */
  19780. update(): void;
  19781. /**
  19782. * @hidden
  19783. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19784. * @returns an identity matrix
  19785. */
  19786. _getViewMatrix(): Matrix;
  19787. private _tmpMatrix;
  19788. /**
  19789. * This function is called by the two RIG cameras.
  19790. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19791. * @hidden
  19792. */
  19793. _getWebVRViewMatrix(): Matrix;
  19794. /** @hidden */
  19795. _getWebVRProjectionMatrix(): Matrix;
  19796. private _onGamepadConnectedObserver;
  19797. private _onGamepadDisconnectedObserver;
  19798. private _updateCacheWhenTrackingDisabledObserver;
  19799. /**
  19800. * Initializes the controllers and their meshes
  19801. */
  19802. initControllers(): void;
  19803. }
  19804. }
  19805. declare module BABYLON {
  19806. /**
  19807. * Size options for a post process
  19808. */
  19809. export type PostProcessOptions = {
  19810. width: number;
  19811. height: number;
  19812. };
  19813. /**
  19814. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19815. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19816. */
  19817. export class PostProcess {
  19818. /** Name of the PostProcess. */
  19819. name: string;
  19820. /**
  19821. * Gets or sets the unique id of the post process
  19822. */
  19823. uniqueId: number;
  19824. /**
  19825. * Width of the texture to apply the post process on
  19826. */
  19827. width: number;
  19828. /**
  19829. * Height of the texture to apply the post process on
  19830. */
  19831. height: number;
  19832. /**
  19833. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19834. * @hidden
  19835. */
  19836. _outputTexture: Nullable<InternalTexture>;
  19837. /**
  19838. * Sampling mode used by the shader
  19839. * See https://doc.babylonjs.com/classes/3.1/texture
  19840. */
  19841. renderTargetSamplingMode: number;
  19842. /**
  19843. * Clear color to use when screen clearing
  19844. */
  19845. clearColor: Color4;
  19846. /**
  19847. * If the buffer needs to be cleared before applying the post process. (default: true)
  19848. * Should be set to false if shader will overwrite all previous pixels.
  19849. */
  19850. autoClear: boolean;
  19851. /**
  19852. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19853. */
  19854. alphaMode: number;
  19855. /**
  19856. * Sets the setAlphaBlendConstants of the babylon engine
  19857. */
  19858. alphaConstants: Color4;
  19859. /**
  19860. * Animations to be used for the post processing
  19861. */
  19862. animations: Animation[];
  19863. /**
  19864. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19865. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19866. */
  19867. enablePixelPerfectMode: boolean;
  19868. /**
  19869. * Force the postprocess to be applied without taking in account viewport
  19870. */
  19871. forceFullscreenViewport: boolean;
  19872. /**
  19873. * List of inspectable custom properties (used by the Inspector)
  19874. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19875. */
  19876. inspectableCustomProperties: IInspectable[];
  19877. /**
  19878. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19879. *
  19880. * | Value | Type | Description |
  19881. * | ----- | ----------------------------------- | ----------- |
  19882. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19883. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19884. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19885. *
  19886. */
  19887. scaleMode: number;
  19888. /**
  19889. * Force textures to be a power of two (default: false)
  19890. */
  19891. alwaysForcePOT: boolean;
  19892. private _samples;
  19893. /**
  19894. * Number of sample textures (default: 1)
  19895. */
  19896. get samples(): number;
  19897. set samples(n: number);
  19898. /**
  19899. * Modify the scale of the post process to be the same as the viewport (default: false)
  19900. */
  19901. adaptScaleToCurrentViewport: boolean;
  19902. private _camera;
  19903. private _scene;
  19904. private _engine;
  19905. private _options;
  19906. private _reusable;
  19907. private _textureType;
  19908. private _textureFormat;
  19909. /**
  19910. * Smart array of input and output textures for the post process.
  19911. * @hidden
  19912. */
  19913. _textures: SmartArray<InternalTexture>;
  19914. /**
  19915. * The index in _textures that corresponds to the output texture.
  19916. * @hidden
  19917. */
  19918. _currentRenderTextureInd: number;
  19919. private _effect;
  19920. private _samplers;
  19921. private _fragmentUrl;
  19922. private _vertexUrl;
  19923. private _parameters;
  19924. private _scaleRatio;
  19925. protected _indexParameters: any;
  19926. private _shareOutputWithPostProcess;
  19927. private _texelSize;
  19928. private _forcedOutputTexture;
  19929. /**
  19930. * Returns the fragment url or shader name used in the post process.
  19931. * @returns the fragment url or name in the shader store.
  19932. */
  19933. getEffectName(): string;
  19934. /**
  19935. * An event triggered when the postprocess is activated.
  19936. */
  19937. onActivateObservable: Observable<Camera>;
  19938. private _onActivateObserver;
  19939. /**
  19940. * A function that is added to the onActivateObservable
  19941. */
  19942. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19943. /**
  19944. * An event triggered when the postprocess changes its size.
  19945. */
  19946. onSizeChangedObservable: Observable<PostProcess>;
  19947. private _onSizeChangedObserver;
  19948. /**
  19949. * A function that is added to the onSizeChangedObservable
  19950. */
  19951. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19952. /**
  19953. * An event triggered when the postprocess applies its effect.
  19954. */
  19955. onApplyObservable: Observable<Effect>;
  19956. private _onApplyObserver;
  19957. /**
  19958. * A function that is added to the onApplyObservable
  19959. */
  19960. set onApply(callback: (effect: Effect) => void);
  19961. /**
  19962. * An event triggered before rendering the postprocess
  19963. */
  19964. onBeforeRenderObservable: Observable<Effect>;
  19965. private _onBeforeRenderObserver;
  19966. /**
  19967. * A function that is added to the onBeforeRenderObservable
  19968. */
  19969. set onBeforeRender(callback: (effect: Effect) => void);
  19970. /**
  19971. * An event triggered after rendering the postprocess
  19972. */
  19973. onAfterRenderObservable: Observable<Effect>;
  19974. private _onAfterRenderObserver;
  19975. /**
  19976. * A function that is added to the onAfterRenderObservable
  19977. */
  19978. set onAfterRender(callback: (efect: Effect) => void);
  19979. /**
  19980. * 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
  19981. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19982. */
  19983. get inputTexture(): InternalTexture;
  19984. set inputTexture(value: InternalTexture);
  19985. /**
  19986. * Gets the camera which post process is applied to.
  19987. * @returns The camera the post process is applied to.
  19988. */
  19989. getCamera(): Camera;
  19990. /**
  19991. * Gets the texel size of the postprocess.
  19992. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19993. */
  19994. get texelSize(): Vector2;
  19995. /**
  19996. * Creates a new instance PostProcess
  19997. * @param name The name of the PostProcess.
  19998. * @param fragmentUrl The url of the fragment shader to be used.
  19999. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20000. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20001. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20002. * @param camera The camera to apply the render pass to.
  20003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20004. * @param engine The engine which the post process will be applied. (default: current engine)
  20005. * @param reusable If the post process can be reused on the same frame. (default: false)
  20006. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20007. * @param textureType Type of textures used when performing the post process. (default: 0)
  20008. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20009. * @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
  20010. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20011. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20012. */
  20013. constructor(
  20014. /** Name of the PostProcess. */
  20015. 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);
  20016. /**
  20017. * Gets a string idenfifying the name of the class
  20018. * @returns "PostProcess" string
  20019. */
  20020. getClassName(): string;
  20021. /**
  20022. * Gets the engine which this post process belongs to.
  20023. * @returns The engine the post process was enabled with.
  20024. */
  20025. getEngine(): Engine;
  20026. /**
  20027. * The effect that is created when initializing the post process.
  20028. * @returns The created effect corresponding the the postprocess.
  20029. */
  20030. getEffect(): Effect;
  20031. /**
  20032. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20033. * @param postProcess The post process to share the output with.
  20034. * @returns This post process.
  20035. */
  20036. shareOutputWith(postProcess: PostProcess): PostProcess;
  20037. /**
  20038. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20039. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20040. */
  20041. useOwnOutput(): void;
  20042. /**
  20043. * Updates the effect with the current post process compile time values and recompiles the shader.
  20044. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20045. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20046. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20047. * @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
  20048. * @param onCompiled Called when the shader has been compiled.
  20049. * @param onError Called if there is an error when compiling a shader.
  20050. */
  20051. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20052. /**
  20053. * The post process is reusable if it can be used multiple times within one frame.
  20054. * @returns If the post process is reusable
  20055. */
  20056. isReusable(): boolean;
  20057. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20058. markTextureDirty(): void;
  20059. /**
  20060. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20061. * 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.
  20062. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20063. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20064. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20065. * @returns The target texture that was bound to be written to.
  20066. */
  20067. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20068. /**
  20069. * If the post process is supported.
  20070. */
  20071. get isSupported(): boolean;
  20072. /**
  20073. * The aspect ratio of the output texture.
  20074. */
  20075. get aspectRatio(): number;
  20076. /**
  20077. * Get a value indicating if the post-process is ready to be used
  20078. * @returns true if the post-process is ready (shader is compiled)
  20079. */
  20080. isReady(): boolean;
  20081. /**
  20082. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20083. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20084. */
  20085. apply(): Nullable<Effect>;
  20086. private _disposeTextures;
  20087. /**
  20088. * Disposes the post process.
  20089. * @param camera The camera to dispose the post process on.
  20090. */
  20091. dispose(camera?: Camera): void;
  20092. }
  20093. }
  20094. declare module BABYLON {
  20095. /** @hidden */
  20096. export var kernelBlurVaryingDeclaration: {
  20097. name: string;
  20098. shader: string;
  20099. };
  20100. }
  20101. declare module BABYLON {
  20102. /** @hidden */
  20103. export var kernelBlurFragment: {
  20104. name: string;
  20105. shader: string;
  20106. };
  20107. }
  20108. declare module BABYLON {
  20109. /** @hidden */
  20110. export var kernelBlurFragment2: {
  20111. name: string;
  20112. shader: string;
  20113. };
  20114. }
  20115. declare module BABYLON {
  20116. /** @hidden */
  20117. export var kernelBlurPixelShader: {
  20118. name: string;
  20119. shader: string;
  20120. };
  20121. }
  20122. declare module BABYLON {
  20123. /** @hidden */
  20124. export var kernelBlurVertex: {
  20125. name: string;
  20126. shader: string;
  20127. };
  20128. }
  20129. declare module BABYLON {
  20130. /** @hidden */
  20131. export var kernelBlurVertexShader: {
  20132. name: string;
  20133. shader: string;
  20134. };
  20135. }
  20136. declare module BABYLON {
  20137. /**
  20138. * The Blur Post Process which blurs an image based on a kernel and direction.
  20139. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20140. */
  20141. export class BlurPostProcess extends PostProcess {
  20142. /** The direction in which to blur the image. */
  20143. direction: Vector2;
  20144. private blockCompilation;
  20145. protected _kernel: number;
  20146. protected _idealKernel: number;
  20147. protected _packedFloat: boolean;
  20148. private _staticDefines;
  20149. /**
  20150. * Sets the length in pixels of the blur sample region
  20151. */
  20152. set kernel(v: number);
  20153. /**
  20154. * Gets the length in pixels of the blur sample region
  20155. */
  20156. get kernel(): number;
  20157. /**
  20158. * Sets wether or not the blur needs to unpack/repack floats
  20159. */
  20160. set packedFloat(v: boolean);
  20161. /**
  20162. * Gets wether or not the blur is unpacking/repacking floats
  20163. */
  20164. get packedFloat(): boolean;
  20165. /**
  20166. * Creates a new instance BlurPostProcess
  20167. * @param name The name of the effect.
  20168. * @param direction The direction in which to blur the image.
  20169. * @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.
  20170. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20171. * @param camera The camera to apply the render pass to.
  20172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20173. * @param engine The engine which the post process will be applied. (default: current engine)
  20174. * @param reusable If the post process can be reused on the same frame. (default: false)
  20175. * @param textureType Type of textures used when performing the post process. (default: 0)
  20176. * @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)
  20177. */
  20178. constructor(name: string,
  20179. /** The direction in which to blur the image. */
  20180. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20181. /**
  20182. * Updates the effect with the current post process compile time values and recompiles the shader.
  20183. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20184. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20185. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20186. * @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
  20187. * @param onCompiled Called when the shader has been compiled.
  20188. * @param onError Called if there is an error when compiling a shader.
  20189. */
  20190. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20191. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20192. /**
  20193. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20194. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20195. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20196. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20197. * The gaps between physical kernels are compensated for in the weighting of the samples
  20198. * @param idealKernel Ideal blur kernel.
  20199. * @return Nearest best kernel.
  20200. */
  20201. protected _nearestBestKernel(idealKernel: number): number;
  20202. /**
  20203. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20204. * @param x The point on the Gaussian distribution to sample.
  20205. * @return the value of the Gaussian function at x.
  20206. */
  20207. protected _gaussianWeight(x: number): number;
  20208. /**
  20209. * Generates a string that can be used as a floating point number in GLSL.
  20210. * @param x Value to print.
  20211. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20212. * @return GLSL float string.
  20213. */
  20214. protected _glslFloat(x: number, decimalFigures?: number): string;
  20215. }
  20216. }
  20217. declare module BABYLON {
  20218. /**
  20219. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20220. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20221. * You can then easily use it as a reflectionTexture on a flat surface.
  20222. * In case the surface is not a plane, please consider relying on reflection probes.
  20223. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20224. */
  20225. export class MirrorTexture extends RenderTargetTexture {
  20226. private scene;
  20227. /**
  20228. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20229. * 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.
  20230. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20231. */
  20232. mirrorPlane: Plane;
  20233. /**
  20234. * Define the blur ratio used to blur the reflection if needed.
  20235. */
  20236. set blurRatio(value: number);
  20237. get blurRatio(): number;
  20238. /**
  20239. * Define the adaptive blur kernel used to blur the reflection if needed.
  20240. * This will autocompute the closest best match for the `blurKernel`
  20241. */
  20242. set adaptiveBlurKernel(value: number);
  20243. /**
  20244. * Define the blur kernel used to blur the reflection if needed.
  20245. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20246. */
  20247. set blurKernel(value: number);
  20248. /**
  20249. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20250. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20251. */
  20252. set blurKernelX(value: number);
  20253. get blurKernelX(): number;
  20254. /**
  20255. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20256. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20257. */
  20258. set blurKernelY(value: number);
  20259. get blurKernelY(): number;
  20260. private _autoComputeBlurKernel;
  20261. protected _onRatioRescale(): void;
  20262. private _updateGammaSpace;
  20263. private _imageProcessingConfigChangeObserver;
  20264. private _transformMatrix;
  20265. private _mirrorMatrix;
  20266. private _savedViewMatrix;
  20267. private _blurX;
  20268. private _blurY;
  20269. private _adaptiveBlurKernel;
  20270. private _blurKernelX;
  20271. private _blurKernelY;
  20272. private _blurRatio;
  20273. /**
  20274. * Instantiates a Mirror Texture.
  20275. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20276. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20277. * You can then easily use it as a reflectionTexture on a flat surface.
  20278. * In case the surface is not a plane, please consider relying on reflection probes.
  20279. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20280. * @param name
  20281. * @param size
  20282. * @param scene
  20283. * @param generateMipMaps
  20284. * @param type
  20285. * @param samplingMode
  20286. * @param generateDepthBuffer
  20287. */
  20288. constructor(name: string, size: number | {
  20289. width: number;
  20290. height: number;
  20291. } | {
  20292. ratio: number;
  20293. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20294. private _preparePostProcesses;
  20295. /**
  20296. * Clone the mirror texture.
  20297. * @returns the cloned texture
  20298. */
  20299. clone(): MirrorTexture;
  20300. /**
  20301. * Serialize the texture to a JSON representation you could use in Parse later on
  20302. * @returns the serialized JSON representation
  20303. */
  20304. serialize(): any;
  20305. /**
  20306. * Dispose the texture and release its associated resources.
  20307. */
  20308. dispose(): void;
  20309. }
  20310. }
  20311. declare module BABYLON {
  20312. /**
  20313. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20314. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20315. */
  20316. export class Texture extends BaseTexture {
  20317. /**
  20318. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20319. */
  20320. static SerializeBuffers: boolean;
  20321. /** @hidden */
  20322. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20323. /** @hidden */
  20324. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20325. /** @hidden */
  20326. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20327. /** nearest is mag = nearest and min = nearest and mip = linear */
  20328. static readonly NEAREST_SAMPLINGMODE: number;
  20329. /** nearest is mag = nearest and min = nearest and mip = linear */
  20330. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20331. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20332. static readonly BILINEAR_SAMPLINGMODE: number;
  20333. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20334. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20335. /** Trilinear is mag = linear and min = linear and mip = linear */
  20336. static readonly TRILINEAR_SAMPLINGMODE: number;
  20337. /** Trilinear is mag = linear and min = linear and mip = linear */
  20338. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20339. /** mag = nearest and min = nearest and mip = nearest */
  20340. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20341. /** mag = nearest and min = linear and mip = nearest */
  20342. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20343. /** mag = nearest and min = linear and mip = linear */
  20344. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20345. /** mag = nearest and min = linear and mip = none */
  20346. static readonly NEAREST_LINEAR: number;
  20347. /** mag = nearest and min = nearest and mip = none */
  20348. static readonly NEAREST_NEAREST: number;
  20349. /** mag = linear and min = nearest and mip = nearest */
  20350. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20351. /** mag = linear and min = nearest and mip = linear */
  20352. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20353. /** mag = linear and min = linear and mip = none */
  20354. static readonly LINEAR_LINEAR: number;
  20355. /** mag = linear and min = nearest and mip = none */
  20356. static readonly LINEAR_NEAREST: number;
  20357. /** Explicit coordinates mode */
  20358. static readonly EXPLICIT_MODE: number;
  20359. /** Spherical coordinates mode */
  20360. static readonly SPHERICAL_MODE: number;
  20361. /** Planar coordinates mode */
  20362. static readonly PLANAR_MODE: number;
  20363. /** Cubic coordinates mode */
  20364. static readonly CUBIC_MODE: number;
  20365. /** Projection coordinates mode */
  20366. static readonly PROJECTION_MODE: number;
  20367. /** Inverse Cubic coordinates mode */
  20368. static readonly SKYBOX_MODE: number;
  20369. /** Inverse Cubic coordinates mode */
  20370. static readonly INVCUBIC_MODE: number;
  20371. /** Equirectangular coordinates mode */
  20372. static readonly EQUIRECTANGULAR_MODE: number;
  20373. /** Equirectangular Fixed coordinates mode */
  20374. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20375. /** Equirectangular Fixed Mirrored coordinates mode */
  20376. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20377. /** Texture is not repeating outside of 0..1 UVs */
  20378. static readonly CLAMP_ADDRESSMODE: number;
  20379. /** Texture is repeating outside of 0..1 UVs */
  20380. static readonly WRAP_ADDRESSMODE: number;
  20381. /** Texture is repeating and mirrored */
  20382. static readonly MIRROR_ADDRESSMODE: number;
  20383. /**
  20384. * 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
  20385. */
  20386. static UseSerializedUrlIfAny: boolean;
  20387. /**
  20388. * Define the url of the texture.
  20389. */
  20390. url: Nullable<string>;
  20391. /**
  20392. * Define an offset on the texture to offset the u coordinates of the UVs
  20393. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20394. */
  20395. uOffset: number;
  20396. /**
  20397. * Define an offset on the texture to offset the v coordinates of the UVs
  20398. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20399. */
  20400. vOffset: number;
  20401. /**
  20402. * Define an offset on the texture to scale the u coordinates of the UVs
  20403. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20404. */
  20405. uScale: number;
  20406. /**
  20407. * Define an offset on the texture to scale the v coordinates of the UVs
  20408. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20409. */
  20410. vScale: number;
  20411. /**
  20412. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20413. * @see http://doc.babylonjs.com/how_to/more_materials
  20414. */
  20415. uAng: number;
  20416. /**
  20417. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20418. * @see http://doc.babylonjs.com/how_to/more_materials
  20419. */
  20420. vAng: number;
  20421. /**
  20422. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20423. * @see http://doc.babylonjs.com/how_to/more_materials
  20424. */
  20425. wAng: number;
  20426. /**
  20427. * Defines the center of rotation (U)
  20428. */
  20429. uRotationCenter: number;
  20430. /**
  20431. * Defines the center of rotation (V)
  20432. */
  20433. vRotationCenter: number;
  20434. /**
  20435. * Defines the center of rotation (W)
  20436. */
  20437. wRotationCenter: number;
  20438. /**
  20439. * Are mip maps generated for this texture or not.
  20440. */
  20441. get noMipmap(): boolean;
  20442. /**
  20443. * List of inspectable custom properties (used by the Inspector)
  20444. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20445. */
  20446. inspectableCustomProperties: Nullable<IInspectable[]>;
  20447. private _noMipmap;
  20448. /** @hidden */
  20449. _invertY: boolean;
  20450. private _rowGenerationMatrix;
  20451. private _cachedTextureMatrix;
  20452. private _projectionModeMatrix;
  20453. private _t0;
  20454. private _t1;
  20455. private _t2;
  20456. private _cachedUOffset;
  20457. private _cachedVOffset;
  20458. private _cachedUScale;
  20459. private _cachedVScale;
  20460. private _cachedUAng;
  20461. private _cachedVAng;
  20462. private _cachedWAng;
  20463. private _cachedProjectionMatrixId;
  20464. private _cachedCoordinatesMode;
  20465. /** @hidden */
  20466. protected _initialSamplingMode: number;
  20467. /** @hidden */
  20468. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20469. private _deleteBuffer;
  20470. protected _format: Nullable<number>;
  20471. private _delayedOnLoad;
  20472. private _delayedOnError;
  20473. private _mimeType?;
  20474. /**
  20475. * Observable triggered once the texture has been loaded.
  20476. */
  20477. onLoadObservable: Observable<Texture>;
  20478. protected _isBlocking: boolean;
  20479. /**
  20480. * Is the texture preventing material to render while loading.
  20481. * If false, a default texture will be used instead of the loading one during the preparation step.
  20482. */
  20483. set isBlocking(value: boolean);
  20484. get isBlocking(): boolean;
  20485. /**
  20486. * Get the current sampling mode associated with the texture.
  20487. */
  20488. get samplingMode(): number;
  20489. /**
  20490. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20491. */
  20492. get invertY(): boolean;
  20493. /**
  20494. * Instantiates a new texture.
  20495. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20496. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20497. * @param url defines the url of the picture to load as a texture
  20498. * @param scene defines the scene or engine the texture will belong to
  20499. * @param noMipmap defines if the texture will require mip maps or not
  20500. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20501. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20502. * @param onLoad defines a callback triggered when the texture has been loaded
  20503. * @param onError defines a callback triggered when an error occurred during the loading session
  20504. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20505. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20506. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20507. * @param mimeType defines an optional mime type information
  20508. */
  20509. 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);
  20510. /**
  20511. * Update the url (and optional buffer) of this texture if url was null during construction.
  20512. * @param url the url of the texture
  20513. * @param buffer the buffer of the texture (defaults to null)
  20514. * @param onLoad callback called when the texture is loaded (defaults to null)
  20515. */
  20516. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20517. /**
  20518. * Finish the loading sequence of a texture flagged as delayed load.
  20519. * @hidden
  20520. */
  20521. delayLoad(): void;
  20522. private _prepareRowForTextureGeneration;
  20523. /**
  20524. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20525. * @returns the transform matrix of the texture.
  20526. */
  20527. getTextureMatrix(uBase?: number): Matrix;
  20528. /**
  20529. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20530. * @returns The reflection texture transform
  20531. */
  20532. getReflectionTextureMatrix(): Matrix;
  20533. /**
  20534. * Clones the texture.
  20535. * @returns the cloned texture
  20536. */
  20537. clone(): Texture;
  20538. /**
  20539. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20540. * @returns The JSON representation of the texture
  20541. */
  20542. serialize(): any;
  20543. /**
  20544. * Get the current class name of the texture useful for serialization or dynamic coding.
  20545. * @returns "Texture"
  20546. */
  20547. getClassName(): string;
  20548. /**
  20549. * Dispose the texture and release its associated resources.
  20550. */
  20551. dispose(): void;
  20552. /**
  20553. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20554. * @param parsedTexture Define the JSON representation of the texture
  20555. * @param scene Define the scene the parsed texture should be instantiated in
  20556. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20557. * @returns The parsed texture if successful
  20558. */
  20559. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20560. /**
  20561. * Creates a texture from its base 64 representation.
  20562. * @param data Define the base64 payload without the data: prefix
  20563. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20564. * @param scene Define the scene the texture should belong to
  20565. * @param noMipmap Forces the texture to not create mip map information if true
  20566. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20567. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20568. * @param onLoad define a callback triggered when the texture has been loaded
  20569. * @param onError define a callback triggered when an error occurred during the loading session
  20570. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20571. * @returns the created texture
  20572. */
  20573. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20574. /**
  20575. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20576. * @param data Define the base64 payload without the data: prefix
  20577. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20578. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20579. * @param scene Define the scene the texture should belong to
  20580. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20581. * @param noMipmap Forces the texture to not create mip map information if true
  20582. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20583. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20584. * @param onLoad define a callback triggered when the texture has been loaded
  20585. * @param onError define a callback triggered when an error occurred during the loading session
  20586. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20587. * @returns the created texture
  20588. */
  20589. 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;
  20590. }
  20591. }
  20592. declare module BABYLON {
  20593. /**
  20594. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20595. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20596. */
  20597. export class PostProcessManager {
  20598. private _scene;
  20599. private _indexBuffer;
  20600. private _vertexBuffers;
  20601. /**
  20602. * Creates a new instance PostProcess
  20603. * @param scene The scene that the post process is associated with.
  20604. */
  20605. constructor(scene: Scene);
  20606. private _prepareBuffers;
  20607. private _buildIndexBuffer;
  20608. /**
  20609. * Rebuilds the vertex buffers of the manager.
  20610. * @hidden
  20611. */
  20612. _rebuild(): void;
  20613. /**
  20614. * Prepares a frame to be run through a post process.
  20615. * @param sourceTexture The input texture to the post procesess. (default: null)
  20616. * @param postProcesses An array of post processes to be run. (default: null)
  20617. * @returns True if the post processes were able to be run.
  20618. * @hidden
  20619. */
  20620. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20621. /**
  20622. * Manually render a set of post processes to a texture.
  20623. * @param postProcesses An array of post processes to be run.
  20624. * @param targetTexture The target texture to render to.
  20625. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20626. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20627. * @param lodLevel defines which lod of the texture to render to
  20628. */
  20629. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20630. /**
  20631. * Finalize the result of the output of the postprocesses.
  20632. * @param doNotPresent If true the result will not be displayed to the screen.
  20633. * @param targetTexture The target texture to render to.
  20634. * @param faceIndex The index of the face to bind the target texture to.
  20635. * @param postProcesses The array of post processes to render.
  20636. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20637. * @hidden
  20638. */
  20639. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20640. /**
  20641. * Disposes of the post process manager.
  20642. */
  20643. dispose(): void;
  20644. }
  20645. }
  20646. declare module BABYLON {
  20647. /**
  20648. * This Helps creating a texture that will be created from a camera in your scene.
  20649. * It is basically a dynamic texture that could be used to create special effects for instance.
  20650. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20651. */
  20652. export class RenderTargetTexture extends Texture {
  20653. isCube: boolean;
  20654. /**
  20655. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20656. */
  20657. static readonly REFRESHRATE_RENDER_ONCE: number;
  20658. /**
  20659. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20660. */
  20661. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20662. /**
  20663. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20664. * the central point of your effect and can save a lot of performances.
  20665. */
  20666. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20667. /**
  20668. * Use this predicate to dynamically define the list of mesh you want to render.
  20669. * If set, the renderList property will be overwritten.
  20670. */
  20671. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20672. private _renderList;
  20673. /**
  20674. * Use this list to define the list of mesh you want to render.
  20675. */
  20676. get renderList(): Nullable<Array<AbstractMesh>>;
  20677. set renderList(value: Nullable<Array<AbstractMesh>>);
  20678. /**
  20679. * Use this function to overload the renderList array at rendering time.
  20680. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20681. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20682. * the cube (if the RTT is a cube, else layerOrFace=0).
  20683. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20684. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20685. * hold dummy elements!
  20686. */
  20687. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20688. private _hookArray;
  20689. /**
  20690. * Define if particles should be rendered in your texture.
  20691. */
  20692. renderParticles: boolean;
  20693. /**
  20694. * Define if sprites should be rendered in your texture.
  20695. */
  20696. renderSprites: boolean;
  20697. /**
  20698. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20699. */
  20700. coordinatesMode: number;
  20701. /**
  20702. * Define the camera used to render the texture.
  20703. */
  20704. activeCamera: Nullable<Camera>;
  20705. /**
  20706. * Override the mesh isReady function with your own one.
  20707. */
  20708. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20709. /**
  20710. * Override the render function of the texture with your own one.
  20711. */
  20712. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20713. /**
  20714. * Define if camera post processes should be use while rendering the texture.
  20715. */
  20716. useCameraPostProcesses: boolean;
  20717. /**
  20718. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20719. */
  20720. ignoreCameraViewport: boolean;
  20721. private _postProcessManager;
  20722. private _postProcesses;
  20723. private _resizeObserver;
  20724. /**
  20725. * An event triggered when the texture is unbind.
  20726. */
  20727. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20728. /**
  20729. * An event triggered when the texture is unbind.
  20730. */
  20731. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20732. private _onAfterUnbindObserver;
  20733. /**
  20734. * Set a after unbind callback in the texture.
  20735. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20736. */
  20737. set onAfterUnbind(callback: () => void);
  20738. /**
  20739. * An event triggered before rendering the texture
  20740. */
  20741. onBeforeRenderObservable: Observable<number>;
  20742. private _onBeforeRenderObserver;
  20743. /**
  20744. * Set a before render callback in the texture.
  20745. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20746. */
  20747. set onBeforeRender(callback: (faceIndex: number) => void);
  20748. /**
  20749. * An event triggered after rendering the texture
  20750. */
  20751. onAfterRenderObservable: Observable<number>;
  20752. private _onAfterRenderObserver;
  20753. /**
  20754. * Set a after render callback in the texture.
  20755. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20756. */
  20757. set onAfterRender(callback: (faceIndex: number) => void);
  20758. /**
  20759. * An event triggered after the texture clear
  20760. */
  20761. onClearObservable: Observable<Engine>;
  20762. private _onClearObserver;
  20763. /**
  20764. * Set a clear callback in the texture.
  20765. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20766. */
  20767. set onClear(callback: (Engine: Engine) => void);
  20768. /**
  20769. * An event triggered when the texture is resized.
  20770. */
  20771. onResizeObservable: Observable<RenderTargetTexture>;
  20772. /**
  20773. * Define the clear color of the Render Target if it should be different from the scene.
  20774. */
  20775. clearColor: Color4;
  20776. protected _size: number | {
  20777. width: number;
  20778. height: number;
  20779. layers?: number;
  20780. };
  20781. protected _initialSizeParameter: number | {
  20782. width: number;
  20783. height: number;
  20784. } | {
  20785. ratio: number;
  20786. };
  20787. protected _sizeRatio: Nullable<number>;
  20788. /** @hidden */
  20789. _generateMipMaps: boolean;
  20790. protected _renderingManager: RenderingManager;
  20791. /** @hidden */
  20792. _waitingRenderList: string[];
  20793. protected _doNotChangeAspectRatio: boolean;
  20794. protected _currentRefreshId: number;
  20795. protected _refreshRate: number;
  20796. protected _textureMatrix: Matrix;
  20797. protected _samples: number;
  20798. protected _renderTargetOptions: RenderTargetCreationOptions;
  20799. /**
  20800. * Gets render target creation options that were used.
  20801. */
  20802. get renderTargetOptions(): RenderTargetCreationOptions;
  20803. protected _engine: Engine;
  20804. protected _onRatioRescale(): void;
  20805. /**
  20806. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20807. * It must define where the camera used to render the texture is set
  20808. */
  20809. boundingBoxPosition: Vector3;
  20810. private _boundingBoxSize;
  20811. /**
  20812. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20813. * When defined, the cubemap will switch to local mode
  20814. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20815. * @example https://www.babylonjs-playground.com/#RNASML
  20816. */
  20817. set boundingBoxSize(value: Vector3);
  20818. get boundingBoxSize(): Vector3;
  20819. /**
  20820. * In case the RTT has been created with a depth texture, get the associated
  20821. * depth texture.
  20822. * Otherwise, return null.
  20823. */
  20824. get depthStencilTexture(): Nullable<InternalTexture>;
  20825. /**
  20826. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20827. * or used a shadow, depth texture...
  20828. * @param name The friendly name of the texture
  20829. * @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)
  20830. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20831. * @param generateMipMaps True if mip maps need to be generated after render.
  20832. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20833. * @param type The type of the buffer in the RTT (int, half float, float...)
  20834. * @param isCube True if a cube texture needs to be created
  20835. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20836. * @param generateDepthBuffer True to generate a depth buffer
  20837. * @param generateStencilBuffer True to generate a stencil buffer
  20838. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20839. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20840. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20841. */
  20842. constructor(name: string, size: number | {
  20843. width: number;
  20844. height: number;
  20845. layers?: number;
  20846. } | {
  20847. ratio: number;
  20848. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20849. /**
  20850. * Creates a depth stencil texture.
  20851. * This is only available in WebGL 2 or with the depth texture extension available.
  20852. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20853. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20854. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20855. */
  20856. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20857. private _processSizeParameter;
  20858. /**
  20859. * Define the number of samples to use in case of MSAA.
  20860. * It defaults to one meaning no MSAA has been enabled.
  20861. */
  20862. get samples(): number;
  20863. set samples(value: number);
  20864. /**
  20865. * Resets the refresh counter of the texture and start bak from scratch.
  20866. * Could be useful to regenerate the texture if it is setup to render only once.
  20867. */
  20868. resetRefreshCounter(): void;
  20869. /**
  20870. * Define the refresh rate of the texture or the rendering frequency.
  20871. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20872. */
  20873. get refreshRate(): number;
  20874. set refreshRate(value: number);
  20875. /**
  20876. * Adds a post process to the render target rendering passes.
  20877. * @param postProcess define the post process to add
  20878. */
  20879. addPostProcess(postProcess: PostProcess): void;
  20880. /**
  20881. * Clear all the post processes attached to the render target
  20882. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20883. */
  20884. clearPostProcesses(dispose?: boolean): void;
  20885. /**
  20886. * Remove one of the post process from the list of attached post processes to the texture
  20887. * @param postProcess define the post process to remove from the list
  20888. */
  20889. removePostProcess(postProcess: PostProcess): void;
  20890. /** @hidden */
  20891. _shouldRender(): boolean;
  20892. /**
  20893. * Gets the actual render size of the texture.
  20894. * @returns the width of the render size
  20895. */
  20896. getRenderSize(): number;
  20897. /**
  20898. * Gets the actual render width of the texture.
  20899. * @returns the width of the render size
  20900. */
  20901. getRenderWidth(): number;
  20902. /**
  20903. * Gets the actual render height of the texture.
  20904. * @returns the height of the render size
  20905. */
  20906. getRenderHeight(): number;
  20907. /**
  20908. * Gets the actual number of layers of the texture.
  20909. * @returns the number of layers
  20910. */
  20911. getRenderLayers(): number;
  20912. /**
  20913. * Get if the texture can be rescaled or not.
  20914. */
  20915. get canRescale(): boolean;
  20916. /**
  20917. * Resize the texture using a ratio.
  20918. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20919. */
  20920. scale(ratio: number): void;
  20921. /**
  20922. * Get the texture reflection matrix used to rotate/transform the reflection.
  20923. * @returns the reflection matrix
  20924. */
  20925. getReflectionTextureMatrix(): Matrix;
  20926. /**
  20927. * Resize the texture to a new desired size.
  20928. * Be carrefull as it will recreate all the data in the new texture.
  20929. * @param size Define the new size. It can be:
  20930. * - a number for squared texture,
  20931. * - an object containing { width: number, height: number }
  20932. * - or an object containing a ratio { ratio: number }
  20933. */
  20934. resize(size: number | {
  20935. width: number;
  20936. height: number;
  20937. } | {
  20938. ratio: number;
  20939. }): void;
  20940. private _defaultRenderListPrepared;
  20941. /**
  20942. * Renders all the objects from the render list into the texture.
  20943. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20944. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20945. */
  20946. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20947. private _bestReflectionRenderTargetDimension;
  20948. private _prepareRenderingManager;
  20949. /**
  20950. * @hidden
  20951. * @param faceIndex face index to bind to if this is a cubetexture
  20952. * @param layer defines the index of the texture to bind in the array
  20953. */
  20954. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20955. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20956. private renderToTarget;
  20957. /**
  20958. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20959. * This allowed control for front to back rendering or reversly depending of the special needs.
  20960. *
  20961. * @param renderingGroupId The rendering group id corresponding to its index
  20962. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20963. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20964. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20965. */
  20966. 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;
  20967. /**
  20968. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20969. *
  20970. * @param renderingGroupId The rendering group id corresponding to its index
  20971. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20972. */
  20973. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20974. /**
  20975. * Clones the texture.
  20976. * @returns the cloned texture
  20977. */
  20978. clone(): RenderTargetTexture;
  20979. /**
  20980. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20981. * @returns The JSON representation of the texture
  20982. */
  20983. serialize(): any;
  20984. /**
  20985. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20986. */
  20987. disposeFramebufferObjects(): void;
  20988. /**
  20989. * Dispose the texture and release its associated resources.
  20990. */
  20991. dispose(): void;
  20992. /** @hidden */
  20993. _rebuild(): void;
  20994. /**
  20995. * Clear the info related to rendering groups preventing retention point in material dispose.
  20996. */
  20997. freeRenderingGroups(): void;
  20998. /**
  20999. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21000. * @returns the view count
  21001. */
  21002. getViewCount(): number;
  21003. }
  21004. }
  21005. declare module BABYLON {
  21006. /**
  21007. * Class used to manipulate GUIDs
  21008. */
  21009. export class GUID {
  21010. /**
  21011. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21012. * Be aware Math.random() could cause collisions, but:
  21013. * "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"
  21014. * @returns a pseudo random id
  21015. */
  21016. static RandomId(): string;
  21017. }
  21018. }
  21019. declare module BABYLON {
  21020. /**
  21021. * Options to be used when creating a shadow depth material
  21022. */
  21023. export interface IIOptionShadowDepthMaterial {
  21024. /** Variables in the vertex shader code that need to have their names remapped.
  21025. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21026. * "var_name" should be either: worldPos or vNormalW
  21027. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21028. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21029. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21030. */
  21031. remappedVariables?: string[];
  21032. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21033. standalone?: boolean;
  21034. }
  21035. /**
  21036. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21037. */
  21038. export class ShadowDepthWrapper {
  21039. private _scene;
  21040. private _options?;
  21041. private _baseMaterial;
  21042. private _onEffectCreatedObserver;
  21043. private _subMeshToEffect;
  21044. private _subMeshToDepthEffect;
  21045. private _meshes;
  21046. /** @hidden */
  21047. _matriceNames: any;
  21048. /** Gets the standalone status of the wrapper */
  21049. get standalone(): boolean;
  21050. /** Gets the base material the wrapper is built upon */
  21051. get baseMaterial(): Material;
  21052. /**
  21053. * Instantiate a new shadow depth wrapper.
  21054. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21055. * generate the shadow depth map. For more information, please refer to the documentation:
  21056. * https://doc.babylonjs.com/babylon101/shadows
  21057. * @param baseMaterial Material to wrap
  21058. * @param scene Define the scene the material belongs to
  21059. * @param options Options used to create the wrapper
  21060. */
  21061. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21062. /**
  21063. * Gets the effect to use to generate the depth map
  21064. * @param subMesh subMesh to get the effect for
  21065. * @param shadowGenerator shadow generator to get the effect for
  21066. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21067. */
  21068. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21069. /**
  21070. * Specifies that the submesh is ready to be used for depth rendering
  21071. * @param subMesh submesh to check
  21072. * @param defines the list of defines to take into account when checking the effect
  21073. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21074. * @param useInstances specifies that instances should be used
  21075. * @returns a boolean indicating that the submesh is ready or not
  21076. */
  21077. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21078. /**
  21079. * Disposes the resources
  21080. */
  21081. dispose(): void;
  21082. private _makeEffect;
  21083. }
  21084. }
  21085. declare module BABYLON {
  21086. /**
  21087. * Options for compiling materials.
  21088. */
  21089. export interface IMaterialCompilationOptions {
  21090. /**
  21091. * Defines whether clip planes are enabled.
  21092. */
  21093. clipPlane: boolean;
  21094. /**
  21095. * Defines whether instances are enabled.
  21096. */
  21097. useInstances: boolean;
  21098. }
  21099. /**
  21100. * Base class for the main features of a material in Babylon.js
  21101. */
  21102. export class Material implements IAnimatable {
  21103. /**
  21104. * Returns the triangle fill mode
  21105. */
  21106. static readonly TriangleFillMode: number;
  21107. /**
  21108. * Returns the wireframe mode
  21109. */
  21110. static readonly WireFrameFillMode: number;
  21111. /**
  21112. * Returns the point fill mode
  21113. */
  21114. static readonly PointFillMode: number;
  21115. /**
  21116. * Returns the point list draw mode
  21117. */
  21118. static readonly PointListDrawMode: number;
  21119. /**
  21120. * Returns the line list draw mode
  21121. */
  21122. static readonly LineListDrawMode: number;
  21123. /**
  21124. * Returns the line loop draw mode
  21125. */
  21126. static readonly LineLoopDrawMode: number;
  21127. /**
  21128. * Returns the line strip draw mode
  21129. */
  21130. static readonly LineStripDrawMode: number;
  21131. /**
  21132. * Returns the triangle strip draw mode
  21133. */
  21134. static readonly TriangleStripDrawMode: number;
  21135. /**
  21136. * Returns the triangle fan draw mode
  21137. */
  21138. static readonly TriangleFanDrawMode: number;
  21139. /**
  21140. * Stores the clock-wise side orientation
  21141. */
  21142. static readonly ClockWiseSideOrientation: number;
  21143. /**
  21144. * Stores the counter clock-wise side orientation
  21145. */
  21146. static readonly CounterClockWiseSideOrientation: number;
  21147. /**
  21148. * The dirty texture flag value
  21149. */
  21150. static readonly TextureDirtyFlag: number;
  21151. /**
  21152. * The dirty light flag value
  21153. */
  21154. static readonly LightDirtyFlag: number;
  21155. /**
  21156. * The dirty fresnel flag value
  21157. */
  21158. static readonly FresnelDirtyFlag: number;
  21159. /**
  21160. * The dirty attribute flag value
  21161. */
  21162. static readonly AttributesDirtyFlag: number;
  21163. /**
  21164. * The dirty misc flag value
  21165. */
  21166. static readonly MiscDirtyFlag: number;
  21167. /**
  21168. * The all dirty flag value
  21169. */
  21170. static readonly AllDirtyFlag: number;
  21171. /**
  21172. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21173. */
  21174. static readonly MATERIAL_OPAQUE: number;
  21175. /**
  21176. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21177. */
  21178. static readonly MATERIAL_ALPHATEST: number;
  21179. /**
  21180. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21181. */
  21182. static readonly MATERIAL_ALPHABLEND: number;
  21183. /**
  21184. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21185. * They are also discarded below the alpha cutoff threshold to improve performances.
  21186. */
  21187. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21188. /**
  21189. * Custom callback helping to override the default shader used in the material.
  21190. */
  21191. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21192. /**
  21193. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21194. */
  21195. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21196. /**
  21197. * The ID of the material
  21198. */
  21199. id: string;
  21200. /**
  21201. * Gets or sets the unique id of the material
  21202. */
  21203. uniqueId: number;
  21204. /**
  21205. * The name of the material
  21206. */
  21207. name: string;
  21208. /**
  21209. * Gets or sets user defined metadata
  21210. */
  21211. metadata: any;
  21212. /**
  21213. * For internal use only. Please do not use.
  21214. */
  21215. reservedDataStore: any;
  21216. /**
  21217. * Specifies if the ready state should be checked on each call
  21218. */
  21219. checkReadyOnEveryCall: boolean;
  21220. /**
  21221. * Specifies if the ready state should be checked once
  21222. */
  21223. checkReadyOnlyOnce: boolean;
  21224. /**
  21225. * The state of the material
  21226. */
  21227. state: string;
  21228. /**
  21229. * The alpha value of the material
  21230. */
  21231. protected _alpha: number;
  21232. /**
  21233. * List of inspectable custom properties (used by the Inspector)
  21234. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21235. */
  21236. inspectableCustomProperties: IInspectable[];
  21237. /**
  21238. * Sets the alpha value of the material
  21239. */
  21240. set alpha(value: number);
  21241. /**
  21242. * Gets the alpha value of the material
  21243. */
  21244. get alpha(): number;
  21245. /**
  21246. * Specifies if back face culling is enabled
  21247. */
  21248. protected _backFaceCulling: boolean;
  21249. /**
  21250. * Sets the back-face culling state
  21251. */
  21252. set backFaceCulling(value: boolean);
  21253. /**
  21254. * Gets the back-face culling state
  21255. */
  21256. get backFaceCulling(): boolean;
  21257. /**
  21258. * Stores the value for side orientation
  21259. */
  21260. sideOrientation: number;
  21261. /**
  21262. * Callback triggered when the material is compiled
  21263. */
  21264. onCompiled: Nullable<(effect: Effect) => void>;
  21265. /**
  21266. * Callback triggered when an error occurs
  21267. */
  21268. onError: Nullable<(effect: Effect, errors: string) => void>;
  21269. /**
  21270. * Callback triggered to get the render target textures
  21271. */
  21272. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21273. /**
  21274. * Gets a boolean indicating that current material needs to register RTT
  21275. */
  21276. get hasRenderTargetTextures(): boolean;
  21277. /**
  21278. * Specifies if the material should be serialized
  21279. */
  21280. doNotSerialize: boolean;
  21281. /**
  21282. * @hidden
  21283. */
  21284. _storeEffectOnSubMeshes: boolean;
  21285. /**
  21286. * Stores the animations for the material
  21287. */
  21288. animations: Nullable<Array<Animation>>;
  21289. /**
  21290. * An event triggered when the material is disposed
  21291. */
  21292. onDisposeObservable: Observable<Material>;
  21293. /**
  21294. * An observer which watches for dispose events
  21295. */
  21296. private _onDisposeObserver;
  21297. private _onUnBindObservable;
  21298. /**
  21299. * Called during a dispose event
  21300. */
  21301. set onDispose(callback: () => void);
  21302. private _onBindObservable;
  21303. /**
  21304. * An event triggered when the material is bound
  21305. */
  21306. get onBindObservable(): Observable<AbstractMesh>;
  21307. /**
  21308. * An observer which watches for bind events
  21309. */
  21310. private _onBindObserver;
  21311. /**
  21312. * Called during a bind event
  21313. */
  21314. set onBind(callback: (Mesh: AbstractMesh) => void);
  21315. /**
  21316. * An event triggered when the material is unbound
  21317. */
  21318. get onUnBindObservable(): Observable<Material>;
  21319. protected _onEffectCreatedObservable: Nullable<Observable<{
  21320. effect: Effect;
  21321. subMesh: Nullable<SubMesh>;
  21322. }>>;
  21323. /**
  21324. * An event triggered when the effect is (re)created
  21325. */
  21326. get onEffectCreatedObservable(): Observable<{
  21327. effect: Effect;
  21328. subMesh: Nullable<SubMesh>;
  21329. }>;
  21330. /**
  21331. * Stores the value of the alpha mode
  21332. */
  21333. private _alphaMode;
  21334. /**
  21335. * Sets the value of the alpha mode.
  21336. *
  21337. * | Value | Type | Description |
  21338. * | --- | --- | --- |
  21339. * | 0 | ALPHA_DISABLE | |
  21340. * | 1 | ALPHA_ADD | |
  21341. * | 2 | ALPHA_COMBINE | |
  21342. * | 3 | ALPHA_SUBTRACT | |
  21343. * | 4 | ALPHA_MULTIPLY | |
  21344. * | 5 | ALPHA_MAXIMIZED | |
  21345. * | 6 | ALPHA_ONEONE | |
  21346. * | 7 | ALPHA_PREMULTIPLIED | |
  21347. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21348. * | 9 | ALPHA_INTERPOLATE | |
  21349. * | 10 | ALPHA_SCREENMODE | |
  21350. *
  21351. */
  21352. set alphaMode(value: number);
  21353. /**
  21354. * Gets the value of the alpha mode
  21355. */
  21356. get alphaMode(): number;
  21357. /**
  21358. * Stores the state of the need depth pre-pass value
  21359. */
  21360. private _needDepthPrePass;
  21361. /**
  21362. * Sets the need depth pre-pass value
  21363. */
  21364. set needDepthPrePass(value: boolean);
  21365. /**
  21366. * Gets the depth pre-pass value
  21367. */
  21368. get needDepthPrePass(): boolean;
  21369. /**
  21370. * Specifies if depth writing should be disabled
  21371. */
  21372. disableDepthWrite: boolean;
  21373. /**
  21374. * Specifies if depth writing should be forced
  21375. */
  21376. forceDepthWrite: boolean;
  21377. /**
  21378. * Specifies the depth function that should be used. 0 means the default engine function
  21379. */
  21380. depthFunction: number;
  21381. /**
  21382. * Specifies if there should be a separate pass for culling
  21383. */
  21384. separateCullingPass: boolean;
  21385. /**
  21386. * Stores the state specifing if fog should be enabled
  21387. */
  21388. private _fogEnabled;
  21389. /**
  21390. * Sets the state for enabling fog
  21391. */
  21392. set fogEnabled(value: boolean);
  21393. /**
  21394. * Gets the value of the fog enabled state
  21395. */
  21396. get fogEnabled(): boolean;
  21397. /**
  21398. * Stores the size of points
  21399. */
  21400. pointSize: number;
  21401. /**
  21402. * Stores the z offset value
  21403. */
  21404. zOffset: number;
  21405. /**
  21406. * Gets a value specifying if wireframe mode is enabled
  21407. */
  21408. get wireframe(): boolean;
  21409. /**
  21410. * Sets the state of wireframe mode
  21411. */
  21412. set wireframe(value: boolean);
  21413. /**
  21414. * Gets the value specifying if point clouds are enabled
  21415. */
  21416. get pointsCloud(): boolean;
  21417. /**
  21418. * Sets the state of point cloud mode
  21419. */
  21420. set pointsCloud(value: boolean);
  21421. /**
  21422. * Gets the material fill mode
  21423. */
  21424. get fillMode(): number;
  21425. /**
  21426. * Sets the material fill mode
  21427. */
  21428. set fillMode(value: number);
  21429. /**
  21430. * @hidden
  21431. * Stores the effects for the material
  21432. */
  21433. _effect: Nullable<Effect>;
  21434. /**
  21435. * Specifies if uniform buffers should be used
  21436. */
  21437. private _useUBO;
  21438. /**
  21439. * Stores a reference to the scene
  21440. */
  21441. private _scene;
  21442. /**
  21443. * Stores the fill mode state
  21444. */
  21445. private _fillMode;
  21446. /**
  21447. * Specifies if the depth write state should be cached
  21448. */
  21449. private _cachedDepthWriteState;
  21450. /**
  21451. * Specifies if the depth function state should be cached
  21452. */
  21453. private _cachedDepthFunctionState;
  21454. /**
  21455. * Stores the uniform buffer
  21456. */
  21457. protected _uniformBuffer: UniformBuffer;
  21458. /** @hidden */
  21459. _indexInSceneMaterialArray: number;
  21460. /** @hidden */
  21461. meshMap: Nullable<{
  21462. [id: string]: AbstractMesh | undefined;
  21463. }>;
  21464. /**
  21465. * Creates a material instance
  21466. * @param name defines the name of the material
  21467. * @param scene defines the scene to reference
  21468. * @param doNotAdd specifies if the material should be added to the scene
  21469. */
  21470. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21471. /**
  21472. * Returns a string representation of the current material
  21473. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21474. * @returns a string with material information
  21475. */
  21476. toString(fullDetails?: boolean): string;
  21477. /**
  21478. * Gets the class name of the material
  21479. * @returns a string with the class name of the material
  21480. */
  21481. getClassName(): string;
  21482. /**
  21483. * Specifies if updates for the material been locked
  21484. */
  21485. get isFrozen(): boolean;
  21486. /**
  21487. * Locks updates for the material
  21488. */
  21489. freeze(): void;
  21490. /**
  21491. * Unlocks updates for the material
  21492. */
  21493. unfreeze(): void;
  21494. /**
  21495. * Specifies if the material is ready to be used
  21496. * @param mesh defines the mesh to check
  21497. * @param useInstances specifies if instances should be used
  21498. * @returns a boolean indicating if the material is ready to be used
  21499. */
  21500. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21501. /**
  21502. * Specifies that the submesh is ready to be used
  21503. * @param mesh defines the mesh to check
  21504. * @param subMesh defines which submesh to check
  21505. * @param useInstances specifies that instances should be used
  21506. * @returns a boolean indicating that the submesh is ready or not
  21507. */
  21508. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21509. /**
  21510. * Returns the material effect
  21511. * @returns the effect associated with the material
  21512. */
  21513. getEffect(): Nullable<Effect>;
  21514. /**
  21515. * Returns the current scene
  21516. * @returns a Scene
  21517. */
  21518. getScene(): Scene;
  21519. /**
  21520. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21521. */
  21522. protected _forceAlphaTest: boolean;
  21523. /**
  21524. * The transparency mode of the material.
  21525. */
  21526. protected _transparencyMode: Nullable<number>;
  21527. /**
  21528. * Gets the current transparency mode.
  21529. */
  21530. get transparencyMode(): Nullable<number>;
  21531. /**
  21532. * Sets the transparency mode of the material.
  21533. *
  21534. * | Value | Type | Description |
  21535. * | ----- | ----------------------------------- | ----------- |
  21536. * | 0 | OPAQUE | |
  21537. * | 1 | ALPHATEST | |
  21538. * | 2 | ALPHABLEND | |
  21539. * | 3 | ALPHATESTANDBLEND | |
  21540. *
  21541. */
  21542. set transparencyMode(value: Nullable<number>);
  21543. /**
  21544. * Returns true if alpha blending should be disabled.
  21545. */
  21546. protected get _disableAlphaBlending(): boolean;
  21547. /**
  21548. * Specifies whether or not this material should be rendered in alpha blend mode.
  21549. * @returns a boolean specifying if alpha blending is needed
  21550. */
  21551. needAlphaBlending(): boolean;
  21552. /**
  21553. * Specifies if the mesh will require alpha blending
  21554. * @param mesh defines the mesh to check
  21555. * @returns a boolean specifying if alpha blending is needed for the mesh
  21556. */
  21557. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21558. /**
  21559. * Specifies whether or not this material should be rendered in alpha test mode.
  21560. * @returns a boolean specifying if an alpha test is needed.
  21561. */
  21562. needAlphaTesting(): boolean;
  21563. /**
  21564. * Specifies if material alpha testing should be turned on for the mesh
  21565. * @param mesh defines the mesh to check
  21566. */
  21567. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21568. /**
  21569. * Gets the texture used for the alpha test
  21570. * @returns the texture to use for alpha testing
  21571. */
  21572. getAlphaTestTexture(): Nullable<BaseTexture>;
  21573. /**
  21574. * Marks the material to indicate that it needs to be re-calculated
  21575. */
  21576. markDirty(): void;
  21577. /** @hidden */
  21578. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21579. /**
  21580. * Binds the material to the mesh
  21581. * @param world defines the world transformation matrix
  21582. * @param mesh defines the mesh to bind the material to
  21583. */
  21584. bind(world: Matrix, mesh?: Mesh): void;
  21585. /**
  21586. * Binds the submesh to the material
  21587. * @param world defines the world transformation matrix
  21588. * @param mesh defines the mesh containing the submesh
  21589. * @param subMesh defines the submesh to bind the material to
  21590. */
  21591. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21592. /**
  21593. * Binds the world matrix to the material
  21594. * @param world defines the world transformation matrix
  21595. */
  21596. bindOnlyWorldMatrix(world: Matrix): void;
  21597. /**
  21598. * Binds the scene's uniform buffer to the effect.
  21599. * @param effect defines the effect to bind to the scene uniform buffer
  21600. * @param sceneUbo defines the uniform buffer storing scene data
  21601. */
  21602. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21603. /**
  21604. * Binds the view matrix to the effect
  21605. * @param effect defines the effect to bind the view matrix to
  21606. */
  21607. bindView(effect: Effect): void;
  21608. /**
  21609. * Binds the view projection matrix to the effect
  21610. * @param effect defines the effect to bind the view projection matrix to
  21611. */
  21612. bindViewProjection(effect: Effect): void;
  21613. /**
  21614. * Processes to execute after binding the material to a mesh
  21615. * @param mesh defines the rendered mesh
  21616. */
  21617. protected _afterBind(mesh?: Mesh): void;
  21618. /**
  21619. * Unbinds the material from the mesh
  21620. */
  21621. unbind(): void;
  21622. /**
  21623. * Gets the active textures from the material
  21624. * @returns an array of textures
  21625. */
  21626. getActiveTextures(): BaseTexture[];
  21627. /**
  21628. * Specifies if the material uses a texture
  21629. * @param texture defines the texture to check against the material
  21630. * @returns a boolean specifying if the material uses the texture
  21631. */
  21632. hasTexture(texture: BaseTexture): boolean;
  21633. /**
  21634. * Makes a duplicate of the material, and gives it a new name
  21635. * @param name defines the new name for the duplicated material
  21636. * @returns the cloned material
  21637. */
  21638. clone(name: string): Nullable<Material>;
  21639. /**
  21640. * Gets the meshes bound to the material
  21641. * @returns an array of meshes bound to the material
  21642. */
  21643. getBindedMeshes(): AbstractMesh[];
  21644. /**
  21645. * Force shader compilation
  21646. * @param mesh defines the mesh associated with this material
  21647. * @param onCompiled defines a function to execute once the material is compiled
  21648. * @param options defines the options to configure the compilation
  21649. * @param onError defines a function to execute if the material fails compiling
  21650. */
  21651. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21652. /**
  21653. * Force shader compilation
  21654. * @param mesh defines the mesh that will use this material
  21655. * @param options defines additional options for compiling the shaders
  21656. * @returns a promise that resolves when the compilation completes
  21657. */
  21658. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21659. private static readonly _AllDirtyCallBack;
  21660. private static readonly _ImageProcessingDirtyCallBack;
  21661. private static readonly _TextureDirtyCallBack;
  21662. private static readonly _FresnelDirtyCallBack;
  21663. private static readonly _MiscDirtyCallBack;
  21664. private static readonly _LightsDirtyCallBack;
  21665. private static readonly _AttributeDirtyCallBack;
  21666. private static _FresnelAndMiscDirtyCallBack;
  21667. private static _TextureAndMiscDirtyCallBack;
  21668. private static readonly _DirtyCallbackArray;
  21669. private static readonly _RunDirtyCallBacks;
  21670. /**
  21671. * Marks a define in the material to indicate that it needs to be re-computed
  21672. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21673. */
  21674. markAsDirty(flag: number): void;
  21675. /**
  21676. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21677. * @param func defines a function which checks material defines against the submeshes
  21678. */
  21679. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21680. /**
  21681. * Indicates that we need to re-calculated for all submeshes
  21682. */
  21683. protected _markAllSubMeshesAsAllDirty(): void;
  21684. /**
  21685. * Indicates that image processing needs to be re-calculated for all submeshes
  21686. */
  21687. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21688. /**
  21689. * Indicates that textures need to be re-calculated for all submeshes
  21690. */
  21691. protected _markAllSubMeshesAsTexturesDirty(): void;
  21692. /**
  21693. * Indicates that fresnel needs to be re-calculated for all submeshes
  21694. */
  21695. protected _markAllSubMeshesAsFresnelDirty(): void;
  21696. /**
  21697. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21698. */
  21699. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21700. /**
  21701. * Indicates that lights need to be re-calculated for all submeshes
  21702. */
  21703. protected _markAllSubMeshesAsLightsDirty(): void;
  21704. /**
  21705. * Indicates that attributes need to be re-calculated for all submeshes
  21706. */
  21707. protected _markAllSubMeshesAsAttributesDirty(): void;
  21708. /**
  21709. * Indicates that misc needs to be re-calculated for all submeshes
  21710. */
  21711. protected _markAllSubMeshesAsMiscDirty(): void;
  21712. /**
  21713. * Indicates that textures and misc need to be re-calculated for all submeshes
  21714. */
  21715. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21716. /**
  21717. * Disposes the material
  21718. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21719. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21720. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21721. */
  21722. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21723. /** @hidden */
  21724. private releaseVertexArrayObject;
  21725. /**
  21726. * Serializes this material
  21727. * @returns the serialized material object
  21728. */
  21729. serialize(): any;
  21730. /**
  21731. * Creates a material from parsed material data
  21732. * @param parsedMaterial defines parsed material data
  21733. * @param scene defines the hosting scene
  21734. * @param rootUrl defines the root URL to use to load textures
  21735. * @returns a new material
  21736. */
  21737. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21738. }
  21739. }
  21740. declare module BABYLON {
  21741. /**
  21742. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21743. * separate meshes. This can be use to improve performances.
  21744. * @see http://doc.babylonjs.com/how_to/multi_materials
  21745. */
  21746. export class MultiMaterial extends Material {
  21747. private _subMaterials;
  21748. /**
  21749. * Gets or Sets the list of Materials used within the multi material.
  21750. * They need to be ordered according to the submeshes order in the associated mesh
  21751. */
  21752. get subMaterials(): Nullable<Material>[];
  21753. set subMaterials(value: Nullable<Material>[]);
  21754. /**
  21755. * Function used to align with Node.getChildren()
  21756. * @returns the list of Materials used within the multi material
  21757. */
  21758. getChildren(): Nullable<Material>[];
  21759. /**
  21760. * Instantiates a new Multi Material
  21761. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21762. * separate meshes. This can be use to improve performances.
  21763. * @see http://doc.babylonjs.com/how_to/multi_materials
  21764. * @param name Define the name in the scene
  21765. * @param scene Define the scene the material belongs to
  21766. */
  21767. constructor(name: string, scene: Scene);
  21768. private _hookArray;
  21769. /**
  21770. * Get one of the submaterial by its index in the submaterials array
  21771. * @param index The index to look the sub material at
  21772. * @returns The Material if the index has been defined
  21773. */
  21774. getSubMaterial(index: number): Nullable<Material>;
  21775. /**
  21776. * Get the list of active textures for the whole sub materials list.
  21777. * @returns All the textures that will be used during the rendering
  21778. */
  21779. getActiveTextures(): BaseTexture[];
  21780. /**
  21781. * Gets the current class name of the material e.g. "MultiMaterial"
  21782. * Mainly use in serialization.
  21783. * @returns the class name
  21784. */
  21785. getClassName(): string;
  21786. /**
  21787. * Checks if the material is ready to render the requested sub mesh
  21788. * @param mesh Define the mesh the submesh belongs to
  21789. * @param subMesh Define the sub mesh to look readyness for
  21790. * @param useInstances Define whether or not the material is used with instances
  21791. * @returns true if ready, otherwise false
  21792. */
  21793. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21794. /**
  21795. * Clones the current material and its related sub materials
  21796. * @param name Define the name of the newly cloned material
  21797. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21798. * @returns the cloned material
  21799. */
  21800. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21801. /**
  21802. * Serializes the materials into a JSON representation.
  21803. * @returns the JSON representation
  21804. */
  21805. serialize(): any;
  21806. /**
  21807. * Dispose the material and release its associated resources
  21808. * @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)
  21809. * @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)
  21810. * @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)
  21811. */
  21812. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21813. /**
  21814. * Creates a MultiMaterial from parsed MultiMaterial data.
  21815. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21816. * @param scene defines the hosting scene
  21817. * @returns a new MultiMaterial
  21818. */
  21819. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21820. }
  21821. }
  21822. declare module BABYLON {
  21823. /**
  21824. * Base class for submeshes
  21825. */
  21826. export class BaseSubMesh {
  21827. /** @hidden */
  21828. _materialDefines: Nullable<MaterialDefines>;
  21829. /** @hidden */
  21830. _materialEffect: Nullable<Effect>;
  21831. /** @hidden */
  21832. _effectOverride: Nullable<Effect>;
  21833. /**
  21834. * Gets material defines used by the effect associated to the sub mesh
  21835. */
  21836. get materialDefines(): Nullable<MaterialDefines>;
  21837. /**
  21838. * Sets material defines used by the effect associated to the sub mesh
  21839. */
  21840. set materialDefines(defines: Nullable<MaterialDefines>);
  21841. /**
  21842. * Gets associated effect
  21843. */
  21844. get effect(): Nullable<Effect>;
  21845. /**
  21846. * Sets associated effect (effect used to render this submesh)
  21847. * @param effect defines the effect to associate with
  21848. * @param defines defines the set of defines used to compile this effect
  21849. */
  21850. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21851. }
  21852. /**
  21853. * Defines a subdivision inside a mesh
  21854. */
  21855. export class SubMesh extends BaseSubMesh implements ICullable {
  21856. /** the material index to use */
  21857. materialIndex: number;
  21858. /** vertex index start */
  21859. verticesStart: number;
  21860. /** vertices count */
  21861. verticesCount: number;
  21862. /** index start */
  21863. indexStart: number;
  21864. /** indices count */
  21865. indexCount: number;
  21866. /** @hidden */
  21867. _linesIndexCount: number;
  21868. private _mesh;
  21869. private _renderingMesh;
  21870. private _boundingInfo;
  21871. private _linesIndexBuffer;
  21872. /** @hidden */
  21873. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21874. /** @hidden */
  21875. _trianglePlanes: Plane[];
  21876. /** @hidden */
  21877. _lastColliderTransformMatrix: Nullable<Matrix>;
  21878. /** @hidden */
  21879. _renderId: number;
  21880. /** @hidden */
  21881. _alphaIndex: number;
  21882. /** @hidden */
  21883. _distanceToCamera: number;
  21884. /** @hidden */
  21885. _id: number;
  21886. private _currentMaterial;
  21887. /**
  21888. * Add a new submesh to a mesh
  21889. * @param materialIndex defines the material index to use
  21890. * @param verticesStart defines vertex index start
  21891. * @param verticesCount defines vertices count
  21892. * @param indexStart defines index start
  21893. * @param indexCount defines indices count
  21894. * @param mesh defines the parent mesh
  21895. * @param renderingMesh defines an optional rendering mesh
  21896. * @param createBoundingBox defines if bounding box should be created for this submesh
  21897. * @returns the new submesh
  21898. */
  21899. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21900. /**
  21901. * Creates a new submesh
  21902. * @param materialIndex defines the material index to use
  21903. * @param verticesStart defines vertex index start
  21904. * @param verticesCount defines vertices count
  21905. * @param indexStart defines index start
  21906. * @param indexCount defines indices count
  21907. * @param mesh defines the parent mesh
  21908. * @param renderingMesh defines an optional rendering mesh
  21909. * @param createBoundingBox defines if bounding box should be created for this submesh
  21910. */
  21911. constructor(
  21912. /** the material index to use */
  21913. materialIndex: number,
  21914. /** vertex index start */
  21915. verticesStart: number,
  21916. /** vertices count */
  21917. verticesCount: number,
  21918. /** index start */
  21919. indexStart: number,
  21920. /** indices count */
  21921. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21922. /**
  21923. * Returns true if this submesh covers the entire parent mesh
  21924. * @ignorenaming
  21925. */
  21926. get IsGlobal(): boolean;
  21927. /**
  21928. * Returns the submesh BoudingInfo object
  21929. * @returns current bounding info (or mesh's one if the submesh is global)
  21930. */
  21931. getBoundingInfo(): BoundingInfo;
  21932. /**
  21933. * Sets the submesh BoundingInfo
  21934. * @param boundingInfo defines the new bounding info to use
  21935. * @returns the SubMesh
  21936. */
  21937. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21938. /**
  21939. * Returns the mesh of the current submesh
  21940. * @return the parent mesh
  21941. */
  21942. getMesh(): AbstractMesh;
  21943. /**
  21944. * Returns the rendering mesh of the submesh
  21945. * @returns the rendering mesh (could be different from parent mesh)
  21946. */
  21947. getRenderingMesh(): Mesh;
  21948. /**
  21949. * Returns the submesh material
  21950. * @returns null or the current material
  21951. */
  21952. getMaterial(): Nullable<Material>;
  21953. /**
  21954. * Sets a new updated BoundingInfo object to the submesh
  21955. * @param data defines an optional position array to use to determine the bounding info
  21956. * @returns the SubMesh
  21957. */
  21958. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21959. /** @hidden */
  21960. _checkCollision(collider: Collider): boolean;
  21961. /**
  21962. * Updates the submesh BoundingInfo
  21963. * @param world defines the world matrix to use to update the bounding info
  21964. * @returns the submesh
  21965. */
  21966. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21967. /**
  21968. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21969. * @param frustumPlanes defines the frustum planes
  21970. * @returns true if the submesh is intersecting with the frustum
  21971. */
  21972. isInFrustum(frustumPlanes: Plane[]): boolean;
  21973. /**
  21974. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21975. * @param frustumPlanes defines the frustum planes
  21976. * @returns true if the submesh is inside the frustum
  21977. */
  21978. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21979. /**
  21980. * Renders the submesh
  21981. * @param enableAlphaMode defines if alpha needs to be used
  21982. * @returns the submesh
  21983. */
  21984. render(enableAlphaMode: boolean): SubMesh;
  21985. /**
  21986. * @hidden
  21987. */
  21988. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21989. /**
  21990. * Checks if the submesh intersects with a ray
  21991. * @param ray defines the ray to test
  21992. * @returns true is the passed ray intersects the submesh bounding box
  21993. */
  21994. canIntersects(ray: Ray): boolean;
  21995. /**
  21996. * Intersects current submesh with a ray
  21997. * @param ray defines the ray to test
  21998. * @param positions defines mesh's positions array
  21999. * @param indices defines mesh's indices array
  22000. * @param fastCheck defines if only bounding info should be used
  22001. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22002. * @returns intersection info or null if no intersection
  22003. */
  22004. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22005. /** @hidden */
  22006. private _intersectLines;
  22007. /** @hidden */
  22008. private _intersectUnIndexedLines;
  22009. /** @hidden */
  22010. private _intersectTriangles;
  22011. /** @hidden */
  22012. private _intersectUnIndexedTriangles;
  22013. /** @hidden */
  22014. _rebuild(): void;
  22015. /**
  22016. * Creates a new submesh from the passed mesh
  22017. * @param newMesh defines the new hosting mesh
  22018. * @param newRenderingMesh defines an optional rendering mesh
  22019. * @returns the new submesh
  22020. */
  22021. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22022. /**
  22023. * Release associated resources
  22024. */
  22025. dispose(): void;
  22026. /**
  22027. * Gets the class name
  22028. * @returns the string "SubMesh".
  22029. */
  22030. getClassName(): string;
  22031. /**
  22032. * Creates a new submesh from indices data
  22033. * @param materialIndex the index of the main mesh material
  22034. * @param startIndex the index where to start the copy in the mesh indices array
  22035. * @param indexCount the number of indices to copy then from the startIndex
  22036. * @param mesh the main mesh to create the submesh from
  22037. * @param renderingMesh the optional rendering mesh
  22038. * @returns a new submesh
  22039. */
  22040. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22041. }
  22042. }
  22043. declare module BABYLON {
  22044. /**
  22045. * Class used to represent data loading progression
  22046. */
  22047. export class SceneLoaderFlags {
  22048. private static _ForceFullSceneLoadingForIncremental;
  22049. private static _ShowLoadingScreen;
  22050. private static _CleanBoneMatrixWeights;
  22051. private static _loggingLevel;
  22052. /**
  22053. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22054. */
  22055. static get ForceFullSceneLoadingForIncremental(): boolean;
  22056. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22057. /**
  22058. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22059. */
  22060. static get ShowLoadingScreen(): boolean;
  22061. static set ShowLoadingScreen(value: boolean);
  22062. /**
  22063. * Defines the current logging level (while loading the scene)
  22064. * @ignorenaming
  22065. */
  22066. static get loggingLevel(): number;
  22067. static set loggingLevel(value: number);
  22068. /**
  22069. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22070. */
  22071. static get CleanBoneMatrixWeights(): boolean;
  22072. static set CleanBoneMatrixWeights(value: boolean);
  22073. }
  22074. }
  22075. declare module BABYLON {
  22076. /**
  22077. * Class used to store geometry data (vertex buffers + index buffer)
  22078. */
  22079. export class Geometry implements IGetSetVerticesData {
  22080. /**
  22081. * Gets or sets the ID of the geometry
  22082. */
  22083. id: string;
  22084. /**
  22085. * Gets or sets the unique ID of the geometry
  22086. */
  22087. uniqueId: number;
  22088. /**
  22089. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22090. */
  22091. delayLoadState: number;
  22092. /**
  22093. * Gets the file containing the data to load when running in delay load state
  22094. */
  22095. delayLoadingFile: Nullable<string>;
  22096. /**
  22097. * Callback called when the geometry is updated
  22098. */
  22099. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22100. private _scene;
  22101. private _engine;
  22102. private _meshes;
  22103. private _totalVertices;
  22104. /** @hidden */
  22105. _indices: IndicesArray;
  22106. /** @hidden */
  22107. _vertexBuffers: {
  22108. [key: string]: VertexBuffer;
  22109. };
  22110. private _isDisposed;
  22111. private _extend;
  22112. private _boundingBias;
  22113. /** @hidden */
  22114. _delayInfo: Array<string>;
  22115. private _indexBuffer;
  22116. private _indexBufferIsUpdatable;
  22117. /** @hidden */
  22118. _boundingInfo: Nullable<BoundingInfo>;
  22119. /** @hidden */
  22120. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22121. /** @hidden */
  22122. _softwareSkinningFrameId: number;
  22123. private _vertexArrayObjects;
  22124. private _updatable;
  22125. /** @hidden */
  22126. _positions: Nullable<Vector3[]>;
  22127. /**
  22128. * 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
  22129. */
  22130. get boundingBias(): Vector2;
  22131. /**
  22132. * 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
  22133. */
  22134. set boundingBias(value: Vector2);
  22135. /**
  22136. * Static function used to attach a new empty geometry to a mesh
  22137. * @param mesh defines the mesh to attach the geometry to
  22138. * @returns the new Geometry
  22139. */
  22140. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22141. /** Get the list of meshes using this geometry */
  22142. get meshes(): Mesh[];
  22143. /**
  22144. * Creates a new geometry
  22145. * @param id defines the unique ID
  22146. * @param scene defines the hosting scene
  22147. * @param vertexData defines the VertexData used to get geometry data
  22148. * @param updatable defines if geometry must be updatable (false by default)
  22149. * @param mesh defines the mesh that will be associated with the geometry
  22150. */
  22151. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22152. /**
  22153. * Gets the current extend of the geometry
  22154. */
  22155. get extend(): {
  22156. minimum: Vector3;
  22157. maximum: Vector3;
  22158. };
  22159. /**
  22160. * Gets the hosting scene
  22161. * @returns the hosting Scene
  22162. */
  22163. getScene(): Scene;
  22164. /**
  22165. * Gets the hosting engine
  22166. * @returns the hosting Engine
  22167. */
  22168. getEngine(): Engine;
  22169. /**
  22170. * Defines if the geometry is ready to use
  22171. * @returns true if the geometry is ready to be used
  22172. */
  22173. isReady(): boolean;
  22174. /**
  22175. * Gets a value indicating that the geometry should not be serialized
  22176. */
  22177. get doNotSerialize(): boolean;
  22178. /** @hidden */
  22179. _rebuild(): void;
  22180. /**
  22181. * Affects all geometry data in one call
  22182. * @param vertexData defines the geometry data
  22183. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22184. */
  22185. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22186. /**
  22187. * Set specific vertex data
  22188. * @param kind defines the data kind (Position, normal, etc...)
  22189. * @param data defines the vertex data to use
  22190. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22191. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22192. */
  22193. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22194. /**
  22195. * Removes a specific vertex data
  22196. * @param kind defines the data kind (Position, normal, etc...)
  22197. */
  22198. removeVerticesData(kind: string): void;
  22199. /**
  22200. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22201. * @param buffer defines the vertex buffer to use
  22202. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22203. */
  22204. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22205. /**
  22206. * Update a specific vertex buffer
  22207. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22208. * It will do nothing if the buffer is not updatable
  22209. * @param kind defines the data kind (Position, normal, etc...)
  22210. * @param data defines the data to use
  22211. * @param offset defines the offset in the target buffer where to store the data
  22212. * @param useBytes set to true if the offset is in bytes
  22213. */
  22214. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22215. /**
  22216. * Update a specific vertex buffer
  22217. * This function will create a new buffer if the current one is not updatable
  22218. * @param kind defines the data kind (Position, normal, etc...)
  22219. * @param data defines the data to use
  22220. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22221. */
  22222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22223. private _updateBoundingInfo;
  22224. /** @hidden */
  22225. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22226. /**
  22227. * Gets total number of vertices
  22228. * @returns the total number of vertices
  22229. */
  22230. getTotalVertices(): number;
  22231. /**
  22232. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22233. * @param kind defines the data kind (Position, normal, etc...)
  22234. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22235. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22236. * @returns a float array containing vertex data
  22237. */
  22238. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22239. /**
  22240. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22241. * @param kind defines the data kind (Position, normal, etc...)
  22242. * @returns true if the vertex buffer with the specified kind is updatable
  22243. */
  22244. isVertexBufferUpdatable(kind: string): boolean;
  22245. /**
  22246. * Gets a specific vertex buffer
  22247. * @param kind defines the data kind (Position, normal, etc...)
  22248. * @returns a VertexBuffer
  22249. */
  22250. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22251. /**
  22252. * Returns all vertex buffers
  22253. * @return an object holding all vertex buffers indexed by kind
  22254. */
  22255. getVertexBuffers(): Nullable<{
  22256. [key: string]: VertexBuffer;
  22257. }>;
  22258. /**
  22259. * Gets a boolean indicating if specific vertex buffer is present
  22260. * @param kind defines the data kind (Position, normal, etc...)
  22261. * @returns true if data is present
  22262. */
  22263. isVerticesDataPresent(kind: string): boolean;
  22264. /**
  22265. * Gets a list of all attached data kinds (Position, normal, etc...)
  22266. * @returns a list of string containing all kinds
  22267. */
  22268. getVerticesDataKinds(): string[];
  22269. /**
  22270. * Update index buffer
  22271. * @param indices defines the indices to store in the index buffer
  22272. * @param offset defines the offset in the target buffer where to store the data
  22273. * @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)
  22274. */
  22275. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22276. /**
  22277. * Creates a new index buffer
  22278. * @param indices defines the indices to store in the index buffer
  22279. * @param totalVertices defines the total number of vertices (could be null)
  22280. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22281. */
  22282. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22283. /**
  22284. * Return the total number of indices
  22285. * @returns the total number of indices
  22286. */
  22287. getTotalIndices(): number;
  22288. /**
  22289. * Gets the index buffer array
  22290. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22291. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22292. * @returns the index buffer array
  22293. */
  22294. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22295. /**
  22296. * Gets the index buffer
  22297. * @return the index buffer
  22298. */
  22299. getIndexBuffer(): Nullable<DataBuffer>;
  22300. /** @hidden */
  22301. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22302. /**
  22303. * Release the associated resources for a specific mesh
  22304. * @param mesh defines the source mesh
  22305. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22306. */
  22307. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22308. /**
  22309. * Apply current geometry to a given mesh
  22310. * @param mesh defines the mesh to apply geometry to
  22311. */
  22312. applyToMesh(mesh: Mesh): void;
  22313. private _updateExtend;
  22314. private _applyToMesh;
  22315. private notifyUpdate;
  22316. /**
  22317. * Load the geometry if it was flagged as delay loaded
  22318. * @param scene defines the hosting scene
  22319. * @param onLoaded defines a callback called when the geometry is loaded
  22320. */
  22321. load(scene: Scene, onLoaded?: () => void): void;
  22322. private _queueLoad;
  22323. /**
  22324. * Invert the geometry to move from a right handed system to a left handed one.
  22325. */
  22326. toLeftHanded(): void;
  22327. /** @hidden */
  22328. _resetPointsArrayCache(): void;
  22329. /** @hidden */
  22330. _generatePointsArray(): boolean;
  22331. /**
  22332. * Gets a value indicating if the geometry is disposed
  22333. * @returns true if the geometry was disposed
  22334. */
  22335. isDisposed(): boolean;
  22336. private _disposeVertexArrayObjects;
  22337. /**
  22338. * Free all associated resources
  22339. */
  22340. dispose(): void;
  22341. /**
  22342. * Clone the current geometry into a new geometry
  22343. * @param id defines the unique ID of the new geometry
  22344. * @returns a new geometry object
  22345. */
  22346. copy(id: string): Geometry;
  22347. /**
  22348. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22349. * @return a JSON representation of the current geometry data (without the vertices data)
  22350. */
  22351. serialize(): any;
  22352. private toNumberArray;
  22353. /**
  22354. * Serialize all vertices data into a JSON oject
  22355. * @returns a JSON representation of the current geometry data
  22356. */
  22357. serializeVerticeData(): any;
  22358. /**
  22359. * Extracts a clone of a mesh geometry
  22360. * @param mesh defines the source mesh
  22361. * @param id defines the unique ID of the new geometry object
  22362. * @returns the new geometry object
  22363. */
  22364. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22365. /**
  22366. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22367. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22368. * Be aware Math.random() could cause collisions, but:
  22369. * "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"
  22370. * @returns a string containing a new GUID
  22371. */
  22372. static RandomId(): string;
  22373. /** @hidden */
  22374. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22375. private static _CleanMatricesWeights;
  22376. /**
  22377. * Create a new geometry from persisted data (Using .babylon file format)
  22378. * @param parsedVertexData defines the persisted data
  22379. * @param scene defines the hosting scene
  22380. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22381. * @returns the new geometry object
  22382. */
  22383. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22384. }
  22385. }
  22386. declare module BABYLON {
  22387. /**
  22388. * Define an interface for all classes that will get and set the data on vertices
  22389. */
  22390. export interface IGetSetVerticesData {
  22391. /**
  22392. * Gets a boolean indicating if specific vertex data is present
  22393. * @param kind defines the vertex data kind to use
  22394. * @returns true is data kind is present
  22395. */
  22396. isVerticesDataPresent(kind: string): boolean;
  22397. /**
  22398. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22399. * @param kind defines the data kind (Position, normal, etc...)
  22400. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22401. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22402. * @returns a float array containing vertex data
  22403. */
  22404. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22405. /**
  22406. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22407. * @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.
  22408. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22409. * @returns the indices array or an empty array if the mesh has no geometry
  22410. */
  22411. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22412. /**
  22413. * Set specific vertex data
  22414. * @param kind defines the data kind (Position, normal, etc...)
  22415. * @param data defines the vertex data to use
  22416. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22417. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22418. */
  22419. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22420. /**
  22421. * Update a specific associated vertex buffer
  22422. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22423. * - VertexBuffer.PositionKind
  22424. * - VertexBuffer.UVKind
  22425. * - VertexBuffer.UV2Kind
  22426. * - VertexBuffer.UV3Kind
  22427. * - VertexBuffer.UV4Kind
  22428. * - VertexBuffer.UV5Kind
  22429. * - VertexBuffer.UV6Kind
  22430. * - VertexBuffer.ColorKind
  22431. * - VertexBuffer.MatricesIndicesKind
  22432. * - VertexBuffer.MatricesIndicesExtraKind
  22433. * - VertexBuffer.MatricesWeightsKind
  22434. * - VertexBuffer.MatricesWeightsExtraKind
  22435. * @param data defines the data source
  22436. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22437. * @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)
  22438. */
  22439. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22440. /**
  22441. * Creates a new index buffer
  22442. * @param indices defines the indices to store in the index buffer
  22443. * @param totalVertices defines the total number of vertices (could be null)
  22444. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22445. */
  22446. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22447. }
  22448. /**
  22449. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22450. */
  22451. export class VertexData {
  22452. /**
  22453. * Mesh side orientation : usually the external or front surface
  22454. */
  22455. static readonly FRONTSIDE: number;
  22456. /**
  22457. * Mesh side orientation : usually the internal or back surface
  22458. */
  22459. static readonly BACKSIDE: number;
  22460. /**
  22461. * Mesh side orientation : both internal and external or front and back surfaces
  22462. */
  22463. static readonly DOUBLESIDE: number;
  22464. /**
  22465. * Mesh side orientation : by default, `FRONTSIDE`
  22466. */
  22467. static readonly DEFAULTSIDE: number;
  22468. /**
  22469. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22470. */
  22471. positions: Nullable<FloatArray>;
  22472. /**
  22473. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22474. */
  22475. normals: Nullable<FloatArray>;
  22476. /**
  22477. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22478. */
  22479. tangents: Nullable<FloatArray>;
  22480. /**
  22481. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22482. */
  22483. uvs: Nullable<FloatArray>;
  22484. /**
  22485. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22486. */
  22487. uvs2: Nullable<FloatArray>;
  22488. /**
  22489. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22490. */
  22491. uvs3: Nullable<FloatArray>;
  22492. /**
  22493. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22494. */
  22495. uvs4: Nullable<FloatArray>;
  22496. /**
  22497. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22498. */
  22499. uvs5: Nullable<FloatArray>;
  22500. /**
  22501. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22502. */
  22503. uvs6: Nullable<FloatArray>;
  22504. /**
  22505. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22506. */
  22507. colors: Nullable<FloatArray>;
  22508. /**
  22509. * 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).
  22510. */
  22511. matricesIndices: Nullable<FloatArray>;
  22512. /**
  22513. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22514. */
  22515. matricesWeights: Nullable<FloatArray>;
  22516. /**
  22517. * An array extending the number of possible indices
  22518. */
  22519. matricesIndicesExtra: Nullable<FloatArray>;
  22520. /**
  22521. * An array extending the number of possible weights when the number of indices is extended
  22522. */
  22523. matricesWeightsExtra: Nullable<FloatArray>;
  22524. /**
  22525. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22526. */
  22527. indices: Nullable<IndicesArray>;
  22528. /**
  22529. * Uses the passed data array to set the set the values for the specified kind of data
  22530. * @param data a linear array of floating numbers
  22531. * @param kind the type of data that is being set, eg positions, colors etc
  22532. */
  22533. set(data: FloatArray, kind: string): void;
  22534. /**
  22535. * Associates the vertexData to the passed Mesh.
  22536. * Sets it as updatable or not (default `false`)
  22537. * @param mesh the mesh the vertexData is applied to
  22538. * @param updatable when used and having the value true allows new data to update the vertexData
  22539. * @returns the VertexData
  22540. */
  22541. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22542. /**
  22543. * Associates the vertexData to the passed Geometry.
  22544. * Sets it as updatable or not (default `false`)
  22545. * @param geometry the geometry the vertexData is applied to
  22546. * @param updatable when used and having the value true allows new data to update the vertexData
  22547. * @returns VertexData
  22548. */
  22549. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22550. /**
  22551. * Updates the associated mesh
  22552. * @param mesh the mesh to be updated
  22553. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22554. * @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
  22555. * @returns VertexData
  22556. */
  22557. updateMesh(mesh: Mesh): VertexData;
  22558. /**
  22559. * Updates the associated geometry
  22560. * @param geometry the geometry to be updated
  22561. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22562. * @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
  22563. * @returns VertexData.
  22564. */
  22565. updateGeometry(geometry: Geometry): VertexData;
  22566. private _applyTo;
  22567. private _update;
  22568. /**
  22569. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22570. * @param matrix the transforming matrix
  22571. * @returns the VertexData
  22572. */
  22573. transform(matrix: Matrix): VertexData;
  22574. /**
  22575. * Merges the passed VertexData into the current one
  22576. * @param other the VertexData to be merged into the current one
  22577. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22578. * @returns the modified VertexData
  22579. */
  22580. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22581. private _mergeElement;
  22582. private _validate;
  22583. /**
  22584. * Serializes the VertexData
  22585. * @returns a serialized object
  22586. */
  22587. serialize(): any;
  22588. /**
  22589. * Extracts the vertexData from a mesh
  22590. * @param mesh the mesh from which to extract the VertexData
  22591. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22592. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22593. * @returns the object VertexData associated to the passed mesh
  22594. */
  22595. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22596. /**
  22597. * Extracts the vertexData from the geometry
  22598. * @param geometry the geometry from which to extract the VertexData
  22599. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22600. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22601. * @returns the object VertexData associated to the passed mesh
  22602. */
  22603. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22604. private static _ExtractFrom;
  22605. /**
  22606. * Creates the VertexData for a Ribbon
  22607. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22608. * * pathArray array of paths, each of which an array of successive Vector3
  22609. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22610. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22611. * * 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
  22612. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22613. * * 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)
  22614. * * 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)
  22615. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22616. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22617. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22618. * @returns the VertexData of the ribbon
  22619. */
  22620. static CreateRibbon(options: {
  22621. pathArray: Vector3[][];
  22622. closeArray?: boolean;
  22623. closePath?: boolean;
  22624. offset?: number;
  22625. sideOrientation?: number;
  22626. frontUVs?: Vector4;
  22627. backUVs?: Vector4;
  22628. invertUV?: boolean;
  22629. uvs?: Vector2[];
  22630. colors?: Color4[];
  22631. }): VertexData;
  22632. /**
  22633. * Creates the VertexData for a box
  22634. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22635. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22636. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22637. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22638. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22639. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22640. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22641. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22642. * * 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)
  22643. * * 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)
  22644. * @returns the VertexData of the box
  22645. */
  22646. static CreateBox(options: {
  22647. size?: number;
  22648. width?: number;
  22649. height?: number;
  22650. depth?: number;
  22651. faceUV?: Vector4[];
  22652. faceColors?: Color4[];
  22653. sideOrientation?: number;
  22654. frontUVs?: Vector4;
  22655. backUVs?: Vector4;
  22656. }): VertexData;
  22657. /**
  22658. * Creates the VertexData for a tiled box
  22659. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22660. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22661. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22662. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22663. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22664. * @returns the VertexData of the box
  22665. */
  22666. static CreateTiledBox(options: {
  22667. pattern?: number;
  22668. width?: number;
  22669. height?: number;
  22670. depth?: number;
  22671. tileSize?: number;
  22672. tileWidth?: number;
  22673. tileHeight?: number;
  22674. alignHorizontal?: number;
  22675. alignVertical?: number;
  22676. faceUV?: Vector4[];
  22677. faceColors?: Color4[];
  22678. sideOrientation?: number;
  22679. }): VertexData;
  22680. /**
  22681. * Creates the VertexData for a tiled plane
  22682. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22683. * * pattern a limited pattern arrangement depending on the number
  22684. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22685. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22686. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22687. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22688. * * 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)
  22689. * * 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)
  22690. * @returns the VertexData of the tiled plane
  22691. */
  22692. static CreateTiledPlane(options: {
  22693. pattern?: number;
  22694. tileSize?: number;
  22695. tileWidth?: number;
  22696. tileHeight?: number;
  22697. size?: number;
  22698. width?: number;
  22699. height?: number;
  22700. alignHorizontal?: number;
  22701. alignVertical?: number;
  22702. sideOrientation?: number;
  22703. frontUVs?: Vector4;
  22704. backUVs?: Vector4;
  22705. }): VertexData;
  22706. /**
  22707. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22708. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22709. * * segments sets the number of horizontal strips optional, default 32
  22710. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22711. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22712. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22713. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22714. * * 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
  22715. * * 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
  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 ellipsoid
  22720. */
  22721. static CreateSphere(options: {
  22722. segments?: number;
  22723. diameter?: number;
  22724. diameterX?: number;
  22725. diameterY?: number;
  22726. diameterZ?: number;
  22727. arc?: number;
  22728. slice?: number;
  22729. sideOrientation?: number;
  22730. frontUVs?: Vector4;
  22731. backUVs?: Vector4;
  22732. }): VertexData;
  22733. /**
  22734. * Creates the VertexData for a cylinder, cone or prism
  22735. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22736. * * height sets the height (y direction) of the cylinder, optional, default 2
  22737. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22738. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22739. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22740. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22741. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22742. * * 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
  22743. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22744. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22745. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22746. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22748. * * 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)
  22749. * * 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)
  22750. * @returns the VertexData of the cylinder, cone or prism
  22751. */
  22752. static CreateCylinder(options: {
  22753. height?: number;
  22754. diameterTop?: number;
  22755. diameterBottom?: number;
  22756. diameter?: number;
  22757. tessellation?: number;
  22758. subdivisions?: number;
  22759. arc?: number;
  22760. faceColors?: Color4[];
  22761. faceUV?: Vector4[];
  22762. hasRings?: boolean;
  22763. enclose?: boolean;
  22764. sideOrientation?: number;
  22765. frontUVs?: Vector4;
  22766. backUVs?: Vector4;
  22767. }): VertexData;
  22768. /**
  22769. * Creates the VertexData for a torus
  22770. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22771. * * diameter the diameter of the torus, optional default 1
  22772. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22773. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22775. * * 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)
  22776. * * 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)
  22777. * @returns the VertexData of the torus
  22778. */
  22779. static CreateTorus(options: {
  22780. diameter?: number;
  22781. thickness?: number;
  22782. tessellation?: number;
  22783. sideOrientation?: number;
  22784. frontUVs?: Vector4;
  22785. backUVs?: Vector4;
  22786. }): VertexData;
  22787. /**
  22788. * Creates the VertexData of the LineSystem
  22789. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22790. * - lines an array of lines, each line being an array of successive Vector3
  22791. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22792. * @returns the VertexData of the LineSystem
  22793. */
  22794. static CreateLineSystem(options: {
  22795. lines: Vector3[][];
  22796. colors?: Nullable<Color4[][]>;
  22797. }): VertexData;
  22798. /**
  22799. * Create the VertexData for a DashedLines
  22800. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22801. * - points an array successive Vector3
  22802. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22803. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22804. * - dashNb the intended total number of dashes, optional, default 200
  22805. * @returns the VertexData for the DashedLines
  22806. */
  22807. static CreateDashedLines(options: {
  22808. points: Vector3[];
  22809. dashSize?: number;
  22810. gapSize?: number;
  22811. dashNb?: number;
  22812. }): VertexData;
  22813. /**
  22814. * Creates the VertexData for a Ground
  22815. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22816. * - width the width (x direction) of the ground, optional, default 1
  22817. * - height the height (z direction) of the ground, optional, default 1
  22818. * - subdivisions the number of subdivisions per side, optional, default 1
  22819. * @returns the VertexData of the Ground
  22820. */
  22821. static CreateGround(options: {
  22822. width?: number;
  22823. height?: number;
  22824. subdivisions?: number;
  22825. subdivisionsX?: number;
  22826. subdivisionsY?: number;
  22827. }): VertexData;
  22828. /**
  22829. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22830. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22831. * * xmin the ground minimum X coordinate, optional, default -1
  22832. * * zmin the ground minimum Z coordinate, optional, default -1
  22833. * * xmax the ground maximum X coordinate, optional, default 1
  22834. * * zmax the ground maximum Z coordinate, optional, default 1
  22835. * * 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}
  22836. * * 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}
  22837. * @returns the VertexData of the TiledGround
  22838. */
  22839. static CreateTiledGround(options: {
  22840. xmin: number;
  22841. zmin: number;
  22842. xmax: number;
  22843. zmax: number;
  22844. subdivisions?: {
  22845. w: number;
  22846. h: number;
  22847. };
  22848. precision?: {
  22849. w: number;
  22850. h: number;
  22851. };
  22852. }): VertexData;
  22853. /**
  22854. * Creates the VertexData of the Ground designed from a heightmap
  22855. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22856. * * width the width (x direction) of the ground
  22857. * * height the height (z direction) of the ground
  22858. * * subdivisions the number of subdivisions per side
  22859. * * minHeight the minimum altitude on the ground, optional, default 0
  22860. * * maxHeight the maximum altitude on the ground, optional default 1
  22861. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22862. * * buffer the array holding the image color data
  22863. * * bufferWidth the width of image
  22864. * * bufferHeight the height of image
  22865. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22866. * @returns the VertexData of the Ground designed from a heightmap
  22867. */
  22868. static CreateGroundFromHeightMap(options: {
  22869. width: number;
  22870. height: number;
  22871. subdivisions: number;
  22872. minHeight: number;
  22873. maxHeight: number;
  22874. colorFilter: Color3;
  22875. buffer: Uint8Array;
  22876. bufferWidth: number;
  22877. bufferHeight: number;
  22878. alphaFilter: number;
  22879. }): VertexData;
  22880. /**
  22881. * Creates the VertexData for a Plane
  22882. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22883. * * size sets the width and height of the plane to the value of size, optional default 1
  22884. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22885. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22886. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22887. * * 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)
  22888. * * 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)
  22889. * @returns the VertexData of the box
  22890. */
  22891. static CreatePlane(options: {
  22892. size?: number;
  22893. width?: number;
  22894. height?: number;
  22895. sideOrientation?: number;
  22896. frontUVs?: Vector4;
  22897. backUVs?: Vector4;
  22898. }): VertexData;
  22899. /**
  22900. * Creates the VertexData of the Disc or regular Polygon
  22901. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22902. * * radius the radius of the disc, optional default 0.5
  22903. * * tessellation the number of polygon sides, optional, default 64
  22904. * * 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
  22905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22906. * * 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)
  22907. * * 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)
  22908. * @returns the VertexData of the box
  22909. */
  22910. static CreateDisc(options: {
  22911. radius?: number;
  22912. tessellation?: number;
  22913. arc?: number;
  22914. sideOrientation?: number;
  22915. frontUVs?: Vector4;
  22916. backUVs?: Vector4;
  22917. }): VertexData;
  22918. /**
  22919. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22920. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22921. * @param polygon a mesh built from polygonTriangulation.build()
  22922. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22923. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22924. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22925. * @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)
  22926. * @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)
  22927. * @returns the VertexData of the Polygon
  22928. */
  22929. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22930. /**
  22931. * Creates the VertexData of the IcoSphere
  22932. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22933. * * radius the radius of the IcoSphere, optional default 1
  22934. * * radiusX allows stretching in the x direction, optional, default radius
  22935. * * radiusY allows stretching in the y direction, optional, default radius
  22936. * * radiusZ allows stretching in the z direction, optional, default radius
  22937. * * flat when true creates a flat shaded mesh, optional, default true
  22938. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22940. * * 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)
  22941. * * 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)
  22942. * @returns the VertexData of the IcoSphere
  22943. */
  22944. static CreateIcoSphere(options: {
  22945. radius?: number;
  22946. radiusX?: number;
  22947. radiusY?: number;
  22948. radiusZ?: number;
  22949. flat?: boolean;
  22950. subdivisions?: number;
  22951. sideOrientation?: number;
  22952. frontUVs?: Vector4;
  22953. backUVs?: Vector4;
  22954. }): VertexData;
  22955. /**
  22956. * Creates the VertexData for a Polyhedron
  22957. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22958. * * type provided types are:
  22959. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22960. * * 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)
  22961. * * size the size of the IcoSphere, optional default 1
  22962. * * sizeX allows stretching in the x direction, optional, default size
  22963. * * sizeY allows stretching in the y direction, optional, default size
  22964. * * sizeZ allows stretching in the z direction, optional, default size
  22965. * * 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
  22966. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22967. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22968. * * flat when true creates a flat shaded mesh, optional, default true
  22969. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22971. * * 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)
  22972. * * 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)
  22973. * @returns the VertexData of the Polyhedron
  22974. */
  22975. static CreatePolyhedron(options: {
  22976. type?: number;
  22977. size?: number;
  22978. sizeX?: number;
  22979. sizeY?: number;
  22980. sizeZ?: number;
  22981. custom?: any;
  22982. faceUV?: Vector4[];
  22983. faceColors?: Color4[];
  22984. flat?: boolean;
  22985. sideOrientation?: number;
  22986. frontUVs?: Vector4;
  22987. backUVs?: Vector4;
  22988. }): VertexData;
  22989. /**
  22990. * Creates the VertexData for a TorusKnot
  22991. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22992. * * radius the radius of the torus knot, optional, default 2
  22993. * * tube the thickness of the tube, optional, default 0.5
  22994. * * radialSegments the number of sides on each tube segments, optional, default 32
  22995. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22996. * * p the number of windings around the z axis, optional, default 2
  22997. * * q the number of windings around the x axis, optional, default 3
  22998. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22999. * * 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)
  23000. * * 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)
  23001. * @returns the VertexData of the Torus Knot
  23002. */
  23003. static CreateTorusKnot(options: {
  23004. radius?: number;
  23005. tube?: number;
  23006. radialSegments?: number;
  23007. tubularSegments?: number;
  23008. p?: number;
  23009. q?: number;
  23010. sideOrientation?: number;
  23011. frontUVs?: Vector4;
  23012. backUVs?: Vector4;
  23013. }): VertexData;
  23014. /**
  23015. * Compute normals for given positions and indices
  23016. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23017. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23018. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23019. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23020. * * facetNormals : optional array of facet normals (vector3)
  23021. * * facetPositions : optional array of facet positions (vector3)
  23022. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23023. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23024. * * bInfo : optional bounding info, required for facetPartitioning computation
  23025. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23026. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23027. * * useRightHandedSystem: optional boolean to for right handed system computation
  23028. * * depthSort : optional boolean to enable the facet depth sort computation
  23029. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23030. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23031. */
  23032. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23033. facetNormals?: any;
  23034. facetPositions?: any;
  23035. facetPartitioning?: any;
  23036. ratio?: number;
  23037. bInfo?: any;
  23038. bbSize?: Vector3;
  23039. subDiv?: any;
  23040. useRightHandedSystem?: boolean;
  23041. depthSort?: boolean;
  23042. distanceTo?: Vector3;
  23043. depthSortedFacets?: any;
  23044. }): void;
  23045. /** @hidden */
  23046. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23047. /**
  23048. * Applies VertexData created from the imported parameters to the geometry
  23049. * @param parsedVertexData the parsed data from an imported file
  23050. * @param geometry the geometry to apply the VertexData to
  23051. */
  23052. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23053. }
  23054. }
  23055. declare module BABYLON {
  23056. /**
  23057. * Defines a target to use with MorphTargetManager
  23058. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23059. */
  23060. export class MorphTarget implements IAnimatable {
  23061. /** defines the name of the target */
  23062. name: string;
  23063. /**
  23064. * Gets or sets the list of animations
  23065. */
  23066. animations: Animation[];
  23067. private _scene;
  23068. private _positions;
  23069. private _normals;
  23070. private _tangents;
  23071. private _uvs;
  23072. private _influence;
  23073. private _uniqueId;
  23074. /**
  23075. * Observable raised when the influence changes
  23076. */
  23077. onInfluenceChanged: Observable<boolean>;
  23078. /** @hidden */
  23079. _onDataLayoutChanged: Observable<void>;
  23080. /**
  23081. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23082. */
  23083. get influence(): number;
  23084. set influence(influence: number);
  23085. /**
  23086. * Gets or sets the id of the morph Target
  23087. */
  23088. id: string;
  23089. private _animationPropertiesOverride;
  23090. /**
  23091. * Gets or sets the animation properties override
  23092. */
  23093. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23094. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23095. /**
  23096. * Creates a new MorphTarget
  23097. * @param name defines the name of the target
  23098. * @param influence defines the influence to use
  23099. * @param scene defines the scene the morphtarget belongs to
  23100. */
  23101. constructor(
  23102. /** defines the name of the target */
  23103. name: string, influence?: number, scene?: Nullable<Scene>);
  23104. /**
  23105. * Gets the unique ID of this manager
  23106. */
  23107. get uniqueId(): number;
  23108. /**
  23109. * Gets a boolean defining if the target contains position data
  23110. */
  23111. get hasPositions(): boolean;
  23112. /**
  23113. * Gets a boolean defining if the target contains normal data
  23114. */
  23115. get hasNormals(): boolean;
  23116. /**
  23117. * Gets a boolean defining if the target contains tangent data
  23118. */
  23119. get hasTangents(): boolean;
  23120. /**
  23121. * Gets a boolean defining if the target contains texture coordinates data
  23122. */
  23123. get hasUVs(): boolean;
  23124. /**
  23125. * Affects position data to this target
  23126. * @param data defines the position data to use
  23127. */
  23128. setPositions(data: Nullable<FloatArray>): void;
  23129. /**
  23130. * Gets the position data stored in this target
  23131. * @returns a FloatArray containing the position data (or null if not present)
  23132. */
  23133. getPositions(): Nullable<FloatArray>;
  23134. /**
  23135. * Affects normal data to this target
  23136. * @param data defines the normal data to use
  23137. */
  23138. setNormals(data: Nullable<FloatArray>): void;
  23139. /**
  23140. * Gets the normal data stored in this target
  23141. * @returns a FloatArray containing the normal data (or null if not present)
  23142. */
  23143. getNormals(): Nullable<FloatArray>;
  23144. /**
  23145. * Affects tangent data to this target
  23146. * @param data defines the tangent data to use
  23147. */
  23148. setTangents(data: Nullable<FloatArray>): void;
  23149. /**
  23150. * Gets the tangent data stored in this target
  23151. * @returns a FloatArray containing the tangent data (or null if not present)
  23152. */
  23153. getTangents(): Nullable<FloatArray>;
  23154. /**
  23155. * Affects texture coordinates data to this target
  23156. * @param data defines the texture coordinates data to use
  23157. */
  23158. setUVs(data: Nullable<FloatArray>): void;
  23159. /**
  23160. * Gets the texture coordinates data stored in this target
  23161. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23162. */
  23163. getUVs(): Nullable<FloatArray>;
  23164. /**
  23165. * Clone the current target
  23166. * @returns a new MorphTarget
  23167. */
  23168. clone(): MorphTarget;
  23169. /**
  23170. * Serializes the current target into a Serialization object
  23171. * @returns the serialized object
  23172. */
  23173. serialize(): any;
  23174. /**
  23175. * Returns the string "MorphTarget"
  23176. * @returns "MorphTarget"
  23177. */
  23178. getClassName(): string;
  23179. /**
  23180. * Creates a new target from serialized data
  23181. * @param serializationObject defines the serialized data to use
  23182. * @returns a new MorphTarget
  23183. */
  23184. static Parse(serializationObject: any): MorphTarget;
  23185. /**
  23186. * Creates a MorphTarget from mesh data
  23187. * @param mesh defines the source mesh
  23188. * @param name defines the name to use for the new target
  23189. * @param influence defines the influence to attach to the target
  23190. * @returns a new MorphTarget
  23191. */
  23192. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23193. }
  23194. }
  23195. declare module BABYLON {
  23196. /**
  23197. * This class is used to deform meshes using morphing between different targets
  23198. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23199. */
  23200. export class MorphTargetManager {
  23201. private _targets;
  23202. private _targetInfluenceChangedObservers;
  23203. private _targetDataLayoutChangedObservers;
  23204. private _activeTargets;
  23205. private _scene;
  23206. private _influences;
  23207. private _supportsNormals;
  23208. private _supportsTangents;
  23209. private _supportsUVs;
  23210. private _vertexCount;
  23211. private _uniqueId;
  23212. private _tempInfluences;
  23213. /**
  23214. * Gets or sets a boolean indicating if normals must be morphed
  23215. */
  23216. enableNormalMorphing: boolean;
  23217. /**
  23218. * Gets or sets a boolean indicating if tangents must be morphed
  23219. */
  23220. enableTangentMorphing: boolean;
  23221. /**
  23222. * Gets or sets a boolean indicating if UV must be morphed
  23223. */
  23224. enableUVMorphing: boolean;
  23225. /**
  23226. * Creates a new MorphTargetManager
  23227. * @param scene defines the current scene
  23228. */
  23229. constructor(scene?: Nullable<Scene>);
  23230. /**
  23231. * Gets the unique ID of this manager
  23232. */
  23233. get uniqueId(): number;
  23234. /**
  23235. * Gets the number of vertices handled by this manager
  23236. */
  23237. get vertexCount(): number;
  23238. /**
  23239. * Gets a boolean indicating if this manager supports morphing of normals
  23240. */
  23241. get supportsNormals(): boolean;
  23242. /**
  23243. * Gets a boolean indicating if this manager supports morphing of tangents
  23244. */
  23245. get supportsTangents(): boolean;
  23246. /**
  23247. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23248. */
  23249. get supportsUVs(): boolean;
  23250. /**
  23251. * Gets the number of targets stored in this manager
  23252. */
  23253. get numTargets(): number;
  23254. /**
  23255. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23256. */
  23257. get numInfluencers(): number;
  23258. /**
  23259. * Gets the list of influences (one per target)
  23260. */
  23261. get influences(): Float32Array;
  23262. /**
  23263. * Gets the active target at specified index. An active target is a target with an influence > 0
  23264. * @param index defines the index to check
  23265. * @returns the requested target
  23266. */
  23267. getActiveTarget(index: number): MorphTarget;
  23268. /**
  23269. * Gets the target at specified index
  23270. * @param index defines the index to check
  23271. * @returns the requested target
  23272. */
  23273. getTarget(index: number): MorphTarget;
  23274. /**
  23275. * Add a new target to this manager
  23276. * @param target defines the target to add
  23277. */
  23278. addTarget(target: MorphTarget): void;
  23279. /**
  23280. * Removes a target from the manager
  23281. * @param target defines the target to remove
  23282. */
  23283. removeTarget(target: MorphTarget): void;
  23284. /**
  23285. * Clone the current manager
  23286. * @returns a new MorphTargetManager
  23287. */
  23288. clone(): MorphTargetManager;
  23289. /**
  23290. * Serializes the current manager into a Serialization object
  23291. * @returns the serialized object
  23292. */
  23293. serialize(): any;
  23294. private _syncActiveTargets;
  23295. /**
  23296. * Syncrhonize the targets with all the meshes using this morph target manager
  23297. */
  23298. synchronize(): void;
  23299. /**
  23300. * Creates a new MorphTargetManager from serialized data
  23301. * @param serializationObject defines the serialized data
  23302. * @param scene defines the hosting scene
  23303. * @returns the new MorphTargetManager
  23304. */
  23305. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23306. }
  23307. }
  23308. declare module BABYLON {
  23309. /**
  23310. * Class used to represent a specific level of detail of a mesh
  23311. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23312. */
  23313. export class MeshLODLevel {
  23314. /** Defines the distance where this level should start being displayed */
  23315. distance: number;
  23316. /** Defines the mesh to use to render this level */
  23317. mesh: Nullable<Mesh>;
  23318. /**
  23319. * Creates a new LOD level
  23320. * @param distance defines the distance where this level should star being displayed
  23321. * @param mesh defines the mesh to use to render this level
  23322. */
  23323. constructor(
  23324. /** Defines the distance where this level should start being displayed */
  23325. distance: number,
  23326. /** Defines the mesh to use to render this level */
  23327. mesh: Nullable<Mesh>);
  23328. }
  23329. }
  23330. declare module BABYLON {
  23331. /**
  23332. * Mesh representing the gorund
  23333. */
  23334. export class GroundMesh extends Mesh {
  23335. /** If octree should be generated */
  23336. generateOctree: boolean;
  23337. private _heightQuads;
  23338. /** @hidden */
  23339. _subdivisionsX: number;
  23340. /** @hidden */
  23341. _subdivisionsY: number;
  23342. /** @hidden */
  23343. _width: number;
  23344. /** @hidden */
  23345. _height: number;
  23346. /** @hidden */
  23347. _minX: number;
  23348. /** @hidden */
  23349. _maxX: number;
  23350. /** @hidden */
  23351. _minZ: number;
  23352. /** @hidden */
  23353. _maxZ: number;
  23354. constructor(name: string, scene: Scene);
  23355. /**
  23356. * "GroundMesh"
  23357. * @returns "GroundMesh"
  23358. */
  23359. getClassName(): string;
  23360. /**
  23361. * The minimum of x and y subdivisions
  23362. */
  23363. get subdivisions(): number;
  23364. /**
  23365. * X subdivisions
  23366. */
  23367. get subdivisionsX(): number;
  23368. /**
  23369. * Y subdivisions
  23370. */
  23371. get subdivisionsY(): number;
  23372. /**
  23373. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23374. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23375. * @param chunksCount the number of subdivisions for x and y
  23376. * @param octreeBlocksSize (Default: 32)
  23377. */
  23378. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23379. /**
  23380. * Returns a height (y) value in the Worl system :
  23381. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23382. * @param x x coordinate
  23383. * @param z z coordinate
  23384. * @returns the ground y position if (x, z) are outside the ground surface.
  23385. */
  23386. getHeightAtCoordinates(x: number, z: number): number;
  23387. /**
  23388. * Returns a normalized vector (Vector3) orthogonal to the ground
  23389. * at the ground coordinates (x, z) expressed in the World system.
  23390. * @param x x coordinate
  23391. * @param z z coordinate
  23392. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23393. */
  23394. getNormalAtCoordinates(x: number, z: number): Vector3;
  23395. /**
  23396. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23397. * at the ground coordinates (x, z) expressed in the World system.
  23398. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23399. * @param x x coordinate
  23400. * @param z z coordinate
  23401. * @param ref vector to store the result
  23402. * @returns the GroundMesh.
  23403. */
  23404. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23405. /**
  23406. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23407. * if the ground has been updated.
  23408. * This can be used in the render loop.
  23409. * @returns the GroundMesh.
  23410. */
  23411. updateCoordinateHeights(): GroundMesh;
  23412. private _getFacetAt;
  23413. private _initHeightQuads;
  23414. private _computeHeightQuads;
  23415. /**
  23416. * Serializes this ground mesh
  23417. * @param serializationObject object to write serialization to
  23418. */
  23419. serialize(serializationObject: any): void;
  23420. /**
  23421. * Parses a serialized ground mesh
  23422. * @param parsedMesh the serialized mesh
  23423. * @param scene the scene to create the ground mesh in
  23424. * @returns the created ground mesh
  23425. */
  23426. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23427. }
  23428. }
  23429. declare module BABYLON {
  23430. /**
  23431. * Interface for Physics-Joint data
  23432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23433. */
  23434. export interface PhysicsJointData {
  23435. /**
  23436. * The main pivot of the joint
  23437. */
  23438. mainPivot?: Vector3;
  23439. /**
  23440. * The connected pivot of the joint
  23441. */
  23442. connectedPivot?: Vector3;
  23443. /**
  23444. * The main axis of the joint
  23445. */
  23446. mainAxis?: Vector3;
  23447. /**
  23448. * The connected axis of the joint
  23449. */
  23450. connectedAxis?: Vector3;
  23451. /**
  23452. * The collision of the joint
  23453. */
  23454. collision?: boolean;
  23455. /**
  23456. * Native Oimo/Cannon/Energy data
  23457. */
  23458. nativeParams?: any;
  23459. }
  23460. /**
  23461. * This is a holder class for the physics joint created by the physics plugin
  23462. * It holds a set of functions to control the underlying joint
  23463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23464. */
  23465. export class PhysicsJoint {
  23466. /**
  23467. * The type of the physics joint
  23468. */
  23469. type: number;
  23470. /**
  23471. * The data for the physics joint
  23472. */
  23473. jointData: PhysicsJointData;
  23474. private _physicsJoint;
  23475. protected _physicsPlugin: IPhysicsEnginePlugin;
  23476. /**
  23477. * Initializes the physics joint
  23478. * @param type The type of the physics joint
  23479. * @param jointData The data for the physics joint
  23480. */
  23481. constructor(
  23482. /**
  23483. * The type of the physics joint
  23484. */
  23485. type: number,
  23486. /**
  23487. * The data for the physics joint
  23488. */
  23489. jointData: PhysicsJointData);
  23490. /**
  23491. * Gets the physics joint
  23492. */
  23493. get physicsJoint(): any;
  23494. /**
  23495. * Sets the physics joint
  23496. */
  23497. set physicsJoint(newJoint: any);
  23498. /**
  23499. * Sets the physics plugin
  23500. */
  23501. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23502. /**
  23503. * Execute a function that is physics-plugin specific.
  23504. * @param {Function} func the function that will be executed.
  23505. * It accepts two parameters: the physics world and the physics joint
  23506. */
  23507. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23508. /**
  23509. * Distance-Joint type
  23510. */
  23511. static DistanceJoint: number;
  23512. /**
  23513. * Hinge-Joint type
  23514. */
  23515. static HingeJoint: number;
  23516. /**
  23517. * Ball-and-Socket joint type
  23518. */
  23519. static BallAndSocketJoint: number;
  23520. /**
  23521. * Wheel-Joint type
  23522. */
  23523. static WheelJoint: number;
  23524. /**
  23525. * Slider-Joint type
  23526. */
  23527. static SliderJoint: number;
  23528. /**
  23529. * Prismatic-Joint type
  23530. */
  23531. static PrismaticJoint: number;
  23532. /**
  23533. * Universal-Joint type
  23534. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23535. */
  23536. static UniversalJoint: number;
  23537. /**
  23538. * Hinge-Joint 2 type
  23539. */
  23540. static Hinge2Joint: number;
  23541. /**
  23542. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23543. */
  23544. static PointToPointJoint: number;
  23545. /**
  23546. * Spring-Joint type
  23547. */
  23548. static SpringJoint: number;
  23549. /**
  23550. * Lock-Joint type
  23551. */
  23552. static LockJoint: number;
  23553. }
  23554. /**
  23555. * A class representing a physics distance joint
  23556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23557. */
  23558. export class DistanceJoint extends PhysicsJoint {
  23559. /**
  23560. *
  23561. * @param jointData The data for the Distance-Joint
  23562. */
  23563. constructor(jointData: DistanceJointData);
  23564. /**
  23565. * Update the predefined distance.
  23566. * @param maxDistance The maximum preferred distance
  23567. * @param minDistance The minimum preferred distance
  23568. */
  23569. updateDistance(maxDistance: number, minDistance?: number): void;
  23570. }
  23571. /**
  23572. * Represents a Motor-Enabled Joint
  23573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23574. */
  23575. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23576. /**
  23577. * Initializes the Motor-Enabled Joint
  23578. * @param type The type of the joint
  23579. * @param jointData The physica joint data for the joint
  23580. */
  23581. constructor(type: number, jointData: PhysicsJointData);
  23582. /**
  23583. * Set the motor values.
  23584. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23585. * @param force the force to apply
  23586. * @param maxForce max force for this motor.
  23587. */
  23588. setMotor(force?: number, maxForce?: number): void;
  23589. /**
  23590. * Set the motor's limits.
  23591. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23592. * @param upperLimit The upper limit of the motor
  23593. * @param lowerLimit The lower limit of the motor
  23594. */
  23595. setLimit(upperLimit: number, lowerLimit?: number): void;
  23596. }
  23597. /**
  23598. * This class represents a single physics Hinge-Joint
  23599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23600. */
  23601. export class HingeJoint extends MotorEnabledJoint {
  23602. /**
  23603. * Initializes the Hinge-Joint
  23604. * @param jointData The joint data for the Hinge-Joint
  23605. */
  23606. constructor(jointData: PhysicsJointData);
  23607. /**
  23608. * Set the motor values.
  23609. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23610. * @param {number} force the force to apply
  23611. * @param {number} maxForce max force for this motor.
  23612. */
  23613. setMotor(force?: number, maxForce?: number): void;
  23614. /**
  23615. * Set the motor's limits.
  23616. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23617. * @param upperLimit The upper limit of the motor
  23618. * @param lowerLimit The lower limit of the motor
  23619. */
  23620. setLimit(upperLimit: number, lowerLimit?: number): void;
  23621. }
  23622. /**
  23623. * This class represents a dual hinge physics joint (same as wheel joint)
  23624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23625. */
  23626. export class Hinge2Joint extends MotorEnabledJoint {
  23627. /**
  23628. * Initializes the Hinge2-Joint
  23629. * @param jointData The joint data for the Hinge2-Joint
  23630. */
  23631. constructor(jointData: PhysicsJointData);
  23632. /**
  23633. * Set the motor values.
  23634. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23635. * @param {number} targetSpeed the speed the motor is to reach
  23636. * @param {number} maxForce max force for this motor.
  23637. * @param {motorIndex} the motor's index, 0 or 1.
  23638. */
  23639. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23640. /**
  23641. * Set the motor limits.
  23642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23643. * @param {number} upperLimit the upper limit
  23644. * @param {number} lowerLimit lower limit
  23645. * @param {motorIndex} the motor's index, 0 or 1.
  23646. */
  23647. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23648. }
  23649. /**
  23650. * Interface for a motor enabled joint
  23651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23652. */
  23653. export interface IMotorEnabledJoint {
  23654. /**
  23655. * Physics joint
  23656. */
  23657. physicsJoint: any;
  23658. /**
  23659. * Sets the motor of the motor-enabled joint
  23660. * @param force The force of the motor
  23661. * @param maxForce The maximum force of the motor
  23662. * @param motorIndex The index of the motor
  23663. */
  23664. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23665. /**
  23666. * Sets the limit of the motor
  23667. * @param upperLimit The upper limit of the motor
  23668. * @param lowerLimit The lower limit of the motor
  23669. * @param motorIndex The index of the motor
  23670. */
  23671. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23672. }
  23673. /**
  23674. * Joint data for a Distance-Joint
  23675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23676. */
  23677. export interface DistanceJointData extends PhysicsJointData {
  23678. /**
  23679. * Max distance the 2 joint objects can be apart
  23680. */
  23681. maxDistance: number;
  23682. }
  23683. /**
  23684. * Joint data from a spring joint
  23685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23686. */
  23687. export interface SpringJointData extends PhysicsJointData {
  23688. /**
  23689. * Length of the spring
  23690. */
  23691. length: number;
  23692. /**
  23693. * Stiffness of the spring
  23694. */
  23695. stiffness: number;
  23696. /**
  23697. * Damping of the spring
  23698. */
  23699. damping: number;
  23700. /** this callback will be called when applying the force to the impostors. */
  23701. forceApplicationCallback: () => void;
  23702. }
  23703. }
  23704. declare module BABYLON {
  23705. /**
  23706. * Holds the data for the raycast result
  23707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23708. */
  23709. export class PhysicsRaycastResult {
  23710. private _hasHit;
  23711. private _hitDistance;
  23712. private _hitNormalWorld;
  23713. private _hitPointWorld;
  23714. private _rayFromWorld;
  23715. private _rayToWorld;
  23716. /**
  23717. * Gets if there was a hit
  23718. */
  23719. get hasHit(): boolean;
  23720. /**
  23721. * Gets the distance from the hit
  23722. */
  23723. get hitDistance(): number;
  23724. /**
  23725. * Gets the hit normal/direction in the world
  23726. */
  23727. get hitNormalWorld(): Vector3;
  23728. /**
  23729. * Gets the hit point in the world
  23730. */
  23731. get hitPointWorld(): Vector3;
  23732. /**
  23733. * Gets the ray "start point" of the ray in the world
  23734. */
  23735. get rayFromWorld(): Vector3;
  23736. /**
  23737. * Gets the ray "end point" of the ray in the world
  23738. */
  23739. get rayToWorld(): Vector3;
  23740. /**
  23741. * Sets the hit data (normal & point in world space)
  23742. * @param hitNormalWorld defines the normal in world space
  23743. * @param hitPointWorld defines the point in world space
  23744. */
  23745. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23746. /**
  23747. * Sets the distance from the start point to the hit point
  23748. * @param distance
  23749. */
  23750. setHitDistance(distance: number): void;
  23751. /**
  23752. * Calculates the distance manually
  23753. */
  23754. calculateHitDistance(): void;
  23755. /**
  23756. * Resets all the values to default
  23757. * @param from The from point on world space
  23758. * @param to The to point on world space
  23759. */
  23760. reset(from?: Vector3, to?: Vector3): void;
  23761. }
  23762. /**
  23763. * Interface for the size containing width and height
  23764. */
  23765. interface IXYZ {
  23766. /**
  23767. * X
  23768. */
  23769. x: number;
  23770. /**
  23771. * Y
  23772. */
  23773. y: number;
  23774. /**
  23775. * Z
  23776. */
  23777. z: number;
  23778. }
  23779. }
  23780. declare module BABYLON {
  23781. /**
  23782. * Interface used to describe a physics joint
  23783. */
  23784. export interface PhysicsImpostorJoint {
  23785. /** Defines the main impostor to which the joint is linked */
  23786. mainImpostor: PhysicsImpostor;
  23787. /** Defines the impostor that is connected to the main impostor using this joint */
  23788. connectedImpostor: PhysicsImpostor;
  23789. /** Defines the joint itself */
  23790. joint: PhysicsJoint;
  23791. }
  23792. /** @hidden */
  23793. export interface IPhysicsEnginePlugin {
  23794. world: any;
  23795. name: string;
  23796. setGravity(gravity: Vector3): void;
  23797. setTimeStep(timeStep: number): void;
  23798. getTimeStep(): number;
  23799. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23800. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23801. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23802. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23803. removePhysicsBody(impostor: PhysicsImpostor): void;
  23804. generateJoint(joint: PhysicsImpostorJoint): void;
  23805. removeJoint(joint: PhysicsImpostorJoint): void;
  23806. isSupported(): boolean;
  23807. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23808. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23809. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23810. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23811. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23812. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23813. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23814. getBodyMass(impostor: PhysicsImpostor): number;
  23815. getBodyFriction(impostor: PhysicsImpostor): number;
  23816. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23817. getBodyRestitution(impostor: PhysicsImpostor): number;
  23818. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23819. getBodyPressure?(impostor: PhysicsImpostor): number;
  23820. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23821. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23822. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23823. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23824. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23825. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23826. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23827. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23828. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23829. sleepBody(impostor: PhysicsImpostor): void;
  23830. wakeUpBody(impostor: PhysicsImpostor): void;
  23831. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23832. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23833. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23834. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23835. getRadius(impostor: PhysicsImpostor): number;
  23836. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23837. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23838. dispose(): void;
  23839. }
  23840. /**
  23841. * Interface used to define a physics engine
  23842. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23843. */
  23844. export interface IPhysicsEngine {
  23845. /**
  23846. * Gets the gravity vector used by the simulation
  23847. */
  23848. gravity: Vector3;
  23849. /**
  23850. * Sets the gravity vector used by the simulation
  23851. * @param gravity defines the gravity vector to use
  23852. */
  23853. setGravity(gravity: Vector3): void;
  23854. /**
  23855. * Set the time step of the physics engine.
  23856. * Default is 1/60.
  23857. * To slow it down, enter 1/600 for example.
  23858. * To speed it up, 1/30
  23859. * @param newTimeStep the new timestep to apply to this world.
  23860. */
  23861. setTimeStep(newTimeStep: number): void;
  23862. /**
  23863. * Get the time step of the physics engine.
  23864. * @returns the current time step
  23865. */
  23866. getTimeStep(): number;
  23867. /**
  23868. * Set the sub time step of the physics engine.
  23869. * Default is 0 meaning there is no sub steps
  23870. * To increase physics resolution precision, set a small value (like 1 ms)
  23871. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23872. */
  23873. setSubTimeStep(subTimeStep: number): void;
  23874. /**
  23875. * Get the sub time step of the physics engine.
  23876. * @returns the current sub time step
  23877. */
  23878. getSubTimeStep(): number;
  23879. /**
  23880. * Release all resources
  23881. */
  23882. dispose(): void;
  23883. /**
  23884. * Gets the name of the current physics plugin
  23885. * @returns the name of the plugin
  23886. */
  23887. getPhysicsPluginName(): string;
  23888. /**
  23889. * Adding a new impostor for the impostor tracking.
  23890. * This will be done by the impostor itself.
  23891. * @param impostor the impostor to add
  23892. */
  23893. addImpostor(impostor: PhysicsImpostor): void;
  23894. /**
  23895. * Remove an impostor from the engine.
  23896. * This impostor and its mesh will not longer be updated by the physics engine.
  23897. * @param impostor the impostor to remove
  23898. */
  23899. removeImpostor(impostor: PhysicsImpostor): void;
  23900. /**
  23901. * Add a joint to the physics engine
  23902. * @param mainImpostor defines the main impostor to which the joint is added.
  23903. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23904. * @param joint defines the joint that will connect both impostors.
  23905. */
  23906. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23907. /**
  23908. * Removes a joint from the simulation
  23909. * @param mainImpostor defines the impostor used with the joint
  23910. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23911. * @param joint defines the joint to remove
  23912. */
  23913. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23914. /**
  23915. * Gets the current plugin used to run the simulation
  23916. * @returns current plugin
  23917. */
  23918. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23919. /**
  23920. * Gets the list of physic impostors
  23921. * @returns an array of PhysicsImpostor
  23922. */
  23923. getImpostors(): Array<PhysicsImpostor>;
  23924. /**
  23925. * Gets the impostor for a physics enabled object
  23926. * @param object defines the object impersonated by the impostor
  23927. * @returns the PhysicsImpostor or null if not found
  23928. */
  23929. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23930. /**
  23931. * Gets the impostor for a physics body object
  23932. * @param body defines physics body used by the impostor
  23933. * @returns the PhysicsImpostor or null if not found
  23934. */
  23935. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23936. /**
  23937. * Does a raycast in the physics world
  23938. * @param from when should the ray start?
  23939. * @param to when should the ray end?
  23940. * @returns PhysicsRaycastResult
  23941. */
  23942. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23943. /**
  23944. * Called by the scene. No need to call it.
  23945. * @param delta defines the timespam between frames
  23946. */
  23947. _step(delta: number): void;
  23948. }
  23949. }
  23950. declare module BABYLON {
  23951. /**
  23952. * The interface for the physics imposter parameters
  23953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23954. */
  23955. export interface PhysicsImpostorParameters {
  23956. /**
  23957. * The mass of the physics imposter
  23958. */
  23959. mass: number;
  23960. /**
  23961. * The friction of the physics imposter
  23962. */
  23963. friction?: number;
  23964. /**
  23965. * The coefficient of restitution of the physics imposter
  23966. */
  23967. restitution?: number;
  23968. /**
  23969. * The native options of the physics imposter
  23970. */
  23971. nativeOptions?: any;
  23972. /**
  23973. * Specifies if the parent should be ignored
  23974. */
  23975. ignoreParent?: boolean;
  23976. /**
  23977. * Specifies if bi-directional transformations should be disabled
  23978. */
  23979. disableBidirectionalTransformation?: boolean;
  23980. /**
  23981. * The pressure inside the physics imposter, soft object only
  23982. */
  23983. pressure?: number;
  23984. /**
  23985. * The stiffness the physics imposter, soft object only
  23986. */
  23987. stiffness?: number;
  23988. /**
  23989. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23990. */
  23991. velocityIterations?: number;
  23992. /**
  23993. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23994. */
  23995. positionIterations?: number;
  23996. /**
  23997. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23998. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23999. * Add to fix multiple points
  24000. */
  24001. fixedPoints?: number;
  24002. /**
  24003. * The collision margin around a soft object
  24004. */
  24005. margin?: number;
  24006. /**
  24007. * The collision margin around a soft object
  24008. */
  24009. damping?: number;
  24010. /**
  24011. * The path for a rope based on an extrusion
  24012. */
  24013. path?: any;
  24014. /**
  24015. * The shape of an extrusion used for a rope based on an extrusion
  24016. */
  24017. shape?: any;
  24018. }
  24019. /**
  24020. * Interface for a physics-enabled object
  24021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24022. */
  24023. export interface IPhysicsEnabledObject {
  24024. /**
  24025. * The position of the physics-enabled object
  24026. */
  24027. position: Vector3;
  24028. /**
  24029. * The rotation of the physics-enabled object
  24030. */
  24031. rotationQuaternion: Nullable<Quaternion>;
  24032. /**
  24033. * The scale of the physics-enabled object
  24034. */
  24035. scaling: Vector3;
  24036. /**
  24037. * The rotation of the physics-enabled object
  24038. */
  24039. rotation?: Vector3;
  24040. /**
  24041. * The parent of the physics-enabled object
  24042. */
  24043. parent?: any;
  24044. /**
  24045. * The bounding info of the physics-enabled object
  24046. * @returns The bounding info of the physics-enabled object
  24047. */
  24048. getBoundingInfo(): BoundingInfo;
  24049. /**
  24050. * Computes the world matrix
  24051. * @param force Specifies if the world matrix should be computed by force
  24052. * @returns A world matrix
  24053. */
  24054. computeWorldMatrix(force: boolean): Matrix;
  24055. /**
  24056. * Gets the world matrix
  24057. * @returns A world matrix
  24058. */
  24059. getWorldMatrix?(): Matrix;
  24060. /**
  24061. * Gets the child meshes
  24062. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24063. * @returns An array of abstract meshes
  24064. */
  24065. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24066. /**
  24067. * Gets the vertex data
  24068. * @param kind The type of vertex data
  24069. * @returns A nullable array of numbers, or a float32 array
  24070. */
  24071. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24072. /**
  24073. * Gets the indices from the mesh
  24074. * @returns A nullable array of index arrays
  24075. */
  24076. getIndices?(): Nullable<IndicesArray>;
  24077. /**
  24078. * Gets the scene from the mesh
  24079. * @returns the indices array or null
  24080. */
  24081. getScene?(): Scene;
  24082. /**
  24083. * Gets the absolute position from the mesh
  24084. * @returns the absolute position
  24085. */
  24086. getAbsolutePosition(): Vector3;
  24087. /**
  24088. * Gets the absolute pivot point from the mesh
  24089. * @returns the absolute pivot point
  24090. */
  24091. getAbsolutePivotPoint(): Vector3;
  24092. /**
  24093. * Rotates the mesh
  24094. * @param axis The axis of rotation
  24095. * @param amount The amount of rotation
  24096. * @param space The space of the rotation
  24097. * @returns The rotation transform node
  24098. */
  24099. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24100. /**
  24101. * Translates the mesh
  24102. * @param axis The axis of translation
  24103. * @param distance The distance of translation
  24104. * @param space The space of the translation
  24105. * @returns The transform node
  24106. */
  24107. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24108. /**
  24109. * Sets the absolute position of the mesh
  24110. * @param absolutePosition The absolute position of the mesh
  24111. * @returns The transform node
  24112. */
  24113. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24114. /**
  24115. * Gets the class name of the mesh
  24116. * @returns The class name
  24117. */
  24118. getClassName(): string;
  24119. }
  24120. /**
  24121. * Represents a physics imposter
  24122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24123. */
  24124. export class PhysicsImpostor {
  24125. /**
  24126. * The physics-enabled object used as the physics imposter
  24127. */
  24128. object: IPhysicsEnabledObject;
  24129. /**
  24130. * The type of the physics imposter
  24131. */
  24132. type: number;
  24133. private _options;
  24134. private _scene?;
  24135. /**
  24136. * The default object size of the imposter
  24137. */
  24138. static DEFAULT_OBJECT_SIZE: Vector3;
  24139. /**
  24140. * The identity quaternion of the imposter
  24141. */
  24142. static IDENTITY_QUATERNION: Quaternion;
  24143. /** @hidden */
  24144. _pluginData: any;
  24145. private _physicsEngine;
  24146. private _physicsBody;
  24147. private _bodyUpdateRequired;
  24148. private _onBeforePhysicsStepCallbacks;
  24149. private _onAfterPhysicsStepCallbacks;
  24150. /** @hidden */
  24151. _onPhysicsCollideCallbacks: Array<{
  24152. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24153. otherImpostors: Array<PhysicsImpostor>;
  24154. }>;
  24155. private _deltaPosition;
  24156. private _deltaRotation;
  24157. private _deltaRotationConjugated;
  24158. /** @hidden */
  24159. _isFromLine: boolean;
  24160. private _parent;
  24161. private _isDisposed;
  24162. private static _tmpVecs;
  24163. private static _tmpQuat;
  24164. /**
  24165. * Specifies if the physics imposter is disposed
  24166. */
  24167. get isDisposed(): boolean;
  24168. /**
  24169. * Gets the mass of the physics imposter
  24170. */
  24171. get mass(): number;
  24172. set mass(value: number);
  24173. /**
  24174. * Gets the coefficient of friction
  24175. */
  24176. get friction(): number;
  24177. /**
  24178. * Sets the coefficient of friction
  24179. */
  24180. set friction(value: number);
  24181. /**
  24182. * Gets the coefficient of restitution
  24183. */
  24184. get restitution(): number;
  24185. /**
  24186. * Sets the coefficient of restitution
  24187. */
  24188. set restitution(value: number);
  24189. /**
  24190. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24191. */
  24192. get pressure(): number;
  24193. /**
  24194. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24195. */
  24196. set pressure(value: number);
  24197. /**
  24198. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24199. */
  24200. get stiffness(): number;
  24201. /**
  24202. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24203. */
  24204. set stiffness(value: number);
  24205. /**
  24206. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24207. */
  24208. get velocityIterations(): number;
  24209. /**
  24210. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24211. */
  24212. set velocityIterations(value: number);
  24213. /**
  24214. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24215. */
  24216. get positionIterations(): number;
  24217. /**
  24218. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24219. */
  24220. set positionIterations(value: number);
  24221. /**
  24222. * The unique id of the physics imposter
  24223. * set by the physics engine when adding this impostor to the array
  24224. */
  24225. uniqueId: number;
  24226. /**
  24227. * @hidden
  24228. */
  24229. soft: boolean;
  24230. /**
  24231. * @hidden
  24232. */
  24233. segments: number;
  24234. private _joints;
  24235. /**
  24236. * Initializes the physics imposter
  24237. * @param object The physics-enabled object used as the physics imposter
  24238. * @param type The type of the physics imposter
  24239. * @param _options The options for the physics imposter
  24240. * @param _scene The Babylon scene
  24241. */
  24242. constructor(
  24243. /**
  24244. * The physics-enabled object used as the physics imposter
  24245. */
  24246. object: IPhysicsEnabledObject,
  24247. /**
  24248. * The type of the physics imposter
  24249. */
  24250. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24251. /**
  24252. * This function will completly initialize this impostor.
  24253. * It will create a new body - but only if this mesh has no parent.
  24254. * If it has, this impostor will not be used other than to define the impostor
  24255. * of the child mesh.
  24256. * @hidden
  24257. */
  24258. _init(): void;
  24259. private _getPhysicsParent;
  24260. /**
  24261. * Should a new body be generated.
  24262. * @returns boolean specifying if body initialization is required
  24263. */
  24264. isBodyInitRequired(): boolean;
  24265. /**
  24266. * Sets the updated scaling
  24267. * @param updated Specifies if the scaling is updated
  24268. */
  24269. setScalingUpdated(): void;
  24270. /**
  24271. * Force a regeneration of this or the parent's impostor's body.
  24272. * Use under cautious - This will remove all joints already implemented.
  24273. */
  24274. forceUpdate(): void;
  24275. /**
  24276. * Gets the body that holds this impostor. Either its own, or its parent.
  24277. */
  24278. get physicsBody(): any;
  24279. /**
  24280. * Get the parent of the physics imposter
  24281. * @returns Physics imposter or null
  24282. */
  24283. get parent(): Nullable<PhysicsImpostor>;
  24284. /**
  24285. * Sets the parent of the physics imposter
  24286. */
  24287. set parent(value: Nullable<PhysicsImpostor>);
  24288. /**
  24289. * Set the physics body. Used mainly by the physics engine/plugin
  24290. */
  24291. set physicsBody(physicsBody: any);
  24292. /**
  24293. * Resets the update flags
  24294. */
  24295. resetUpdateFlags(): void;
  24296. /**
  24297. * Gets the object extend size
  24298. * @returns the object extend size
  24299. */
  24300. getObjectExtendSize(): Vector3;
  24301. /**
  24302. * Gets the object center
  24303. * @returns The object center
  24304. */
  24305. getObjectCenter(): Vector3;
  24306. /**
  24307. * Get a specific parameter from the options parameters
  24308. * @param paramName The object parameter name
  24309. * @returns The object parameter
  24310. */
  24311. getParam(paramName: string): any;
  24312. /**
  24313. * Sets a specific parameter in the options given to the physics plugin
  24314. * @param paramName The parameter name
  24315. * @param value The value of the parameter
  24316. */
  24317. setParam(paramName: string, value: number): void;
  24318. /**
  24319. * Specifically change the body's mass option. Won't recreate the physics body object
  24320. * @param mass The mass of the physics imposter
  24321. */
  24322. setMass(mass: number): void;
  24323. /**
  24324. * Gets the linear velocity
  24325. * @returns linear velocity or null
  24326. */
  24327. getLinearVelocity(): Nullable<Vector3>;
  24328. /**
  24329. * Sets the linear velocity
  24330. * @param velocity linear velocity or null
  24331. */
  24332. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24333. /**
  24334. * Gets the angular velocity
  24335. * @returns angular velocity or null
  24336. */
  24337. getAngularVelocity(): Nullable<Vector3>;
  24338. /**
  24339. * Sets the angular velocity
  24340. * @param velocity The velocity or null
  24341. */
  24342. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24343. /**
  24344. * Execute a function with the physics plugin native code
  24345. * Provide a function the will have two variables - the world object and the physics body object
  24346. * @param func The function to execute with the physics plugin native code
  24347. */
  24348. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24349. /**
  24350. * Register a function that will be executed before the physics world is stepping forward
  24351. * @param func The function to execute before the physics world is stepped forward
  24352. */
  24353. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24354. /**
  24355. * Unregister a function that will be executed before the physics world is stepping forward
  24356. * @param func The function to execute before the physics world is stepped forward
  24357. */
  24358. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24359. /**
  24360. * Register a function that will be executed after the physics step
  24361. * @param func The function to execute after physics step
  24362. */
  24363. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24364. /**
  24365. * Unregisters a function that will be executed after the physics step
  24366. * @param func The function to execute after physics step
  24367. */
  24368. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24369. /**
  24370. * register a function that will be executed when this impostor collides against a different body
  24371. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24372. * @param func Callback that is executed on collision
  24373. */
  24374. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24375. /**
  24376. * Unregisters the physics imposter on contact
  24377. * @param collideAgainst The physics object to collide against
  24378. * @param func Callback to execute on collision
  24379. */
  24380. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24381. private _tmpQuat;
  24382. private _tmpQuat2;
  24383. /**
  24384. * Get the parent rotation
  24385. * @returns The parent rotation
  24386. */
  24387. getParentsRotation(): Quaternion;
  24388. /**
  24389. * this function is executed by the physics engine.
  24390. */
  24391. beforeStep: () => void;
  24392. /**
  24393. * this function is executed by the physics engine
  24394. */
  24395. afterStep: () => void;
  24396. /**
  24397. * Legacy collision detection event support
  24398. */
  24399. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24400. /**
  24401. * event and body object due to cannon's event-based architecture.
  24402. */
  24403. onCollide: (e: {
  24404. body: any;
  24405. }) => void;
  24406. /**
  24407. * Apply a force
  24408. * @param force The force to apply
  24409. * @param contactPoint The contact point for the force
  24410. * @returns The physics imposter
  24411. */
  24412. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24413. /**
  24414. * Apply an impulse
  24415. * @param force The impulse force
  24416. * @param contactPoint The contact point for the impulse force
  24417. * @returns The physics imposter
  24418. */
  24419. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24420. /**
  24421. * A help function to create a joint
  24422. * @param otherImpostor A physics imposter used to create a joint
  24423. * @param jointType The type of joint
  24424. * @param jointData The data for the joint
  24425. * @returns The physics imposter
  24426. */
  24427. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24428. /**
  24429. * Add a joint to this impostor with a different impostor
  24430. * @param otherImpostor A physics imposter used to add a joint
  24431. * @param joint The joint to add
  24432. * @returns The physics imposter
  24433. */
  24434. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24435. /**
  24436. * Add an anchor to a cloth impostor
  24437. * @param otherImpostor rigid impostor to anchor to
  24438. * @param width ratio across width from 0 to 1
  24439. * @param height ratio up height from 0 to 1
  24440. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24441. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24442. * @returns impostor the soft imposter
  24443. */
  24444. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24445. /**
  24446. * Add a hook to a rope impostor
  24447. * @param otherImpostor rigid impostor to anchor to
  24448. * @param length ratio across rope from 0 to 1
  24449. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24450. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24451. * @returns impostor the rope imposter
  24452. */
  24453. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24454. /**
  24455. * Will keep this body still, in a sleep mode.
  24456. * @returns the physics imposter
  24457. */
  24458. sleep(): PhysicsImpostor;
  24459. /**
  24460. * Wake the body up.
  24461. * @returns The physics imposter
  24462. */
  24463. wakeUp(): PhysicsImpostor;
  24464. /**
  24465. * Clones the physics imposter
  24466. * @param newObject The physics imposter clones to this physics-enabled object
  24467. * @returns A nullable physics imposter
  24468. */
  24469. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24470. /**
  24471. * Disposes the physics imposter
  24472. */
  24473. dispose(): void;
  24474. /**
  24475. * Sets the delta position
  24476. * @param position The delta position amount
  24477. */
  24478. setDeltaPosition(position: Vector3): void;
  24479. /**
  24480. * Sets the delta rotation
  24481. * @param rotation The delta rotation amount
  24482. */
  24483. setDeltaRotation(rotation: Quaternion): void;
  24484. /**
  24485. * Gets the box size of the physics imposter and stores the result in the input parameter
  24486. * @param result Stores the box size
  24487. * @returns The physics imposter
  24488. */
  24489. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24490. /**
  24491. * Gets the radius of the physics imposter
  24492. * @returns Radius of the physics imposter
  24493. */
  24494. getRadius(): number;
  24495. /**
  24496. * Sync a bone with this impostor
  24497. * @param bone The bone to sync to the impostor.
  24498. * @param boneMesh The mesh that the bone is influencing.
  24499. * @param jointPivot The pivot of the joint / bone in local space.
  24500. * @param distToJoint Optional distance from the impostor to the joint.
  24501. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24502. */
  24503. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24504. /**
  24505. * Sync impostor to a bone
  24506. * @param bone The bone that the impostor will be synced to.
  24507. * @param boneMesh The mesh that the bone is influencing.
  24508. * @param jointPivot The pivot of the joint / bone in local space.
  24509. * @param distToJoint Optional distance from the impostor to the joint.
  24510. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24511. * @param boneAxis Optional vector3 axis the bone is aligned with
  24512. */
  24513. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24514. /**
  24515. * No-Imposter type
  24516. */
  24517. static NoImpostor: number;
  24518. /**
  24519. * Sphere-Imposter type
  24520. */
  24521. static SphereImpostor: number;
  24522. /**
  24523. * Box-Imposter type
  24524. */
  24525. static BoxImpostor: number;
  24526. /**
  24527. * Plane-Imposter type
  24528. */
  24529. static PlaneImpostor: number;
  24530. /**
  24531. * Mesh-imposter type
  24532. */
  24533. static MeshImpostor: number;
  24534. /**
  24535. * Capsule-Impostor type (Ammo.js plugin only)
  24536. */
  24537. static CapsuleImpostor: number;
  24538. /**
  24539. * Cylinder-Imposter type
  24540. */
  24541. static CylinderImpostor: number;
  24542. /**
  24543. * Particle-Imposter type
  24544. */
  24545. static ParticleImpostor: number;
  24546. /**
  24547. * Heightmap-Imposter type
  24548. */
  24549. static HeightmapImpostor: number;
  24550. /**
  24551. * ConvexHull-Impostor type (Ammo.js plugin only)
  24552. */
  24553. static ConvexHullImpostor: number;
  24554. /**
  24555. * Custom-Imposter type (Ammo.js plugin only)
  24556. */
  24557. static CustomImpostor: number;
  24558. /**
  24559. * Rope-Imposter type
  24560. */
  24561. static RopeImpostor: number;
  24562. /**
  24563. * Cloth-Imposter type
  24564. */
  24565. static ClothImpostor: number;
  24566. /**
  24567. * Softbody-Imposter type
  24568. */
  24569. static SoftbodyImpostor: number;
  24570. }
  24571. }
  24572. declare module BABYLON {
  24573. /**
  24574. * @hidden
  24575. **/
  24576. export class _CreationDataStorage {
  24577. closePath?: boolean;
  24578. closeArray?: boolean;
  24579. idx: number[];
  24580. dashSize: number;
  24581. gapSize: number;
  24582. path3D: Path3D;
  24583. pathArray: Vector3[][];
  24584. arc: number;
  24585. radius: number;
  24586. cap: number;
  24587. tessellation: number;
  24588. }
  24589. /**
  24590. * @hidden
  24591. **/
  24592. class _InstanceDataStorage {
  24593. visibleInstances: any;
  24594. batchCache: _InstancesBatch;
  24595. instancesBufferSize: number;
  24596. instancesBuffer: Nullable<Buffer>;
  24597. instancesData: Float32Array;
  24598. overridenInstanceCount: number;
  24599. isFrozen: boolean;
  24600. previousBatch: Nullable<_InstancesBatch>;
  24601. hardwareInstancedRendering: boolean;
  24602. sideOrientation: number;
  24603. manualUpdate: boolean;
  24604. }
  24605. /**
  24606. * @hidden
  24607. **/
  24608. export class _InstancesBatch {
  24609. mustReturn: boolean;
  24610. visibleInstances: Nullable<InstancedMesh[]>[];
  24611. renderSelf: boolean[];
  24612. hardwareInstancedRendering: boolean[];
  24613. }
  24614. /**
  24615. * Class used to represent renderable models
  24616. */
  24617. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24618. /**
  24619. * Mesh side orientation : usually the external or front surface
  24620. */
  24621. static readonly FRONTSIDE: number;
  24622. /**
  24623. * Mesh side orientation : usually the internal or back surface
  24624. */
  24625. static readonly BACKSIDE: number;
  24626. /**
  24627. * Mesh side orientation : both internal and external or front and back surfaces
  24628. */
  24629. static readonly DOUBLESIDE: number;
  24630. /**
  24631. * Mesh side orientation : by default, `FRONTSIDE`
  24632. */
  24633. static readonly DEFAULTSIDE: number;
  24634. /**
  24635. * Mesh cap setting : no cap
  24636. */
  24637. static readonly NO_CAP: number;
  24638. /**
  24639. * Mesh cap setting : one cap at the beginning of the mesh
  24640. */
  24641. static readonly CAP_START: number;
  24642. /**
  24643. * Mesh cap setting : one cap at the end of the mesh
  24644. */
  24645. static readonly CAP_END: number;
  24646. /**
  24647. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24648. */
  24649. static readonly CAP_ALL: number;
  24650. /**
  24651. * Mesh pattern setting : no flip or rotate
  24652. */
  24653. static readonly NO_FLIP: number;
  24654. /**
  24655. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24656. */
  24657. static readonly FLIP_TILE: number;
  24658. /**
  24659. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24660. */
  24661. static readonly ROTATE_TILE: number;
  24662. /**
  24663. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24664. */
  24665. static readonly FLIP_ROW: number;
  24666. /**
  24667. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24668. */
  24669. static readonly ROTATE_ROW: number;
  24670. /**
  24671. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24672. */
  24673. static readonly FLIP_N_ROTATE_TILE: number;
  24674. /**
  24675. * Mesh pattern setting : rotate pattern and rotate
  24676. */
  24677. static readonly FLIP_N_ROTATE_ROW: number;
  24678. /**
  24679. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24680. */
  24681. static readonly CENTER: number;
  24682. /**
  24683. * Mesh tile positioning : part tiles on left
  24684. */
  24685. static readonly LEFT: number;
  24686. /**
  24687. * Mesh tile positioning : part tiles on right
  24688. */
  24689. static readonly RIGHT: number;
  24690. /**
  24691. * Mesh tile positioning : part tiles on top
  24692. */
  24693. static readonly TOP: number;
  24694. /**
  24695. * Mesh tile positioning : part tiles on bottom
  24696. */
  24697. static readonly BOTTOM: number;
  24698. /**
  24699. * Gets the default side orientation.
  24700. * @param orientation the orientation to value to attempt to get
  24701. * @returns the default orientation
  24702. * @hidden
  24703. */
  24704. static _GetDefaultSideOrientation(orientation?: number): number;
  24705. private _internalMeshDataInfo;
  24706. /**
  24707. * An event triggered before rendering the mesh
  24708. */
  24709. get onBeforeRenderObservable(): Observable<Mesh>;
  24710. /**
  24711. * An event triggered before binding the mesh
  24712. */
  24713. get onBeforeBindObservable(): Observable<Mesh>;
  24714. /**
  24715. * An event triggered after rendering the mesh
  24716. */
  24717. get onAfterRenderObservable(): Observable<Mesh>;
  24718. /**
  24719. * An event triggered before drawing the mesh
  24720. */
  24721. get onBeforeDrawObservable(): Observable<Mesh>;
  24722. private _onBeforeDrawObserver;
  24723. /**
  24724. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24725. */
  24726. set onBeforeDraw(callback: () => void);
  24727. get hasInstances(): boolean;
  24728. /**
  24729. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24730. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24731. */
  24732. delayLoadState: number;
  24733. /**
  24734. * Gets the list of instances created from this mesh
  24735. * it is not supposed to be modified manually.
  24736. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24737. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24738. */
  24739. instances: InstancedMesh[];
  24740. /**
  24741. * Gets the file containing delay loading data for this mesh
  24742. */
  24743. delayLoadingFile: string;
  24744. /** @hidden */
  24745. _binaryInfo: any;
  24746. /**
  24747. * User defined function used to change how LOD level selection is done
  24748. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24749. */
  24750. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24751. /**
  24752. * Gets or sets the morph target manager
  24753. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24754. */
  24755. get morphTargetManager(): Nullable<MorphTargetManager>;
  24756. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24757. /** @hidden */
  24758. _creationDataStorage: Nullable<_CreationDataStorage>;
  24759. /** @hidden */
  24760. _geometry: Nullable<Geometry>;
  24761. /** @hidden */
  24762. _delayInfo: Array<string>;
  24763. /** @hidden */
  24764. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24765. /** @hidden */
  24766. _instanceDataStorage: _InstanceDataStorage;
  24767. private _effectiveMaterial;
  24768. /** @hidden */
  24769. _shouldGenerateFlatShading: boolean;
  24770. /** @hidden */
  24771. _originalBuilderSideOrientation: number;
  24772. /**
  24773. * Use this property to change the original side orientation defined at construction time
  24774. */
  24775. overrideMaterialSideOrientation: Nullable<number>;
  24776. /**
  24777. * Gets the source mesh (the one used to clone this one from)
  24778. */
  24779. get source(): Nullable<Mesh>;
  24780. /**
  24781. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24782. */
  24783. get isUnIndexed(): boolean;
  24784. set isUnIndexed(value: boolean);
  24785. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24786. get worldMatrixInstancedBuffer(): Float32Array;
  24787. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24788. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24789. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24790. /**
  24791. * @constructor
  24792. * @param name The value used by scene.getMeshByName() to do a lookup.
  24793. * @param scene The scene to add this mesh to.
  24794. * @param parent The parent of this mesh, if it has one
  24795. * @param source An optional Mesh from which geometry is shared, cloned.
  24796. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24797. * When false, achieved by calling a clone(), also passing False.
  24798. * This will make creation of children, recursive.
  24799. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24800. */
  24801. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24802. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24803. doNotInstantiate: boolean;
  24804. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24805. /**
  24806. * Gets the class name
  24807. * @returns the string "Mesh".
  24808. */
  24809. getClassName(): string;
  24810. /** @hidden */
  24811. get _isMesh(): boolean;
  24812. /**
  24813. * Returns a description of this mesh
  24814. * @param fullDetails define if full details about this mesh must be used
  24815. * @returns a descriptive string representing this mesh
  24816. */
  24817. toString(fullDetails?: boolean): string;
  24818. /** @hidden */
  24819. _unBindEffect(): void;
  24820. /**
  24821. * Gets a boolean indicating if this mesh has LOD
  24822. */
  24823. get hasLODLevels(): boolean;
  24824. /**
  24825. * Gets the list of MeshLODLevel associated with the current mesh
  24826. * @returns an array of MeshLODLevel
  24827. */
  24828. getLODLevels(): MeshLODLevel[];
  24829. private _sortLODLevels;
  24830. /**
  24831. * Add a mesh as LOD level triggered at the given distance.
  24832. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24833. * @param distance The distance from the center of the object to show this level
  24834. * @param mesh The mesh to be added as LOD level (can be null)
  24835. * @return This mesh (for chaining)
  24836. */
  24837. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24838. /**
  24839. * Returns the LOD level mesh at the passed distance or null if not found.
  24840. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24841. * @param distance The distance from the center of the object to show this level
  24842. * @returns a Mesh or `null`
  24843. */
  24844. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24845. /**
  24846. * Remove a mesh from the LOD array
  24847. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24848. * @param mesh defines the mesh to be removed
  24849. * @return This mesh (for chaining)
  24850. */
  24851. removeLODLevel(mesh: Mesh): Mesh;
  24852. /**
  24853. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24854. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24855. * @param camera defines the camera to use to compute distance
  24856. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24857. * @return This mesh (for chaining)
  24858. */
  24859. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24860. /**
  24861. * Gets the mesh internal Geometry object
  24862. */
  24863. get geometry(): Nullable<Geometry>;
  24864. /**
  24865. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24866. * @returns the total number of vertices
  24867. */
  24868. getTotalVertices(): number;
  24869. /**
  24870. * Returns the content of an associated vertex buffer
  24871. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24872. * - VertexBuffer.PositionKind
  24873. * - VertexBuffer.UVKind
  24874. * - VertexBuffer.UV2Kind
  24875. * - VertexBuffer.UV3Kind
  24876. * - VertexBuffer.UV4Kind
  24877. * - VertexBuffer.UV5Kind
  24878. * - VertexBuffer.UV6Kind
  24879. * - VertexBuffer.ColorKind
  24880. * - VertexBuffer.MatricesIndicesKind
  24881. * - VertexBuffer.MatricesIndicesExtraKind
  24882. * - VertexBuffer.MatricesWeightsKind
  24883. * - VertexBuffer.MatricesWeightsExtraKind
  24884. * @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
  24885. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24886. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24887. */
  24888. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24889. /**
  24890. * Returns the mesh VertexBuffer object from the requested `kind`
  24891. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24892. * - VertexBuffer.PositionKind
  24893. * - VertexBuffer.NormalKind
  24894. * - VertexBuffer.UVKind
  24895. * - VertexBuffer.UV2Kind
  24896. * - VertexBuffer.UV3Kind
  24897. * - VertexBuffer.UV4Kind
  24898. * - VertexBuffer.UV5Kind
  24899. * - VertexBuffer.UV6Kind
  24900. * - VertexBuffer.ColorKind
  24901. * - VertexBuffer.MatricesIndicesKind
  24902. * - VertexBuffer.MatricesIndicesExtraKind
  24903. * - VertexBuffer.MatricesWeightsKind
  24904. * - VertexBuffer.MatricesWeightsExtraKind
  24905. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24906. */
  24907. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24908. /**
  24909. * Tests if a specific vertex buffer is associated with this mesh
  24910. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24911. * - VertexBuffer.PositionKind
  24912. * - VertexBuffer.NormalKind
  24913. * - VertexBuffer.UVKind
  24914. * - VertexBuffer.UV2Kind
  24915. * - VertexBuffer.UV3Kind
  24916. * - VertexBuffer.UV4Kind
  24917. * - VertexBuffer.UV5Kind
  24918. * - VertexBuffer.UV6Kind
  24919. * - VertexBuffer.ColorKind
  24920. * - VertexBuffer.MatricesIndicesKind
  24921. * - VertexBuffer.MatricesIndicesExtraKind
  24922. * - VertexBuffer.MatricesWeightsKind
  24923. * - VertexBuffer.MatricesWeightsExtraKind
  24924. * @returns a boolean
  24925. */
  24926. isVerticesDataPresent(kind: string): boolean;
  24927. /**
  24928. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24929. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24930. * - VertexBuffer.PositionKind
  24931. * - VertexBuffer.UVKind
  24932. * - VertexBuffer.UV2Kind
  24933. * - VertexBuffer.UV3Kind
  24934. * - VertexBuffer.UV4Kind
  24935. * - VertexBuffer.UV5Kind
  24936. * - VertexBuffer.UV6Kind
  24937. * - VertexBuffer.ColorKind
  24938. * - VertexBuffer.MatricesIndicesKind
  24939. * - VertexBuffer.MatricesIndicesExtraKind
  24940. * - VertexBuffer.MatricesWeightsKind
  24941. * - VertexBuffer.MatricesWeightsExtraKind
  24942. * @returns a boolean
  24943. */
  24944. isVertexBufferUpdatable(kind: string): boolean;
  24945. /**
  24946. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24947. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24948. * - VertexBuffer.PositionKind
  24949. * - VertexBuffer.NormalKind
  24950. * - VertexBuffer.UVKind
  24951. * - VertexBuffer.UV2Kind
  24952. * - VertexBuffer.UV3Kind
  24953. * - VertexBuffer.UV4Kind
  24954. * - VertexBuffer.UV5Kind
  24955. * - VertexBuffer.UV6Kind
  24956. * - VertexBuffer.ColorKind
  24957. * - VertexBuffer.MatricesIndicesKind
  24958. * - VertexBuffer.MatricesIndicesExtraKind
  24959. * - VertexBuffer.MatricesWeightsKind
  24960. * - VertexBuffer.MatricesWeightsExtraKind
  24961. * @returns an array of strings
  24962. */
  24963. getVerticesDataKinds(): string[];
  24964. /**
  24965. * Returns a positive integer : the total number of indices in this mesh geometry.
  24966. * @returns the numner of indices or zero if the mesh has no geometry.
  24967. */
  24968. getTotalIndices(): number;
  24969. /**
  24970. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24971. * @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.
  24972. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24973. * @returns the indices array or an empty array if the mesh has no geometry
  24974. */
  24975. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24976. get isBlocked(): boolean;
  24977. /**
  24978. * Determine if the current mesh is ready to be rendered
  24979. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24980. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24981. * @returns true if all associated assets are ready (material, textures, shaders)
  24982. */
  24983. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24984. /**
  24985. * 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.
  24986. */
  24987. get areNormalsFrozen(): boolean;
  24988. /**
  24989. * 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.
  24990. * @returns the current mesh
  24991. */
  24992. freezeNormals(): Mesh;
  24993. /**
  24994. * 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
  24995. * @returns the current mesh
  24996. */
  24997. unfreezeNormals(): Mesh;
  24998. /**
  24999. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25000. */
  25001. set overridenInstanceCount(count: number);
  25002. /** @hidden */
  25003. _preActivate(): Mesh;
  25004. /** @hidden */
  25005. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25006. /** @hidden */
  25007. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25008. /**
  25009. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25010. * This means the mesh underlying bounding box and sphere are recomputed.
  25011. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25012. * @returns the current mesh
  25013. */
  25014. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25015. /** @hidden */
  25016. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25017. /**
  25018. * This function will subdivide the mesh into multiple submeshes
  25019. * @param count defines the expected number of submeshes
  25020. */
  25021. subdivide(count: number): void;
  25022. /**
  25023. * Copy a FloatArray into a specific associated vertex buffer
  25024. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25025. * - VertexBuffer.PositionKind
  25026. * - VertexBuffer.UVKind
  25027. * - VertexBuffer.UV2Kind
  25028. * - VertexBuffer.UV3Kind
  25029. * - VertexBuffer.UV4Kind
  25030. * - VertexBuffer.UV5Kind
  25031. * - VertexBuffer.UV6Kind
  25032. * - VertexBuffer.ColorKind
  25033. * - VertexBuffer.MatricesIndicesKind
  25034. * - VertexBuffer.MatricesIndicesExtraKind
  25035. * - VertexBuffer.MatricesWeightsKind
  25036. * - VertexBuffer.MatricesWeightsExtraKind
  25037. * @param data defines the data source
  25038. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25039. * @param stride defines the data stride size (can be null)
  25040. * @returns the current mesh
  25041. */
  25042. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25043. /**
  25044. * Delete a vertex buffer associated with this mesh
  25045. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25046. * - VertexBuffer.PositionKind
  25047. * - VertexBuffer.UVKind
  25048. * - VertexBuffer.UV2Kind
  25049. * - VertexBuffer.UV3Kind
  25050. * - VertexBuffer.UV4Kind
  25051. * - VertexBuffer.UV5Kind
  25052. * - VertexBuffer.UV6Kind
  25053. * - VertexBuffer.ColorKind
  25054. * - VertexBuffer.MatricesIndicesKind
  25055. * - VertexBuffer.MatricesIndicesExtraKind
  25056. * - VertexBuffer.MatricesWeightsKind
  25057. * - VertexBuffer.MatricesWeightsExtraKind
  25058. */
  25059. removeVerticesData(kind: string): void;
  25060. /**
  25061. * Flags an associated vertex buffer as updatable
  25062. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25063. * - VertexBuffer.PositionKind
  25064. * - VertexBuffer.UVKind
  25065. * - VertexBuffer.UV2Kind
  25066. * - VertexBuffer.UV3Kind
  25067. * - VertexBuffer.UV4Kind
  25068. * - VertexBuffer.UV5Kind
  25069. * - VertexBuffer.UV6Kind
  25070. * - VertexBuffer.ColorKind
  25071. * - VertexBuffer.MatricesIndicesKind
  25072. * - VertexBuffer.MatricesIndicesExtraKind
  25073. * - VertexBuffer.MatricesWeightsKind
  25074. * - VertexBuffer.MatricesWeightsExtraKind
  25075. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25076. */
  25077. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25078. /**
  25079. * Sets the mesh global Vertex Buffer
  25080. * @param buffer defines the buffer to use
  25081. * @returns the current mesh
  25082. */
  25083. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25084. /**
  25085. * Update a specific associated vertex buffer
  25086. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25087. * - VertexBuffer.PositionKind
  25088. * - VertexBuffer.UVKind
  25089. * - VertexBuffer.UV2Kind
  25090. * - VertexBuffer.UV3Kind
  25091. * - VertexBuffer.UV4Kind
  25092. * - VertexBuffer.UV5Kind
  25093. * - VertexBuffer.UV6Kind
  25094. * - VertexBuffer.ColorKind
  25095. * - VertexBuffer.MatricesIndicesKind
  25096. * - VertexBuffer.MatricesIndicesExtraKind
  25097. * - VertexBuffer.MatricesWeightsKind
  25098. * - VertexBuffer.MatricesWeightsExtraKind
  25099. * @param data defines the data source
  25100. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25101. * @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)
  25102. * @returns the current mesh
  25103. */
  25104. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25105. /**
  25106. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25107. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25108. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25109. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25110. * @returns the current mesh
  25111. */
  25112. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25113. /**
  25114. * Creates a un-shared specific occurence of the geometry for the mesh.
  25115. * @returns the current mesh
  25116. */
  25117. makeGeometryUnique(): Mesh;
  25118. /**
  25119. * Set the index buffer of this mesh
  25120. * @param indices defines the source data
  25121. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25122. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25123. * @returns the current mesh
  25124. */
  25125. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25126. /**
  25127. * Update the current index buffer
  25128. * @param indices defines the source data
  25129. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25130. * @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)
  25131. * @returns the current mesh
  25132. */
  25133. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25134. /**
  25135. * Invert the geometry to move from a right handed system to a left handed one.
  25136. * @returns the current mesh
  25137. */
  25138. toLeftHanded(): Mesh;
  25139. /** @hidden */
  25140. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25141. /** @hidden */
  25142. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25143. /**
  25144. * Registers for this mesh a javascript function called just before the rendering process
  25145. * @param func defines the function to call before rendering this mesh
  25146. * @returns the current mesh
  25147. */
  25148. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25149. /**
  25150. * Disposes a previously registered javascript function called before the rendering
  25151. * @param func defines the function to remove
  25152. * @returns the current mesh
  25153. */
  25154. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25155. /**
  25156. * Registers for this mesh a javascript function called just after the rendering is complete
  25157. * @param func defines the function to call after rendering this mesh
  25158. * @returns the current mesh
  25159. */
  25160. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25161. /**
  25162. * Disposes a previously registered javascript function called after the rendering.
  25163. * @param func defines the function to remove
  25164. * @returns the current mesh
  25165. */
  25166. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25167. /** @hidden */
  25168. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25169. /** @hidden */
  25170. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25171. /** @hidden */
  25172. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25173. /** @hidden */
  25174. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25175. /** @hidden */
  25176. _rebuild(): void;
  25177. /** @hidden */
  25178. _freeze(): void;
  25179. /** @hidden */
  25180. _unFreeze(): void;
  25181. /**
  25182. * 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
  25183. * @param subMesh defines the subMesh to render
  25184. * @param enableAlphaMode defines if alpha mode can be changed
  25185. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25186. * @returns the current mesh
  25187. */
  25188. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25189. private _onBeforeDraw;
  25190. /**
  25191. * Renormalize the mesh and patch it up if there are no weights
  25192. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25193. * However in the case of zero weights then we set just a single influence to 1.
  25194. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25195. */
  25196. cleanMatrixWeights(): void;
  25197. private normalizeSkinFourWeights;
  25198. private normalizeSkinWeightsAndExtra;
  25199. /**
  25200. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25201. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25202. * the user know there was an issue with importing the mesh
  25203. * @returns a validation object with skinned, valid and report string
  25204. */
  25205. validateSkinning(): {
  25206. skinned: boolean;
  25207. valid: boolean;
  25208. report: string;
  25209. };
  25210. /** @hidden */
  25211. _checkDelayState(): Mesh;
  25212. private _queueLoad;
  25213. /**
  25214. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25215. * A mesh is in the frustum if its bounding box intersects the frustum
  25216. * @param frustumPlanes defines the frustum to test
  25217. * @returns true if the mesh is in the frustum planes
  25218. */
  25219. isInFrustum(frustumPlanes: Plane[]): boolean;
  25220. /**
  25221. * Sets the mesh material by the material or multiMaterial `id` property
  25222. * @param id is a string identifying the material or the multiMaterial
  25223. * @returns the current mesh
  25224. */
  25225. setMaterialByID(id: string): Mesh;
  25226. /**
  25227. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25228. * @returns an array of IAnimatable
  25229. */
  25230. getAnimatables(): IAnimatable[];
  25231. /**
  25232. * Modifies the mesh geometry according to the passed transformation matrix.
  25233. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25234. * The mesh normals are modified using the same transformation.
  25235. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25236. * @param transform defines the transform matrix to use
  25237. * @see http://doc.babylonjs.com/resources/baking_transformations
  25238. * @returns the current mesh
  25239. */
  25240. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25241. /**
  25242. * Modifies the mesh geometry according to its own current World Matrix.
  25243. * The mesh World Matrix is then reset.
  25244. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25245. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25246. * @see http://doc.babylonjs.com/resources/baking_transformations
  25247. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25248. * @returns the current mesh
  25249. */
  25250. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25251. /** @hidden */
  25252. get _positions(): Nullable<Vector3[]>;
  25253. /** @hidden */
  25254. _resetPointsArrayCache(): Mesh;
  25255. /** @hidden */
  25256. _generatePointsArray(): boolean;
  25257. /**
  25258. * Returns a new Mesh object generated from the current mesh properties.
  25259. * This method must not get confused with createInstance()
  25260. * @param name is a string, the name given to the new mesh
  25261. * @param newParent can be any Node object (default `null`)
  25262. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25263. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25264. * @returns a new mesh
  25265. */
  25266. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25267. /**
  25268. * Releases resources associated with this mesh.
  25269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25271. */
  25272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25273. /** @hidden */
  25274. _disposeInstanceSpecificData(): void;
  25275. /**
  25276. * Modifies the mesh geometry according to a displacement map.
  25277. * 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.
  25278. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25279. * @param url is a string, the URL from the image file is to be downloaded.
  25280. * @param minHeight is the lower limit of the displacement.
  25281. * @param maxHeight is the upper limit of the displacement.
  25282. * @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.
  25283. * @param uvOffset is an optional vector2 used to offset UV.
  25284. * @param uvScale is an optional vector2 used to scale UV.
  25285. * @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.
  25286. * @returns the Mesh.
  25287. */
  25288. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25289. /**
  25290. * Modifies the mesh geometry according to a displacementMap buffer.
  25291. * 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.
  25292. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25293. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25294. * @param heightMapWidth is the width of the buffer image.
  25295. * @param heightMapHeight is the height of the buffer image.
  25296. * @param minHeight is the lower limit of the displacement.
  25297. * @param maxHeight is the upper limit of the displacement.
  25298. * @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.
  25299. * @param uvOffset is an optional vector2 used to offset UV.
  25300. * @param uvScale is an optional vector2 used to scale UV.
  25301. * @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.
  25302. * @returns the Mesh.
  25303. */
  25304. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25305. /**
  25306. * Modify the mesh to get a flat shading rendering.
  25307. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25308. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25309. * @returns current mesh
  25310. */
  25311. convertToFlatShadedMesh(): Mesh;
  25312. /**
  25313. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25314. * In other words, more vertices, no more indices and a single bigger VBO.
  25315. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25316. * @returns current mesh
  25317. */
  25318. convertToUnIndexedMesh(): Mesh;
  25319. /**
  25320. * Inverses facet orientations.
  25321. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25322. * @param flipNormals will also inverts the normals
  25323. * @returns current mesh
  25324. */
  25325. flipFaces(flipNormals?: boolean): Mesh;
  25326. /**
  25327. * Increase the number of facets and hence vertices in a mesh
  25328. * Vertex normals are interpolated from existing vertex normals
  25329. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25330. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25331. */
  25332. increaseVertices(numberPerEdge: number): void;
  25333. /**
  25334. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25335. * This will undo any application of covertToFlatShadedMesh
  25336. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25337. */
  25338. forceSharedVertices(): void;
  25339. /** @hidden */
  25340. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25341. /** @hidden */
  25342. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25343. /**
  25344. * Creates a new InstancedMesh object from the mesh model.
  25345. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25346. * @param name defines the name of the new instance
  25347. * @returns a new InstancedMesh
  25348. */
  25349. createInstance(name: string): InstancedMesh;
  25350. /**
  25351. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25352. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25353. * @returns the current mesh
  25354. */
  25355. synchronizeInstances(): Mesh;
  25356. /**
  25357. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25358. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25359. * This should be used together with the simplification to avoid disappearing triangles.
  25360. * @param successCallback an optional success callback to be called after the optimization finished.
  25361. * @returns the current mesh
  25362. */
  25363. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25364. /**
  25365. * Serialize current mesh
  25366. * @param serializationObject defines the object which will receive the serialization data
  25367. */
  25368. serialize(serializationObject: any): void;
  25369. /** @hidden */
  25370. _syncGeometryWithMorphTargetManager(): void;
  25371. /** @hidden */
  25372. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25373. /**
  25374. * Returns a new Mesh object parsed from the source provided.
  25375. * @param parsedMesh is the source
  25376. * @param scene defines the hosting scene
  25377. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25378. * @returns a new Mesh
  25379. */
  25380. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25381. /**
  25382. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25383. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25384. * @param name defines the name of the mesh to create
  25385. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25386. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25387. * @param closePath creates a seam between the first and the last points of each path of the path array
  25388. * @param offset is taken in account only if the `pathArray` is containing a single path
  25389. * @param scene defines the hosting scene
  25390. * @param updatable defines if the mesh must be flagged as updatable
  25391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25392. * @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)
  25393. * @returns a new Mesh
  25394. */
  25395. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25396. /**
  25397. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25398. * @param name defines the name of the mesh to create
  25399. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25400. * @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
  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 CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25407. /**
  25408. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25409. * @param name defines the name of the mesh to create
  25410. * @param size sets the size (float) of each box side (default 1)
  25411. * @param scene defines the hosting scene
  25412. * @param updatable defines if the mesh must be flagged as updatable
  25413. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25414. * @returns a new Mesh
  25415. */
  25416. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25417. /**
  25418. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25419. * @param name defines the name of the mesh to create
  25420. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25421. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25422. * @param scene defines the hosting scene
  25423. * @param updatable defines if the mesh must be flagged as updatable
  25424. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25425. * @returns a new Mesh
  25426. */
  25427. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25428. /**
  25429. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25430. * @param name defines the name of the mesh to create
  25431. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25432. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25433. * @param scene defines the hosting scene
  25434. * @returns a new Mesh
  25435. */
  25436. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25437. /**
  25438. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25439. * @param name defines the name of the mesh to create
  25440. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25441. * @param diameterTop set the top cap diameter (floats, default 1)
  25442. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25443. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25444. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25445. * @param scene defines the hosting scene
  25446. * @param updatable defines if the mesh must be flagged as updatable
  25447. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25448. * @returns a new Mesh
  25449. */
  25450. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25451. /**
  25452. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25453. * @param name defines the name of the mesh to create
  25454. * @param diameter sets the diameter size (float) of the torus (default 1)
  25455. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25456. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25457. * @param scene defines the hosting scene
  25458. * @param updatable defines if the mesh must be flagged as updatable
  25459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25460. * @returns a new Mesh
  25461. */
  25462. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25463. /**
  25464. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25465. * @param name defines the name of the mesh to create
  25466. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25467. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25468. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25469. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25470. * @param p the number of windings on X axis (positive integers, default 2)
  25471. * @param q the number of windings on Y axis (positive integers, default 3)
  25472. * @param scene defines the hosting scene
  25473. * @param updatable defines if the mesh must be flagged as updatable
  25474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25475. * @returns a new Mesh
  25476. */
  25477. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25478. /**
  25479. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25480. * @param name defines the name of the mesh to create
  25481. * @param points is an array successive Vector3
  25482. * @param scene defines the hosting scene
  25483. * @param updatable defines if the mesh must be flagged as updatable
  25484. * @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).
  25485. * @returns a new Mesh
  25486. */
  25487. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25488. /**
  25489. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25490. * @param name defines the name of the mesh to create
  25491. * @param points is an array successive Vector3
  25492. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25493. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25494. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25495. * @param scene defines the hosting scene
  25496. * @param updatable defines if the mesh must be flagged as updatable
  25497. * @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)
  25498. * @returns a new Mesh
  25499. */
  25500. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25501. /**
  25502. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25503. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25504. * 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.
  25505. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25506. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25507. * Remember you can only change the shape positions, not their number when updating a polygon.
  25508. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25509. * @param name defines the name of the mesh to create
  25510. * @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
  25511. * @param scene defines the hosting scene
  25512. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25513. * @param updatable defines if the mesh must be flagged as updatable
  25514. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25515. * @param earcutInjection can be used to inject your own earcut reference
  25516. * @returns a new Mesh
  25517. */
  25518. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25519. /**
  25520. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25521. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25522. * @param name defines the name of the mesh to create
  25523. * @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
  25524. * @param depth defines the height of extrusion
  25525. * @param scene defines the hosting scene
  25526. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25527. * @param updatable defines if the mesh must be flagged as updatable
  25528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25529. * @param earcutInjection can be used to inject your own earcut reference
  25530. * @returns a new Mesh
  25531. */
  25532. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25533. /**
  25534. * Creates an extruded shape mesh.
  25535. * 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
  25536. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25537. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25538. * @param name defines the name of the mesh to create
  25539. * @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
  25540. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25541. * @param scale is the value to scale the shape
  25542. * @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
  25543. * @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
  25544. * @param scene defines the hosting scene
  25545. * @param updatable defines if the mesh must be flagged as updatable
  25546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25547. * @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)
  25548. * @returns a new Mesh
  25549. */
  25550. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25551. /**
  25552. * Creates an custom extruded shape mesh.
  25553. * The custom extrusion is a parametric shape.
  25554. * It has no predefined shape. Its final shape will depend on the input parameters.
  25555. * Please consider using the same method from the MeshBuilder class instead
  25556. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25557. * @param name defines the name of the mesh to create
  25558. * @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
  25559. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25560. * @param scaleFunction is a custom Javascript function called on each path point
  25561. * @param rotationFunction is a custom Javascript function called on each path point
  25562. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25563. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25564. * @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
  25565. * @param scene defines the hosting scene
  25566. * @param updatable defines if the mesh must be flagged as updatable
  25567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25568. * @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)
  25569. * @returns a new Mesh
  25570. */
  25571. 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;
  25572. /**
  25573. * Creates lathe mesh.
  25574. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25575. * Please consider using the same method from the MeshBuilder class instead
  25576. * @param name defines the name of the mesh to create
  25577. * @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
  25578. * @param radius is the radius value of the lathe
  25579. * @param tessellation is the side number of the lathe.
  25580. * @param scene defines the hosting scene
  25581. * @param updatable defines if the mesh must be flagged as updatable
  25582. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25583. * @returns a new Mesh
  25584. */
  25585. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25586. /**
  25587. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25588. * @param name defines the name of the mesh to create
  25589. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25590. * @param scene defines the hosting scene
  25591. * @param updatable defines if the mesh must be flagged as updatable
  25592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25593. * @returns a new Mesh
  25594. */
  25595. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25596. /**
  25597. * Creates a ground mesh.
  25598. * Please consider using the same method from the MeshBuilder class instead
  25599. * @param name defines the name of the mesh to create
  25600. * @param width set the width of the ground
  25601. * @param height set the height of the ground
  25602. * @param subdivisions sets the number of subdivisions per side
  25603. * @param scene defines the hosting scene
  25604. * @param updatable defines if the mesh must be flagged as updatable
  25605. * @returns a new Mesh
  25606. */
  25607. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25608. /**
  25609. * Creates a tiled ground mesh.
  25610. * Please consider using the same method from the MeshBuilder class instead
  25611. * @param name defines the name of the mesh to create
  25612. * @param xmin set the ground minimum X coordinate
  25613. * @param zmin set the ground minimum Y coordinate
  25614. * @param xmax set the ground maximum X coordinate
  25615. * @param zmax set the ground maximum Z coordinate
  25616. * @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
  25617. * @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
  25618. * @param scene defines the hosting scene
  25619. * @param updatable defines if the mesh must be flagged as updatable
  25620. * @returns a new Mesh
  25621. */
  25622. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25623. w: number;
  25624. h: number;
  25625. }, precision: {
  25626. w: number;
  25627. h: number;
  25628. }, scene: Scene, updatable?: boolean): Mesh;
  25629. /**
  25630. * Creates a ground mesh from a height map.
  25631. * Please consider using the same method from the MeshBuilder class instead
  25632. * @see http://doc.babylonjs.com/babylon101/height_map
  25633. * @param name defines the name of the mesh to create
  25634. * @param url sets the URL of the height map image resource
  25635. * @param width set the ground width size
  25636. * @param height set the ground height size
  25637. * @param subdivisions sets the number of subdivision per side
  25638. * @param minHeight is the minimum altitude on the ground
  25639. * @param maxHeight is the maximum altitude on the ground
  25640. * @param scene defines the hosting scene
  25641. * @param updatable defines if the mesh must be flagged as updatable
  25642. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25643. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25644. * @returns a new Mesh
  25645. */
  25646. 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;
  25647. /**
  25648. * Creates a tube mesh.
  25649. * The tube is a parametric shape.
  25650. * It has no predefined shape. Its final shape will depend on the input parameters.
  25651. * Please consider using the same method from the MeshBuilder class instead
  25652. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25653. * @param name defines the name of the mesh to create
  25654. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25655. * @param radius sets the tube radius size
  25656. * @param tessellation is the number of sides on the tubular surface
  25657. * @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
  25658. * @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
  25659. * @param scene defines the hosting scene
  25660. * @param updatable defines if the mesh must be flagged as updatable
  25661. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25662. * @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)
  25663. * @returns a new Mesh
  25664. */
  25665. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25666. (i: number, distance: number): number;
  25667. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25668. /**
  25669. * Creates a polyhedron mesh.
  25670. * Please consider using the same method from the MeshBuilder class instead.
  25671. * * 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
  25672. * * The parameter `size` (positive float, default 1) sets the polygon size
  25673. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25674. * * 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`
  25675. * * 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
  25676. * * 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)`)
  25677. * * 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
  25678. * * 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
  25679. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25680. * * 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
  25681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25682. * @param name defines the name of the mesh to create
  25683. * @param options defines the options used to create the mesh
  25684. * @param scene defines the hosting scene
  25685. * @returns a new Mesh
  25686. */
  25687. static CreatePolyhedron(name: string, options: {
  25688. type?: number;
  25689. size?: number;
  25690. sizeX?: number;
  25691. sizeY?: number;
  25692. sizeZ?: number;
  25693. custom?: any;
  25694. faceUV?: Vector4[];
  25695. faceColors?: Color4[];
  25696. updatable?: boolean;
  25697. sideOrientation?: number;
  25698. }, scene: Scene): Mesh;
  25699. /**
  25700. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25701. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25702. * * 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`)
  25703. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25704. * * 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
  25705. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25706. * * 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
  25707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25708. * @param name defines the name of the mesh
  25709. * @param options defines the options used to create the mesh
  25710. * @param scene defines the hosting scene
  25711. * @returns a new Mesh
  25712. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25713. */
  25714. static CreateIcoSphere(name: string, options: {
  25715. radius?: number;
  25716. flat?: boolean;
  25717. subdivisions?: number;
  25718. sideOrientation?: number;
  25719. updatable?: boolean;
  25720. }, scene: Scene): Mesh;
  25721. /**
  25722. * Creates a decal mesh.
  25723. * Please consider using the same method from the MeshBuilder class instead.
  25724. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25725. * @param name defines the name of the mesh
  25726. * @param sourceMesh defines the mesh receiving the decal
  25727. * @param position sets the position of the decal in world coordinates
  25728. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25729. * @param size sets the decal scaling
  25730. * @param angle sets the angle to rotate the decal
  25731. * @returns a new Mesh
  25732. */
  25733. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25734. /**
  25735. * Prepare internal position array for software CPU skinning
  25736. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25737. */
  25738. setPositionsForCPUSkinning(): Float32Array;
  25739. /**
  25740. * Prepare internal normal array for software CPU skinning
  25741. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25742. */
  25743. setNormalsForCPUSkinning(): Float32Array;
  25744. /**
  25745. * Updates the vertex buffer by applying transformation from the bones
  25746. * @param skeleton defines the skeleton to apply to current mesh
  25747. * @returns the current mesh
  25748. */
  25749. applySkeleton(skeleton: Skeleton): Mesh;
  25750. /**
  25751. * 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
  25752. * @param meshes defines the list of meshes to scan
  25753. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25754. */
  25755. static MinMax(meshes: AbstractMesh[]): {
  25756. min: Vector3;
  25757. max: Vector3;
  25758. };
  25759. /**
  25760. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25761. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25762. * @returns a vector3
  25763. */
  25764. static Center(meshesOrMinMaxVector: {
  25765. min: Vector3;
  25766. max: Vector3;
  25767. } | AbstractMesh[]): Vector3;
  25768. /**
  25769. * Merge the array of meshes into a single mesh for performance reasons.
  25770. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25771. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25772. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25773. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25774. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25775. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25776. * @returns a new mesh
  25777. */
  25778. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25779. /** @hidden */
  25780. addInstance(instance: InstancedMesh): void;
  25781. /** @hidden */
  25782. removeInstance(instance: InstancedMesh): void;
  25783. }
  25784. }
  25785. declare module BABYLON {
  25786. /**
  25787. * This is the base class of all the camera used in the application.
  25788. * @see http://doc.babylonjs.com/features/cameras
  25789. */
  25790. export class Camera extends Node {
  25791. /** @hidden */
  25792. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25793. /**
  25794. * This is the default projection mode used by the cameras.
  25795. * It helps recreating a feeling of perspective and better appreciate depth.
  25796. * This is the best way to simulate real life cameras.
  25797. */
  25798. static readonly PERSPECTIVE_CAMERA: number;
  25799. /**
  25800. * This helps creating camera with an orthographic mode.
  25801. * 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.
  25802. */
  25803. static readonly ORTHOGRAPHIC_CAMERA: number;
  25804. /**
  25805. * This is the default FOV mode for perspective cameras.
  25806. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25807. */
  25808. static readonly FOVMODE_VERTICAL_FIXED: number;
  25809. /**
  25810. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25811. */
  25812. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25813. /**
  25814. * This specifies ther is no need for a camera rig.
  25815. * Basically only one eye is rendered corresponding to the camera.
  25816. */
  25817. static readonly RIG_MODE_NONE: number;
  25818. /**
  25819. * Simulates a camera Rig with one blue eye and one red eye.
  25820. * This can be use with 3d blue and red glasses.
  25821. */
  25822. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25823. /**
  25824. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25825. */
  25826. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25827. /**
  25828. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25829. */
  25830. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25831. /**
  25832. * Defines that both eyes of the camera will be rendered over under each other.
  25833. */
  25834. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25835. /**
  25836. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25837. */
  25838. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25839. /**
  25840. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25841. */
  25842. static readonly RIG_MODE_VR: number;
  25843. /**
  25844. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25845. */
  25846. static readonly RIG_MODE_WEBVR: number;
  25847. /**
  25848. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25849. */
  25850. static readonly RIG_MODE_CUSTOM: number;
  25851. /**
  25852. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25853. */
  25854. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25855. /**
  25856. * Define the input manager associated with the camera.
  25857. */
  25858. inputs: CameraInputsManager<Camera>;
  25859. /** @hidden */
  25860. _position: Vector3;
  25861. /**
  25862. * Define the current local position of the camera in the scene
  25863. */
  25864. get position(): Vector3;
  25865. set position(newPosition: Vector3);
  25866. /**
  25867. * The vector the camera should consider as up.
  25868. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25869. */
  25870. upVector: Vector3;
  25871. /**
  25872. * Define the current limit on the left side for an orthographic camera
  25873. * In scene unit
  25874. */
  25875. orthoLeft: Nullable<number>;
  25876. /**
  25877. * Define the current limit on the right side for an orthographic camera
  25878. * In scene unit
  25879. */
  25880. orthoRight: Nullable<number>;
  25881. /**
  25882. * Define the current limit on the bottom side for an orthographic camera
  25883. * In scene unit
  25884. */
  25885. orthoBottom: Nullable<number>;
  25886. /**
  25887. * Define the current limit on the top side for an orthographic camera
  25888. * In scene unit
  25889. */
  25890. orthoTop: Nullable<number>;
  25891. /**
  25892. * Field Of View is set in Radians. (default is 0.8)
  25893. */
  25894. fov: number;
  25895. /**
  25896. * Define the minimum distance the camera can see from.
  25897. * This is important to note that the depth buffer are not infinite and the closer it starts
  25898. * the more your scene might encounter depth fighting issue.
  25899. */
  25900. minZ: number;
  25901. /**
  25902. * Define the maximum distance the camera can see to.
  25903. * This is important to note that the depth buffer are not infinite and the further it end
  25904. * the more your scene might encounter depth fighting issue.
  25905. */
  25906. maxZ: number;
  25907. /**
  25908. * Define the default inertia of the camera.
  25909. * This helps giving a smooth feeling to the camera movement.
  25910. */
  25911. inertia: number;
  25912. /**
  25913. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25914. */
  25915. mode: number;
  25916. /**
  25917. * Define whether the camera is intermediate.
  25918. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25919. */
  25920. isIntermediate: boolean;
  25921. /**
  25922. * Define the viewport of the camera.
  25923. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25924. */
  25925. viewport: Viewport;
  25926. /**
  25927. * Restricts the camera to viewing objects with the same layerMask.
  25928. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25929. */
  25930. layerMask: number;
  25931. /**
  25932. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25933. */
  25934. fovMode: number;
  25935. /**
  25936. * Rig mode of the camera.
  25937. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25938. * This is normally controlled byt the camera themselves as internal use.
  25939. */
  25940. cameraRigMode: number;
  25941. /**
  25942. * Defines the distance between both "eyes" in case of a RIG
  25943. */
  25944. interaxialDistance: number;
  25945. /**
  25946. * Defines if stereoscopic rendering is done side by side or over under.
  25947. */
  25948. isStereoscopicSideBySide: boolean;
  25949. /**
  25950. * 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
  25951. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25952. * else in the scene. (Eg. security camera)
  25953. *
  25954. * 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)
  25955. */
  25956. customRenderTargets: RenderTargetTexture[];
  25957. /**
  25958. * When set, the camera will render to this render target instead of the default canvas
  25959. *
  25960. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25961. */
  25962. outputRenderTarget: Nullable<RenderTargetTexture>;
  25963. /**
  25964. * Observable triggered when the camera view matrix has changed.
  25965. */
  25966. onViewMatrixChangedObservable: Observable<Camera>;
  25967. /**
  25968. * Observable triggered when the camera Projection matrix has changed.
  25969. */
  25970. onProjectionMatrixChangedObservable: Observable<Camera>;
  25971. /**
  25972. * Observable triggered when the inputs have been processed.
  25973. */
  25974. onAfterCheckInputsObservable: Observable<Camera>;
  25975. /**
  25976. * Observable triggered when reset has been called and applied to the camera.
  25977. */
  25978. onRestoreStateObservable: Observable<Camera>;
  25979. /**
  25980. * Is this camera a part of a rig system?
  25981. */
  25982. isRigCamera: boolean;
  25983. /**
  25984. * If isRigCamera set to true this will be set with the parent camera.
  25985. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25986. */
  25987. rigParent?: Camera;
  25988. /** @hidden */
  25989. _cameraRigParams: any;
  25990. /** @hidden */
  25991. _rigCameras: Camera[];
  25992. /** @hidden */
  25993. _rigPostProcess: Nullable<PostProcess>;
  25994. protected _webvrViewMatrix: Matrix;
  25995. /** @hidden */
  25996. _skipRendering: boolean;
  25997. /** @hidden */
  25998. _projectionMatrix: Matrix;
  25999. /** @hidden */
  26000. _postProcesses: Nullable<PostProcess>[];
  26001. /** @hidden */
  26002. _activeMeshes: SmartArray<AbstractMesh>;
  26003. protected _globalPosition: Vector3;
  26004. /** @hidden */
  26005. _computedViewMatrix: Matrix;
  26006. private _doNotComputeProjectionMatrix;
  26007. private _transformMatrix;
  26008. private _frustumPlanes;
  26009. private _refreshFrustumPlanes;
  26010. private _storedFov;
  26011. private _stateStored;
  26012. /**
  26013. * Instantiates a new camera object.
  26014. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26015. * @see http://doc.babylonjs.com/features/cameras
  26016. * @param name Defines the name of the camera in the scene
  26017. * @param position Defines the position of the camera
  26018. * @param scene Defines the scene the camera belongs too
  26019. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26020. */
  26021. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26022. /**
  26023. * Store current camera state (fov, position, etc..)
  26024. * @returns the camera
  26025. */
  26026. storeState(): Camera;
  26027. /**
  26028. * Restores the camera state values if it has been stored. You must call storeState() first
  26029. */
  26030. protected _restoreStateValues(): boolean;
  26031. /**
  26032. * Restored camera state. You must call storeState() first.
  26033. * @returns true if restored and false otherwise
  26034. */
  26035. restoreState(): boolean;
  26036. /**
  26037. * Gets the class name of the camera.
  26038. * @returns the class name
  26039. */
  26040. getClassName(): string;
  26041. /** @hidden */
  26042. readonly _isCamera: boolean;
  26043. /**
  26044. * Gets a string representation of the camera useful for debug purpose.
  26045. * @param fullDetails Defines that a more verboe level of logging is required
  26046. * @returns the string representation
  26047. */
  26048. toString(fullDetails?: boolean): string;
  26049. /**
  26050. * Gets the current world space position of the camera.
  26051. */
  26052. get globalPosition(): Vector3;
  26053. /**
  26054. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26055. * @returns the active meshe list
  26056. */
  26057. getActiveMeshes(): SmartArray<AbstractMesh>;
  26058. /**
  26059. * Check whether a mesh is part of the current active mesh list of the camera
  26060. * @param mesh Defines the mesh to check
  26061. * @returns true if active, false otherwise
  26062. */
  26063. isActiveMesh(mesh: Mesh): boolean;
  26064. /**
  26065. * Is this camera ready to be used/rendered
  26066. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26067. * @return true if the camera is ready
  26068. */
  26069. isReady(completeCheck?: boolean): boolean;
  26070. /** @hidden */
  26071. _initCache(): void;
  26072. /** @hidden */
  26073. _updateCache(ignoreParentClass?: boolean): void;
  26074. /** @hidden */
  26075. _isSynchronized(): boolean;
  26076. /** @hidden */
  26077. _isSynchronizedViewMatrix(): boolean;
  26078. /** @hidden */
  26079. _isSynchronizedProjectionMatrix(): boolean;
  26080. /**
  26081. * Attach the input controls to a specific dom element to get the input from.
  26082. * @param element Defines the element the controls should be listened from
  26083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26084. */
  26085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26086. /**
  26087. * Detach the current controls from the specified dom element.
  26088. * @param element Defines the element to stop listening the inputs from
  26089. */
  26090. detachControl(element: HTMLElement): void;
  26091. /**
  26092. * Update the camera state according to the different inputs gathered during the frame.
  26093. */
  26094. update(): void;
  26095. /** @hidden */
  26096. _checkInputs(): void;
  26097. /** @hidden */
  26098. get rigCameras(): Camera[];
  26099. /**
  26100. * Gets the post process used by the rig cameras
  26101. */
  26102. get rigPostProcess(): Nullable<PostProcess>;
  26103. /**
  26104. * Internal, gets the first post proces.
  26105. * @returns the first post process to be run on this camera.
  26106. */
  26107. _getFirstPostProcess(): Nullable<PostProcess>;
  26108. private _cascadePostProcessesToRigCams;
  26109. /**
  26110. * Attach a post process to the camera.
  26111. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26112. * @param postProcess The post process to attach to the camera
  26113. * @param insertAt The position of the post process in case several of them are in use in the scene
  26114. * @returns the position the post process has been inserted at
  26115. */
  26116. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26117. /**
  26118. * Detach a post process to the camera.
  26119. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26120. * @param postProcess The post process to detach from the camera
  26121. */
  26122. detachPostProcess(postProcess: PostProcess): void;
  26123. /**
  26124. * Gets the current world matrix of the camera
  26125. */
  26126. getWorldMatrix(): Matrix;
  26127. /** @hidden */
  26128. _getViewMatrix(): Matrix;
  26129. /**
  26130. * Gets the current view matrix of the camera.
  26131. * @param force forces the camera to recompute the matrix without looking at the cached state
  26132. * @returns the view matrix
  26133. */
  26134. getViewMatrix(force?: boolean): Matrix;
  26135. /**
  26136. * Freeze the projection matrix.
  26137. * It will prevent the cache check of the camera projection compute and can speed up perf
  26138. * if no parameter of the camera are meant to change
  26139. * @param projection Defines manually a projection if necessary
  26140. */
  26141. freezeProjectionMatrix(projection?: Matrix): void;
  26142. /**
  26143. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26144. */
  26145. unfreezeProjectionMatrix(): void;
  26146. /**
  26147. * Gets the current projection matrix of the camera.
  26148. * @param force forces the camera to recompute the matrix without looking at the cached state
  26149. * @returns the projection matrix
  26150. */
  26151. getProjectionMatrix(force?: boolean): Matrix;
  26152. /**
  26153. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26154. * @returns a Matrix
  26155. */
  26156. getTransformationMatrix(): Matrix;
  26157. private _updateFrustumPlanes;
  26158. /**
  26159. * Checks if a cullable object (mesh...) is in the camera frustum
  26160. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26161. * @param target The object to check
  26162. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26163. * @returns true if the object is in frustum otherwise false
  26164. */
  26165. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26166. /**
  26167. * Checks if a cullable object (mesh...) is in the camera frustum
  26168. * Unlike isInFrustum this cheks the full bounding box
  26169. * @param target The object to check
  26170. * @returns true if the object is in frustum otherwise false
  26171. */
  26172. isCompletelyInFrustum(target: ICullable): boolean;
  26173. /**
  26174. * Gets a ray in the forward direction from the camera.
  26175. * @param length Defines the length of the ray to create
  26176. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26177. * @param origin Defines the start point of the ray which defaults to the camera position
  26178. * @returns the forward ray
  26179. */
  26180. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26181. /**
  26182. * Releases resources associated with this node.
  26183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26185. */
  26186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26187. /** @hidden */
  26188. _isLeftCamera: boolean;
  26189. /**
  26190. * Gets the left camera of a rig setup in case of Rigged Camera
  26191. */
  26192. get isLeftCamera(): boolean;
  26193. /** @hidden */
  26194. _isRightCamera: boolean;
  26195. /**
  26196. * Gets the right camera of a rig setup in case of Rigged Camera
  26197. */
  26198. get isRightCamera(): boolean;
  26199. /**
  26200. * Gets the left camera of a rig setup in case of Rigged Camera
  26201. */
  26202. get leftCamera(): Nullable<FreeCamera>;
  26203. /**
  26204. * Gets the right camera of a rig setup in case of Rigged Camera
  26205. */
  26206. get rightCamera(): Nullable<FreeCamera>;
  26207. /**
  26208. * Gets the left camera target of a rig setup in case of Rigged Camera
  26209. * @returns the target position
  26210. */
  26211. getLeftTarget(): Nullable<Vector3>;
  26212. /**
  26213. * Gets the right camera target of a rig setup in case of Rigged Camera
  26214. * @returns the target position
  26215. */
  26216. getRightTarget(): Nullable<Vector3>;
  26217. /**
  26218. * @hidden
  26219. */
  26220. setCameraRigMode(mode: number, rigParams: any): void;
  26221. /** @hidden */
  26222. static _setStereoscopicRigMode(camera: Camera): void;
  26223. /** @hidden */
  26224. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26225. /** @hidden */
  26226. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26227. /** @hidden */
  26228. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26229. /** @hidden */
  26230. _getVRProjectionMatrix(): Matrix;
  26231. protected _updateCameraRotationMatrix(): void;
  26232. protected _updateWebVRCameraRotationMatrix(): void;
  26233. /**
  26234. * This function MUST be overwritten by the different WebVR cameras available.
  26235. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26236. * @hidden
  26237. */
  26238. _getWebVRProjectionMatrix(): Matrix;
  26239. /**
  26240. * This function MUST be overwritten by the different WebVR cameras available.
  26241. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26242. * @hidden
  26243. */
  26244. _getWebVRViewMatrix(): Matrix;
  26245. /** @hidden */
  26246. setCameraRigParameter(name: string, value: any): void;
  26247. /**
  26248. * needs to be overridden by children so sub has required properties to be copied
  26249. * @hidden
  26250. */
  26251. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26252. /**
  26253. * May need to be overridden by children
  26254. * @hidden
  26255. */
  26256. _updateRigCameras(): void;
  26257. /** @hidden */
  26258. _setupInputs(): void;
  26259. /**
  26260. * Serialiaze the camera setup to a json represention
  26261. * @returns the JSON representation
  26262. */
  26263. serialize(): any;
  26264. /**
  26265. * Clones the current camera.
  26266. * @param name The cloned camera name
  26267. * @returns the cloned camera
  26268. */
  26269. clone(name: string): Camera;
  26270. /**
  26271. * Gets the direction of the camera relative to a given local axis.
  26272. * @param localAxis Defines the reference axis to provide a relative direction.
  26273. * @return the direction
  26274. */
  26275. getDirection(localAxis: Vector3): Vector3;
  26276. /**
  26277. * Returns the current camera absolute rotation
  26278. */
  26279. get absoluteRotation(): Quaternion;
  26280. /**
  26281. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26282. * @param localAxis Defines the reference axis to provide a relative direction.
  26283. * @param result Defines the vector to store the result in
  26284. */
  26285. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26286. /**
  26287. * Gets a camera constructor for a given camera type
  26288. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26289. * @param name The name of the camera the result will be able to instantiate
  26290. * @param scene The scene the result will construct the camera in
  26291. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26292. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26293. * @returns a factory method to construc the camera
  26294. */
  26295. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26296. /**
  26297. * Compute the world matrix of the camera.
  26298. * @returns the camera world matrix
  26299. */
  26300. computeWorldMatrix(): Matrix;
  26301. /**
  26302. * Parse a JSON and creates the camera from the parsed information
  26303. * @param parsedCamera The JSON to parse
  26304. * @param scene The scene to instantiate the camera in
  26305. * @returns the newly constructed camera
  26306. */
  26307. static Parse(parsedCamera: any, scene: Scene): Camera;
  26308. }
  26309. }
  26310. declare module BABYLON {
  26311. /**
  26312. * Class containing static functions to help procedurally build meshes
  26313. */
  26314. export class DiscBuilder {
  26315. /**
  26316. * Creates a plane polygonal mesh. By default, this is a disc
  26317. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26318. * * 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
  26319. * * 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
  26320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26321. * * 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
  26322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26323. * @param name defines the name of the mesh
  26324. * @param options defines the options used to create the mesh
  26325. * @param scene defines the hosting scene
  26326. * @returns the plane polygonal mesh
  26327. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26328. */
  26329. static CreateDisc(name: string, options: {
  26330. radius?: number;
  26331. tessellation?: number;
  26332. arc?: number;
  26333. updatable?: boolean;
  26334. sideOrientation?: number;
  26335. frontUVs?: Vector4;
  26336. backUVs?: Vector4;
  26337. }, scene?: Nullable<Scene>): Mesh;
  26338. }
  26339. }
  26340. declare module BABYLON {
  26341. /**
  26342. * Options to be used when creating a FresnelParameters.
  26343. */
  26344. export type IFresnelParametersCreationOptions = {
  26345. /**
  26346. * Define the color used on edges (grazing angle)
  26347. */
  26348. leftColor?: Color3;
  26349. /**
  26350. * Define the color used on center
  26351. */
  26352. rightColor?: Color3;
  26353. /**
  26354. * Define bias applied to computed fresnel term
  26355. */
  26356. bias?: number;
  26357. /**
  26358. * Defined the power exponent applied to fresnel term
  26359. */
  26360. power?: number;
  26361. /**
  26362. * Define if the fresnel effect is enable or not.
  26363. */
  26364. isEnabled?: boolean;
  26365. };
  26366. /**
  26367. * Serialized format for FresnelParameters.
  26368. */
  26369. export type IFresnelParametersSerialized = {
  26370. /**
  26371. * Define the color used on edges (grazing angle) [as an array]
  26372. */
  26373. leftColor: number[];
  26374. /**
  26375. * Define the color used on center [as an array]
  26376. */
  26377. rightColor: number[];
  26378. /**
  26379. * Define bias applied to computed fresnel term
  26380. */
  26381. bias: number;
  26382. /**
  26383. * Defined the power exponent applied to fresnel term
  26384. */
  26385. power?: number;
  26386. /**
  26387. * Define if the fresnel effect is enable or not.
  26388. */
  26389. isEnabled: boolean;
  26390. };
  26391. /**
  26392. * This represents all the required information to add a fresnel effect on a material:
  26393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26394. */
  26395. export class FresnelParameters {
  26396. private _isEnabled;
  26397. /**
  26398. * Define if the fresnel effect is enable or not.
  26399. */
  26400. get isEnabled(): boolean;
  26401. set isEnabled(value: boolean);
  26402. /**
  26403. * Define the color used on edges (grazing angle)
  26404. */
  26405. leftColor: Color3;
  26406. /**
  26407. * Define the color used on center
  26408. */
  26409. rightColor: Color3;
  26410. /**
  26411. * Define bias applied to computed fresnel term
  26412. */
  26413. bias: number;
  26414. /**
  26415. * Defined the power exponent applied to fresnel term
  26416. */
  26417. power: number;
  26418. /**
  26419. * Creates a new FresnelParameters object.
  26420. *
  26421. * @param options provide your own settings to optionally to override defaults
  26422. */
  26423. constructor(options?: IFresnelParametersCreationOptions);
  26424. /**
  26425. * Clones the current fresnel and its valuues
  26426. * @returns a clone fresnel configuration
  26427. */
  26428. clone(): FresnelParameters;
  26429. /**
  26430. * Determines equality between FresnelParameters objects
  26431. * @param otherFresnelParameters defines the second operand
  26432. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26433. */
  26434. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26435. /**
  26436. * Serializes the current fresnel parameters to a JSON representation.
  26437. * @return the JSON serialization
  26438. */
  26439. serialize(): IFresnelParametersSerialized;
  26440. /**
  26441. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26442. * @param parsedFresnelParameters Define the JSON representation
  26443. * @returns the parsed parameters
  26444. */
  26445. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26446. }
  26447. }
  26448. declare module BABYLON {
  26449. /**
  26450. * Base class of materials working in push mode in babylon JS
  26451. * @hidden
  26452. */
  26453. export class PushMaterial extends Material {
  26454. protected _activeEffect: Effect;
  26455. protected _normalMatrix: Matrix;
  26456. /**
  26457. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26458. * This means that the material can keep using a previous shader while a new one is being compiled.
  26459. * This is mostly used when shader parallel compilation is supported (true by default)
  26460. */
  26461. allowShaderHotSwapping: boolean;
  26462. constructor(name: string, scene: Scene);
  26463. getEffect(): Effect;
  26464. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26465. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26466. /**
  26467. * Binds the given world matrix to the active effect
  26468. *
  26469. * @param world the matrix to bind
  26470. */
  26471. bindOnlyWorldMatrix(world: Matrix): void;
  26472. /**
  26473. * Binds the given normal matrix to the active effect
  26474. *
  26475. * @param normalMatrix the matrix to bind
  26476. */
  26477. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26478. bind(world: Matrix, mesh?: Mesh): void;
  26479. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26480. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26481. }
  26482. }
  26483. declare module BABYLON {
  26484. /**
  26485. * This groups all the flags used to control the materials channel.
  26486. */
  26487. export class MaterialFlags {
  26488. private static _DiffuseTextureEnabled;
  26489. /**
  26490. * Are diffuse textures enabled in the application.
  26491. */
  26492. static get DiffuseTextureEnabled(): boolean;
  26493. static set DiffuseTextureEnabled(value: boolean);
  26494. private static _AmbientTextureEnabled;
  26495. /**
  26496. * Are ambient textures enabled in the application.
  26497. */
  26498. static get AmbientTextureEnabled(): boolean;
  26499. static set AmbientTextureEnabled(value: boolean);
  26500. private static _OpacityTextureEnabled;
  26501. /**
  26502. * Are opacity textures enabled in the application.
  26503. */
  26504. static get OpacityTextureEnabled(): boolean;
  26505. static set OpacityTextureEnabled(value: boolean);
  26506. private static _ReflectionTextureEnabled;
  26507. /**
  26508. * Are reflection textures enabled in the application.
  26509. */
  26510. static get ReflectionTextureEnabled(): boolean;
  26511. static set ReflectionTextureEnabled(value: boolean);
  26512. private static _EmissiveTextureEnabled;
  26513. /**
  26514. * Are emissive textures enabled in the application.
  26515. */
  26516. static get EmissiveTextureEnabled(): boolean;
  26517. static set EmissiveTextureEnabled(value: boolean);
  26518. private static _SpecularTextureEnabled;
  26519. /**
  26520. * Are specular textures enabled in the application.
  26521. */
  26522. static get SpecularTextureEnabled(): boolean;
  26523. static set SpecularTextureEnabled(value: boolean);
  26524. private static _BumpTextureEnabled;
  26525. /**
  26526. * Are bump textures enabled in the application.
  26527. */
  26528. static get BumpTextureEnabled(): boolean;
  26529. static set BumpTextureEnabled(value: boolean);
  26530. private static _LightmapTextureEnabled;
  26531. /**
  26532. * Are lightmap textures enabled in the application.
  26533. */
  26534. static get LightmapTextureEnabled(): boolean;
  26535. static set LightmapTextureEnabled(value: boolean);
  26536. private static _RefractionTextureEnabled;
  26537. /**
  26538. * Are refraction textures enabled in the application.
  26539. */
  26540. static get RefractionTextureEnabled(): boolean;
  26541. static set RefractionTextureEnabled(value: boolean);
  26542. private static _ColorGradingTextureEnabled;
  26543. /**
  26544. * Are color grading textures enabled in the application.
  26545. */
  26546. static get ColorGradingTextureEnabled(): boolean;
  26547. static set ColorGradingTextureEnabled(value: boolean);
  26548. private static _FresnelEnabled;
  26549. /**
  26550. * Are fresnels enabled in the application.
  26551. */
  26552. static get FresnelEnabled(): boolean;
  26553. static set FresnelEnabled(value: boolean);
  26554. private static _ClearCoatTextureEnabled;
  26555. /**
  26556. * Are clear coat textures enabled in the application.
  26557. */
  26558. static get ClearCoatTextureEnabled(): boolean;
  26559. static set ClearCoatTextureEnabled(value: boolean);
  26560. private static _ClearCoatBumpTextureEnabled;
  26561. /**
  26562. * Are clear coat bump textures enabled in the application.
  26563. */
  26564. static get ClearCoatBumpTextureEnabled(): boolean;
  26565. static set ClearCoatBumpTextureEnabled(value: boolean);
  26566. private static _ClearCoatTintTextureEnabled;
  26567. /**
  26568. * Are clear coat tint textures enabled in the application.
  26569. */
  26570. static get ClearCoatTintTextureEnabled(): boolean;
  26571. static set ClearCoatTintTextureEnabled(value: boolean);
  26572. private static _SheenTextureEnabled;
  26573. /**
  26574. * Are sheen textures enabled in the application.
  26575. */
  26576. static get SheenTextureEnabled(): boolean;
  26577. static set SheenTextureEnabled(value: boolean);
  26578. private static _AnisotropicTextureEnabled;
  26579. /**
  26580. * Are anisotropic textures enabled in the application.
  26581. */
  26582. static get AnisotropicTextureEnabled(): boolean;
  26583. static set AnisotropicTextureEnabled(value: boolean);
  26584. private static _ThicknessTextureEnabled;
  26585. /**
  26586. * Are thickness textures enabled in the application.
  26587. */
  26588. static get ThicknessTextureEnabled(): boolean;
  26589. static set ThicknessTextureEnabled(value: boolean);
  26590. }
  26591. }
  26592. declare module BABYLON {
  26593. /** @hidden */
  26594. export var defaultFragmentDeclaration: {
  26595. name: string;
  26596. shader: string;
  26597. };
  26598. }
  26599. declare module BABYLON {
  26600. /** @hidden */
  26601. export var defaultUboDeclaration: {
  26602. name: string;
  26603. shader: string;
  26604. };
  26605. }
  26606. declare module BABYLON {
  26607. /** @hidden */
  26608. export var lightFragmentDeclaration: {
  26609. name: string;
  26610. shader: string;
  26611. };
  26612. }
  26613. declare module BABYLON {
  26614. /** @hidden */
  26615. export var lightUboDeclaration: {
  26616. name: string;
  26617. shader: string;
  26618. };
  26619. }
  26620. declare module BABYLON {
  26621. /** @hidden */
  26622. export var lightsFragmentFunctions: {
  26623. name: string;
  26624. shader: string;
  26625. };
  26626. }
  26627. declare module BABYLON {
  26628. /** @hidden */
  26629. export var shadowsFragmentFunctions: {
  26630. name: string;
  26631. shader: string;
  26632. };
  26633. }
  26634. declare module BABYLON {
  26635. /** @hidden */
  26636. export var fresnelFunction: {
  26637. name: string;
  26638. shader: string;
  26639. };
  26640. }
  26641. declare module BABYLON {
  26642. /** @hidden */
  26643. export var reflectionFunction: {
  26644. name: string;
  26645. shader: string;
  26646. };
  26647. }
  26648. declare module BABYLON {
  26649. /** @hidden */
  26650. export var bumpFragmentFunctions: {
  26651. name: string;
  26652. shader: string;
  26653. };
  26654. }
  26655. declare module BABYLON {
  26656. /** @hidden */
  26657. export var logDepthDeclaration: {
  26658. name: string;
  26659. shader: string;
  26660. };
  26661. }
  26662. declare module BABYLON {
  26663. /** @hidden */
  26664. export var bumpFragment: {
  26665. name: string;
  26666. shader: string;
  26667. };
  26668. }
  26669. declare module BABYLON {
  26670. /** @hidden */
  26671. export var depthPrePass: {
  26672. name: string;
  26673. shader: string;
  26674. };
  26675. }
  26676. declare module BABYLON {
  26677. /** @hidden */
  26678. export var lightFragment: {
  26679. name: string;
  26680. shader: string;
  26681. };
  26682. }
  26683. declare module BABYLON {
  26684. /** @hidden */
  26685. export var logDepthFragment: {
  26686. name: string;
  26687. shader: string;
  26688. };
  26689. }
  26690. declare module BABYLON {
  26691. /** @hidden */
  26692. export var defaultPixelShader: {
  26693. name: string;
  26694. shader: string;
  26695. };
  26696. }
  26697. declare module BABYLON {
  26698. /** @hidden */
  26699. export var defaultVertexDeclaration: {
  26700. name: string;
  26701. shader: string;
  26702. };
  26703. }
  26704. declare module BABYLON {
  26705. /** @hidden */
  26706. export var bumpVertexDeclaration: {
  26707. name: string;
  26708. shader: string;
  26709. };
  26710. }
  26711. declare module BABYLON {
  26712. /** @hidden */
  26713. export var bumpVertex: {
  26714. name: string;
  26715. shader: string;
  26716. };
  26717. }
  26718. declare module BABYLON {
  26719. /** @hidden */
  26720. export var fogVertex: {
  26721. name: string;
  26722. shader: string;
  26723. };
  26724. }
  26725. declare module BABYLON {
  26726. /** @hidden */
  26727. export var shadowsVertex: {
  26728. name: string;
  26729. shader: string;
  26730. };
  26731. }
  26732. declare module BABYLON {
  26733. /** @hidden */
  26734. export var pointCloudVertex: {
  26735. name: string;
  26736. shader: string;
  26737. };
  26738. }
  26739. declare module BABYLON {
  26740. /** @hidden */
  26741. export var logDepthVertex: {
  26742. name: string;
  26743. shader: string;
  26744. };
  26745. }
  26746. declare module BABYLON {
  26747. /** @hidden */
  26748. export var defaultVertexShader: {
  26749. name: string;
  26750. shader: string;
  26751. };
  26752. }
  26753. declare module BABYLON {
  26754. /** @hidden */
  26755. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26756. MAINUV1: boolean;
  26757. MAINUV2: boolean;
  26758. DIFFUSE: boolean;
  26759. DIFFUSEDIRECTUV: number;
  26760. AMBIENT: boolean;
  26761. AMBIENTDIRECTUV: number;
  26762. OPACITY: boolean;
  26763. OPACITYDIRECTUV: number;
  26764. OPACITYRGB: boolean;
  26765. REFLECTION: boolean;
  26766. EMISSIVE: boolean;
  26767. EMISSIVEDIRECTUV: number;
  26768. SPECULAR: boolean;
  26769. SPECULARDIRECTUV: number;
  26770. BUMP: boolean;
  26771. BUMPDIRECTUV: number;
  26772. PARALLAX: boolean;
  26773. PARALLAXOCCLUSION: boolean;
  26774. SPECULAROVERALPHA: boolean;
  26775. CLIPPLANE: boolean;
  26776. CLIPPLANE2: boolean;
  26777. CLIPPLANE3: boolean;
  26778. CLIPPLANE4: boolean;
  26779. CLIPPLANE5: boolean;
  26780. CLIPPLANE6: boolean;
  26781. ALPHATEST: boolean;
  26782. DEPTHPREPASS: boolean;
  26783. ALPHAFROMDIFFUSE: boolean;
  26784. POINTSIZE: boolean;
  26785. FOG: boolean;
  26786. SPECULARTERM: boolean;
  26787. DIFFUSEFRESNEL: boolean;
  26788. OPACITYFRESNEL: boolean;
  26789. REFLECTIONFRESNEL: boolean;
  26790. REFRACTIONFRESNEL: boolean;
  26791. EMISSIVEFRESNEL: boolean;
  26792. FRESNEL: boolean;
  26793. NORMAL: boolean;
  26794. UV1: boolean;
  26795. UV2: boolean;
  26796. VERTEXCOLOR: boolean;
  26797. VERTEXALPHA: boolean;
  26798. NUM_BONE_INFLUENCERS: number;
  26799. BonesPerMesh: number;
  26800. BONETEXTURE: boolean;
  26801. INSTANCES: boolean;
  26802. GLOSSINESS: boolean;
  26803. ROUGHNESS: boolean;
  26804. EMISSIVEASILLUMINATION: boolean;
  26805. LINKEMISSIVEWITHDIFFUSE: boolean;
  26806. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26807. LIGHTMAP: boolean;
  26808. LIGHTMAPDIRECTUV: number;
  26809. OBJECTSPACE_NORMALMAP: boolean;
  26810. USELIGHTMAPASSHADOWMAP: boolean;
  26811. REFLECTIONMAP_3D: boolean;
  26812. REFLECTIONMAP_SPHERICAL: boolean;
  26813. REFLECTIONMAP_PLANAR: boolean;
  26814. REFLECTIONMAP_CUBIC: boolean;
  26815. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26816. REFLECTIONMAP_PROJECTION: boolean;
  26817. REFLECTIONMAP_SKYBOX: boolean;
  26818. REFLECTIONMAP_EXPLICIT: boolean;
  26819. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26820. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26821. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26822. INVERTCUBICMAP: boolean;
  26823. LOGARITHMICDEPTH: boolean;
  26824. REFRACTION: boolean;
  26825. REFRACTIONMAP_3D: boolean;
  26826. REFLECTIONOVERALPHA: boolean;
  26827. TWOSIDEDLIGHTING: boolean;
  26828. SHADOWFLOAT: boolean;
  26829. MORPHTARGETS: boolean;
  26830. MORPHTARGETS_NORMAL: boolean;
  26831. MORPHTARGETS_TANGENT: boolean;
  26832. MORPHTARGETS_UV: boolean;
  26833. NUM_MORPH_INFLUENCERS: number;
  26834. NONUNIFORMSCALING: boolean;
  26835. PREMULTIPLYALPHA: boolean;
  26836. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26837. ALPHABLEND: boolean;
  26838. IMAGEPROCESSING: boolean;
  26839. VIGNETTE: boolean;
  26840. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26841. VIGNETTEBLENDMODEOPAQUE: boolean;
  26842. TONEMAPPING: boolean;
  26843. TONEMAPPING_ACES: boolean;
  26844. CONTRAST: boolean;
  26845. COLORCURVES: boolean;
  26846. COLORGRADING: boolean;
  26847. COLORGRADING3D: boolean;
  26848. SAMPLER3DGREENDEPTH: boolean;
  26849. SAMPLER3DBGRMAP: boolean;
  26850. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26851. MULTIVIEW: boolean;
  26852. /**
  26853. * If the reflection texture on this material is in linear color space
  26854. * @hidden
  26855. */
  26856. IS_REFLECTION_LINEAR: boolean;
  26857. /**
  26858. * If the refraction texture on this material is in linear color space
  26859. * @hidden
  26860. */
  26861. IS_REFRACTION_LINEAR: boolean;
  26862. EXPOSURE: boolean;
  26863. constructor();
  26864. setReflectionMode(modeToEnable: string): void;
  26865. }
  26866. /**
  26867. * This is the default material used in Babylon. It is the best trade off between quality
  26868. * and performances.
  26869. * @see http://doc.babylonjs.com/babylon101/materials
  26870. */
  26871. export class StandardMaterial extends PushMaterial {
  26872. private _diffuseTexture;
  26873. /**
  26874. * The basic texture of the material as viewed under a light.
  26875. */
  26876. diffuseTexture: Nullable<BaseTexture>;
  26877. private _ambientTexture;
  26878. /**
  26879. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26880. */
  26881. ambientTexture: Nullable<BaseTexture>;
  26882. private _opacityTexture;
  26883. /**
  26884. * Define the transparency of the material from a texture.
  26885. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26886. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26887. */
  26888. opacityTexture: Nullable<BaseTexture>;
  26889. private _reflectionTexture;
  26890. /**
  26891. * Define the texture used to display the reflection.
  26892. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26893. */
  26894. reflectionTexture: Nullable<BaseTexture>;
  26895. private _emissiveTexture;
  26896. /**
  26897. * Define texture of the material as if self lit.
  26898. * This will be mixed in the final result even in the absence of light.
  26899. */
  26900. emissiveTexture: Nullable<BaseTexture>;
  26901. private _specularTexture;
  26902. /**
  26903. * Define how the color and intensity of the highlight given by the light in the material.
  26904. */
  26905. specularTexture: Nullable<BaseTexture>;
  26906. private _bumpTexture;
  26907. /**
  26908. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26909. * 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.
  26910. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26911. */
  26912. bumpTexture: Nullable<BaseTexture>;
  26913. private _lightmapTexture;
  26914. /**
  26915. * Complex lighting can be computationally expensive to compute at runtime.
  26916. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26917. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26918. */
  26919. lightmapTexture: Nullable<BaseTexture>;
  26920. private _refractionTexture;
  26921. /**
  26922. * Define the texture used to display the refraction.
  26923. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26924. */
  26925. refractionTexture: Nullable<BaseTexture>;
  26926. /**
  26927. * The color of the material lit by the environmental background lighting.
  26928. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26929. */
  26930. ambientColor: Color3;
  26931. /**
  26932. * The basic color of the material as viewed under a light.
  26933. */
  26934. diffuseColor: Color3;
  26935. /**
  26936. * Define how the color and intensity of the highlight given by the light in the material.
  26937. */
  26938. specularColor: Color3;
  26939. /**
  26940. * Define the color of the material as if self lit.
  26941. * This will be mixed in the final result even in the absence of light.
  26942. */
  26943. emissiveColor: Color3;
  26944. /**
  26945. * Defines how sharp are the highlights in the material.
  26946. * The bigger the value the sharper giving a more glossy feeling to the result.
  26947. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26948. */
  26949. specularPower: number;
  26950. private _useAlphaFromDiffuseTexture;
  26951. /**
  26952. * Does the transparency come from the diffuse texture alpha channel.
  26953. */
  26954. useAlphaFromDiffuseTexture: boolean;
  26955. private _useEmissiveAsIllumination;
  26956. /**
  26957. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26958. */
  26959. useEmissiveAsIllumination: boolean;
  26960. private _linkEmissiveWithDiffuse;
  26961. /**
  26962. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26963. * the emissive level when the final color is close to one.
  26964. */
  26965. linkEmissiveWithDiffuse: boolean;
  26966. private _useSpecularOverAlpha;
  26967. /**
  26968. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26969. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26970. */
  26971. useSpecularOverAlpha: boolean;
  26972. private _useReflectionOverAlpha;
  26973. /**
  26974. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26975. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26976. */
  26977. useReflectionOverAlpha: boolean;
  26978. private _disableLighting;
  26979. /**
  26980. * Does lights from the scene impacts this material.
  26981. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26982. */
  26983. disableLighting: boolean;
  26984. private _useObjectSpaceNormalMap;
  26985. /**
  26986. * Allows using an object space normal map (instead of tangent space).
  26987. */
  26988. useObjectSpaceNormalMap: boolean;
  26989. private _useParallax;
  26990. /**
  26991. * Is parallax enabled or not.
  26992. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26993. */
  26994. useParallax: boolean;
  26995. private _useParallaxOcclusion;
  26996. /**
  26997. * Is parallax occlusion enabled or not.
  26998. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26999. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27000. */
  27001. useParallaxOcclusion: boolean;
  27002. /**
  27003. * 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.
  27004. */
  27005. parallaxScaleBias: number;
  27006. private _roughness;
  27007. /**
  27008. * Helps to define how blurry the reflections should appears in the material.
  27009. */
  27010. roughness: number;
  27011. /**
  27012. * In case of refraction, define the value of the index of refraction.
  27013. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27014. */
  27015. indexOfRefraction: number;
  27016. /**
  27017. * Invert the refraction texture alongside the y axis.
  27018. * It can be useful with procedural textures or probe for instance.
  27019. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27020. */
  27021. invertRefractionY: boolean;
  27022. /**
  27023. * Defines the alpha limits in alpha test mode.
  27024. */
  27025. alphaCutOff: number;
  27026. private _useLightmapAsShadowmap;
  27027. /**
  27028. * In case of light mapping, define whether the map contains light or shadow informations.
  27029. */
  27030. useLightmapAsShadowmap: boolean;
  27031. private _diffuseFresnelParameters;
  27032. /**
  27033. * Define the diffuse fresnel parameters of the material.
  27034. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27035. */
  27036. diffuseFresnelParameters: FresnelParameters;
  27037. private _opacityFresnelParameters;
  27038. /**
  27039. * Define the opacity fresnel parameters of the material.
  27040. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27041. */
  27042. opacityFresnelParameters: FresnelParameters;
  27043. private _reflectionFresnelParameters;
  27044. /**
  27045. * Define the reflection fresnel parameters of the material.
  27046. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27047. */
  27048. reflectionFresnelParameters: FresnelParameters;
  27049. private _refractionFresnelParameters;
  27050. /**
  27051. * Define the refraction fresnel parameters of the material.
  27052. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27053. */
  27054. refractionFresnelParameters: FresnelParameters;
  27055. private _emissiveFresnelParameters;
  27056. /**
  27057. * Define the emissive fresnel parameters of the material.
  27058. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27059. */
  27060. emissiveFresnelParameters: FresnelParameters;
  27061. private _useReflectionFresnelFromSpecular;
  27062. /**
  27063. * If true automatically deducts the fresnels values from the material specularity.
  27064. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27065. */
  27066. useReflectionFresnelFromSpecular: boolean;
  27067. private _useGlossinessFromSpecularMapAlpha;
  27068. /**
  27069. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27070. */
  27071. useGlossinessFromSpecularMapAlpha: boolean;
  27072. private _maxSimultaneousLights;
  27073. /**
  27074. * Defines the maximum number of lights that can be used in the material
  27075. */
  27076. maxSimultaneousLights: number;
  27077. private _invertNormalMapX;
  27078. /**
  27079. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27080. */
  27081. invertNormalMapX: boolean;
  27082. private _invertNormalMapY;
  27083. /**
  27084. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27085. */
  27086. invertNormalMapY: boolean;
  27087. private _twoSidedLighting;
  27088. /**
  27089. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27090. */
  27091. twoSidedLighting: boolean;
  27092. /**
  27093. * Default configuration related to image processing available in the standard Material.
  27094. */
  27095. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27096. /**
  27097. * Gets the image processing configuration used either in this material.
  27098. */
  27099. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27100. /**
  27101. * Sets the Default image processing configuration used either in the this material.
  27102. *
  27103. * If sets to null, the scene one is in use.
  27104. */
  27105. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27106. /**
  27107. * Keep track of the image processing observer to allow dispose and replace.
  27108. */
  27109. private _imageProcessingObserver;
  27110. /**
  27111. * Attaches a new image processing configuration to the Standard Material.
  27112. * @param configuration
  27113. */
  27114. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27115. /**
  27116. * Gets wether the color curves effect is enabled.
  27117. */
  27118. get cameraColorCurvesEnabled(): boolean;
  27119. /**
  27120. * Sets wether the color curves effect is enabled.
  27121. */
  27122. set cameraColorCurvesEnabled(value: boolean);
  27123. /**
  27124. * Gets wether the color grading effect is enabled.
  27125. */
  27126. get cameraColorGradingEnabled(): boolean;
  27127. /**
  27128. * Gets wether the color grading effect is enabled.
  27129. */
  27130. set cameraColorGradingEnabled(value: boolean);
  27131. /**
  27132. * Gets wether tonemapping is enabled or not.
  27133. */
  27134. get cameraToneMappingEnabled(): boolean;
  27135. /**
  27136. * Sets wether tonemapping is enabled or not
  27137. */
  27138. set cameraToneMappingEnabled(value: boolean);
  27139. /**
  27140. * The camera exposure used on this material.
  27141. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27142. * This corresponds to a photographic exposure.
  27143. */
  27144. get cameraExposure(): number;
  27145. /**
  27146. * The camera exposure used on this material.
  27147. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27148. * This corresponds to a photographic exposure.
  27149. */
  27150. set cameraExposure(value: number);
  27151. /**
  27152. * Gets The camera contrast used on this material.
  27153. */
  27154. get cameraContrast(): number;
  27155. /**
  27156. * Sets The camera contrast used on this material.
  27157. */
  27158. set cameraContrast(value: number);
  27159. /**
  27160. * Gets the Color Grading 2D Lookup Texture.
  27161. */
  27162. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27163. /**
  27164. * Sets the Color Grading 2D Lookup Texture.
  27165. */
  27166. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27167. /**
  27168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27170. * 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;
  27171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27172. */
  27173. get cameraColorCurves(): Nullable<ColorCurves>;
  27174. /**
  27175. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27176. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27177. * 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;
  27178. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27179. */
  27180. set cameraColorCurves(value: Nullable<ColorCurves>);
  27181. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27182. protected _worldViewProjectionMatrix: Matrix;
  27183. protected _globalAmbientColor: Color3;
  27184. protected _useLogarithmicDepth: boolean;
  27185. protected _rebuildInParallel: boolean;
  27186. /**
  27187. * Instantiates a new standard material.
  27188. * This is the default material used in Babylon. It is the best trade off between quality
  27189. * and performances.
  27190. * @see http://doc.babylonjs.com/babylon101/materials
  27191. * @param name Define the name of the material in the scene
  27192. * @param scene Define the scene the material belong to
  27193. */
  27194. constructor(name: string, scene: Scene);
  27195. /**
  27196. * Gets a boolean indicating that current material needs to register RTT
  27197. */
  27198. get hasRenderTargetTextures(): boolean;
  27199. /**
  27200. * Gets the current class name of the material e.g. "StandardMaterial"
  27201. * Mainly use in serialization.
  27202. * @returns the class name
  27203. */
  27204. getClassName(): string;
  27205. /**
  27206. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27207. * You can try switching to logarithmic depth.
  27208. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27209. */
  27210. get useLogarithmicDepth(): boolean;
  27211. set useLogarithmicDepth(value: boolean);
  27212. /**
  27213. * Specifies if the material will require alpha blending
  27214. * @returns a boolean specifying if alpha blending is needed
  27215. */
  27216. needAlphaBlending(): boolean;
  27217. /**
  27218. * Specifies if this material should be rendered in alpha test mode
  27219. * @returns a boolean specifying if an alpha test is needed.
  27220. */
  27221. needAlphaTesting(): boolean;
  27222. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27223. /**
  27224. * Get the texture used for alpha test purpose.
  27225. * @returns the diffuse texture in case of the standard material.
  27226. */
  27227. getAlphaTestTexture(): Nullable<BaseTexture>;
  27228. /**
  27229. * Get if the submesh is ready to be used and all its information available.
  27230. * Child classes can use it to update shaders
  27231. * @param mesh defines the mesh to check
  27232. * @param subMesh defines which submesh to check
  27233. * @param useInstances specifies that instances should be used
  27234. * @returns a boolean indicating that the submesh is ready or not
  27235. */
  27236. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27237. /**
  27238. * Builds the material UBO layouts.
  27239. * Used internally during the effect preparation.
  27240. */
  27241. buildUniformLayout(): void;
  27242. /**
  27243. * Unbinds the material from the mesh
  27244. */
  27245. unbind(): void;
  27246. /**
  27247. * Binds the submesh to this material by preparing the effect and shader to draw
  27248. * @param world defines the world transformation matrix
  27249. * @param mesh defines the mesh containing the submesh
  27250. * @param subMesh defines the submesh to bind the material to
  27251. */
  27252. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27253. /**
  27254. * Get the list of animatables in the material.
  27255. * @returns the list of animatables object used in the material
  27256. */
  27257. getAnimatables(): IAnimatable[];
  27258. /**
  27259. * Gets the active textures from the material
  27260. * @returns an array of textures
  27261. */
  27262. getActiveTextures(): BaseTexture[];
  27263. /**
  27264. * Specifies if the material uses a texture
  27265. * @param texture defines the texture to check against the material
  27266. * @returns a boolean specifying if the material uses the texture
  27267. */
  27268. hasTexture(texture: BaseTexture): boolean;
  27269. /**
  27270. * Disposes the material
  27271. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27272. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27273. */
  27274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27275. /**
  27276. * Makes a duplicate of the material, and gives it a new name
  27277. * @param name defines the new name for the duplicated material
  27278. * @returns the cloned material
  27279. */
  27280. clone(name: string): StandardMaterial;
  27281. /**
  27282. * Serializes this material in a JSON representation
  27283. * @returns the serialized material object
  27284. */
  27285. serialize(): any;
  27286. /**
  27287. * Creates a standard material from parsed material data
  27288. * @param source defines the JSON representation of the material
  27289. * @param scene defines the hosting scene
  27290. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27291. * @returns a new standard material
  27292. */
  27293. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27294. /**
  27295. * Are diffuse textures enabled in the application.
  27296. */
  27297. static get DiffuseTextureEnabled(): boolean;
  27298. static set DiffuseTextureEnabled(value: boolean);
  27299. /**
  27300. * Are ambient textures enabled in the application.
  27301. */
  27302. static get AmbientTextureEnabled(): boolean;
  27303. static set AmbientTextureEnabled(value: boolean);
  27304. /**
  27305. * Are opacity textures enabled in the application.
  27306. */
  27307. static get OpacityTextureEnabled(): boolean;
  27308. static set OpacityTextureEnabled(value: boolean);
  27309. /**
  27310. * Are reflection textures enabled in the application.
  27311. */
  27312. static get ReflectionTextureEnabled(): boolean;
  27313. static set ReflectionTextureEnabled(value: boolean);
  27314. /**
  27315. * Are emissive textures enabled in the application.
  27316. */
  27317. static get EmissiveTextureEnabled(): boolean;
  27318. static set EmissiveTextureEnabled(value: boolean);
  27319. /**
  27320. * Are specular textures enabled in the application.
  27321. */
  27322. static get SpecularTextureEnabled(): boolean;
  27323. static set SpecularTextureEnabled(value: boolean);
  27324. /**
  27325. * Are bump textures enabled in the application.
  27326. */
  27327. static get BumpTextureEnabled(): boolean;
  27328. static set BumpTextureEnabled(value: boolean);
  27329. /**
  27330. * Are lightmap textures enabled in the application.
  27331. */
  27332. static get LightmapTextureEnabled(): boolean;
  27333. static set LightmapTextureEnabled(value: boolean);
  27334. /**
  27335. * Are refraction textures enabled in the application.
  27336. */
  27337. static get RefractionTextureEnabled(): boolean;
  27338. static set RefractionTextureEnabled(value: boolean);
  27339. /**
  27340. * Are color grading textures enabled in the application.
  27341. */
  27342. static get ColorGradingTextureEnabled(): boolean;
  27343. static set ColorGradingTextureEnabled(value: boolean);
  27344. /**
  27345. * Are fresnels enabled in the application.
  27346. */
  27347. static get FresnelEnabled(): boolean;
  27348. static set FresnelEnabled(value: boolean);
  27349. }
  27350. }
  27351. declare module BABYLON {
  27352. /**
  27353. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27354. *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.
  27355. * The SPS is also a particle system. It provides some methods to manage the particles.
  27356. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27357. *
  27358. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27359. */
  27360. export class SolidParticleSystem implements IDisposable {
  27361. /**
  27362. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27363. * Example : var p = SPS.particles[i];
  27364. */
  27365. particles: SolidParticle[];
  27366. /**
  27367. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27368. */
  27369. nbParticles: number;
  27370. /**
  27371. * If the particles must ever face the camera (default false). Useful for planar particles.
  27372. */
  27373. billboard: boolean;
  27374. /**
  27375. * Recompute normals when adding a shape
  27376. */
  27377. recomputeNormals: boolean;
  27378. /**
  27379. * This a counter ofr your own usage. It's not set by any SPS functions.
  27380. */
  27381. counter: number;
  27382. /**
  27383. * The SPS name. This name is also given to the underlying mesh.
  27384. */
  27385. name: string;
  27386. /**
  27387. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27388. */
  27389. mesh: Mesh;
  27390. /**
  27391. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27392. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27393. */
  27394. vars: any;
  27395. /**
  27396. * This array is populated when the SPS is set as 'pickable'.
  27397. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27398. * Each element of this array is an object `{idx: int, faceId: int}`.
  27399. * `idx` is the picked particle index in the `SPS.particles` array
  27400. * `faceId` is the picked face index counted within this particle.
  27401. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27402. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27403. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27404. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27405. */
  27406. pickedParticles: {
  27407. idx: number;
  27408. faceId: number;
  27409. }[];
  27410. /**
  27411. * This array is populated when the SPS is set as 'pickable'
  27412. * Each key of this array is a submesh index.
  27413. * Each element of this array is a second array defined like this :
  27414. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27415. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27416. * `idx` is the picked particle index in the `SPS.particles` array
  27417. * `faceId` is the picked face index counted within this particle.
  27418. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27419. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27420. */
  27421. pickedBySubMesh: {
  27422. idx: number;
  27423. faceId: number;
  27424. }[][];
  27425. /**
  27426. * This array is populated when `enableDepthSort` is set to true.
  27427. * Each element of this array is an instance of the class DepthSortedParticle.
  27428. */
  27429. depthSortedParticles: DepthSortedParticle[];
  27430. /**
  27431. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27432. * @hidden
  27433. */
  27434. _bSphereOnly: boolean;
  27435. /**
  27436. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27437. * @hidden
  27438. */
  27439. _bSphereRadiusFactor: number;
  27440. private _scene;
  27441. private _positions;
  27442. private _indices;
  27443. private _normals;
  27444. private _colors;
  27445. private _uvs;
  27446. private _indices32;
  27447. private _positions32;
  27448. private _normals32;
  27449. private _fixedNormal32;
  27450. private _colors32;
  27451. private _uvs32;
  27452. private _index;
  27453. private _updatable;
  27454. private _pickable;
  27455. private _isVisibilityBoxLocked;
  27456. private _alwaysVisible;
  27457. private _depthSort;
  27458. private _expandable;
  27459. private _shapeCounter;
  27460. private _copy;
  27461. private _color;
  27462. private _computeParticleColor;
  27463. private _computeParticleTexture;
  27464. private _computeParticleRotation;
  27465. private _computeParticleVertex;
  27466. private _computeBoundingBox;
  27467. private _depthSortParticles;
  27468. private _camera;
  27469. private _mustUnrotateFixedNormals;
  27470. private _particlesIntersect;
  27471. private _needs32Bits;
  27472. private _isNotBuilt;
  27473. private _lastParticleId;
  27474. private _idxOfId;
  27475. private _multimaterialEnabled;
  27476. private _useModelMaterial;
  27477. private _indicesByMaterial;
  27478. private _materialIndexes;
  27479. private _depthSortFunction;
  27480. private _materialSortFunction;
  27481. private _materials;
  27482. private _multimaterial;
  27483. private _materialIndexesById;
  27484. private _defaultMaterial;
  27485. private _autoUpdateSubMeshes;
  27486. /**
  27487. * Creates a SPS (Solid Particle System) object.
  27488. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27489. * @param scene (Scene) is the scene in which the SPS is added.
  27490. * @param options defines the options of the sps e.g.
  27491. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27492. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27493. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27494. * * 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.
  27495. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27496. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27497. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27498. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27499. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27500. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27501. */
  27502. constructor(name: string, scene: Scene, options?: {
  27503. updatable?: boolean;
  27504. isPickable?: boolean;
  27505. enableDepthSort?: boolean;
  27506. particleIntersection?: boolean;
  27507. boundingSphereOnly?: boolean;
  27508. bSphereRadiusFactor?: number;
  27509. expandable?: boolean;
  27510. useModelMaterial?: boolean;
  27511. enableMultiMaterial?: boolean;
  27512. });
  27513. /**
  27514. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27515. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27516. * @returns the created mesh
  27517. */
  27518. buildMesh(): Mesh;
  27519. /**
  27520. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27521. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27522. * Thus the particles generated from `digest()` have their property `position` set yet.
  27523. * @param mesh ( Mesh ) is the mesh to be digested
  27524. * @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
  27525. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27526. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27527. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27528. * @returns the current SPS
  27529. */
  27530. digest(mesh: Mesh, options?: {
  27531. facetNb?: number;
  27532. number?: number;
  27533. delta?: number;
  27534. storage?: [];
  27535. }): SolidParticleSystem;
  27536. /**
  27537. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27538. * @hidden
  27539. */
  27540. private _unrotateFixedNormals;
  27541. /**
  27542. * Resets the temporary working copy particle
  27543. * @hidden
  27544. */
  27545. private _resetCopy;
  27546. /**
  27547. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27548. * @param p the current index in the positions array to be updated
  27549. * @param ind the current index in the indices array
  27550. * @param shape a Vector3 array, the shape geometry
  27551. * @param positions the positions array to be updated
  27552. * @param meshInd the shape indices array
  27553. * @param indices the indices array to be updated
  27554. * @param meshUV the shape uv array
  27555. * @param uvs the uv array to be updated
  27556. * @param meshCol the shape color array
  27557. * @param colors the color array to be updated
  27558. * @param meshNor the shape normals array
  27559. * @param normals the normals array to be updated
  27560. * @param idx the particle index
  27561. * @param idxInShape the particle index in its shape
  27562. * @param options the addShape() method passed options
  27563. * @model the particle model
  27564. * @hidden
  27565. */
  27566. private _meshBuilder;
  27567. /**
  27568. * Returns a shape Vector3 array from positions float array
  27569. * @param positions float array
  27570. * @returns a vector3 array
  27571. * @hidden
  27572. */
  27573. private _posToShape;
  27574. /**
  27575. * Returns a shapeUV array from a float uvs (array deep copy)
  27576. * @param uvs as a float array
  27577. * @returns a shapeUV array
  27578. * @hidden
  27579. */
  27580. private _uvsToShapeUV;
  27581. /**
  27582. * Adds a new particle object in the particles array
  27583. * @param idx particle index in particles array
  27584. * @param id particle id
  27585. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27586. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27587. * @param model particle ModelShape object
  27588. * @param shapeId model shape identifier
  27589. * @param idxInShape index of the particle in the current model
  27590. * @param bInfo model bounding info object
  27591. * @param storage target storage array, if any
  27592. * @hidden
  27593. */
  27594. private _addParticle;
  27595. /**
  27596. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27597. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27598. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27599. * @param nb (positive integer) the number of particles to be created from this model
  27600. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27601. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27602. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27603. * @returns the number of shapes in the system
  27604. */
  27605. addShape(mesh: Mesh, nb: number, options?: {
  27606. positionFunction?: any;
  27607. vertexFunction?: any;
  27608. storage?: [];
  27609. }): number;
  27610. /**
  27611. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27612. * @hidden
  27613. */
  27614. private _rebuildParticle;
  27615. /**
  27616. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27617. * @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.
  27618. * @returns the SPS.
  27619. */
  27620. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27621. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27622. * Returns an array with the removed particles.
  27623. * 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.
  27624. * The SPS can't be empty so at least one particle needs to remain in place.
  27625. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27626. * @param start index of the first particle to remove
  27627. * @param end index of the last particle to remove (included)
  27628. * @returns an array populated with the removed particles
  27629. */
  27630. removeParticles(start: number, end: number): SolidParticle[];
  27631. /**
  27632. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27633. * @param solidParticleArray an array populated with Solid Particles objects
  27634. * @returns the SPS
  27635. */
  27636. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27637. /**
  27638. * Creates a new particle and modifies the SPS mesh geometry :
  27639. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27640. * - calls _addParticle() to populate the particle array
  27641. * factorized code from addShape() and insertParticlesFromArray()
  27642. * @param idx particle index in the particles array
  27643. * @param i particle index in its shape
  27644. * @param modelShape particle ModelShape object
  27645. * @param shape shape vertex array
  27646. * @param meshInd shape indices array
  27647. * @param meshUV shape uv array
  27648. * @param meshCol shape color array
  27649. * @param meshNor shape normals array
  27650. * @param bbInfo shape bounding info
  27651. * @param storage target particle storage
  27652. * @options addShape() passed options
  27653. * @hidden
  27654. */
  27655. private _insertNewParticle;
  27656. /**
  27657. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27658. * This method calls `updateParticle()` for each particle of the SPS.
  27659. * For an animated SPS, it is usually called within the render loop.
  27660. * 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.
  27661. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27662. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27663. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27664. * @returns the SPS.
  27665. */
  27666. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27667. /**
  27668. * Disposes the SPS.
  27669. */
  27670. dispose(): void;
  27671. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27672. * idx is the particle index in the SPS
  27673. * faceId is the picked face index counted within this particle.
  27674. * Returns null if the pickInfo can't identify a picked particle.
  27675. * @param pickingInfo (PickingInfo object)
  27676. * @returns {idx: number, faceId: number} or null
  27677. */
  27678. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27679. idx: number;
  27680. faceId: number;
  27681. }>;
  27682. /**
  27683. * Returns a SolidParticle object from its identifier : particle.id
  27684. * @param id (integer) the particle Id
  27685. * @returns the searched particle or null if not found in the SPS.
  27686. */
  27687. getParticleById(id: number): Nullable<SolidParticle>;
  27688. /**
  27689. * Returns a new array populated with the particles having the passed shapeId.
  27690. * @param shapeId (integer) the shape identifier
  27691. * @returns a new solid particle array
  27692. */
  27693. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27694. /**
  27695. * Populates the passed array "ref" with the particles having the passed shapeId.
  27696. * @param shapeId the shape identifier
  27697. * @returns the SPS
  27698. * @param ref
  27699. */
  27700. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27701. /**
  27702. * Computes the required SubMeshes according the materials assigned to the particles.
  27703. * @returns the solid particle system.
  27704. * Does nothing if called before the SPS mesh is built.
  27705. */
  27706. computeSubMeshes(): SolidParticleSystem;
  27707. /**
  27708. * Sorts the solid particles by material when MultiMaterial is enabled.
  27709. * Updates the indices32 array.
  27710. * Updates the indicesByMaterial array.
  27711. * Updates the mesh indices array.
  27712. * @returns the SPS
  27713. * @hidden
  27714. */
  27715. private _sortParticlesByMaterial;
  27716. /**
  27717. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27718. * @hidden
  27719. */
  27720. private _setMaterialIndexesById;
  27721. /**
  27722. * Returns an array with unique values of Materials from the passed array
  27723. * @param array the material array to be checked and filtered
  27724. * @hidden
  27725. */
  27726. private _filterUniqueMaterialId;
  27727. /**
  27728. * Sets a new Standard Material as _defaultMaterial if not already set.
  27729. * @hidden
  27730. */
  27731. private _setDefaultMaterial;
  27732. /**
  27733. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27734. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27735. * @returns the SPS.
  27736. */
  27737. refreshVisibleSize(): SolidParticleSystem;
  27738. /**
  27739. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27740. * @param size the size (float) of the visibility box
  27741. * note : this doesn't lock the SPS mesh bounding box.
  27742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27743. */
  27744. setVisibilityBox(size: number): void;
  27745. /**
  27746. * Gets whether the SPS as always visible or not
  27747. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27748. */
  27749. get isAlwaysVisible(): boolean;
  27750. /**
  27751. * Sets the SPS as always visible or not
  27752. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27753. */
  27754. set isAlwaysVisible(val: boolean);
  27755. /**
  27756. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27757. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27758. */
  27759. set isVisibilityBoxLocked(val: boolean);
  27760. /**
  27761. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27762. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27763. */
  27764. get isVisibilityBoxLocked(): boolean;
  27765. /**
  27766. * Tells to `setParticles()` to compute the particle rotations or not.
  27767. * Default value : true. The SPS is faster when it's set to false.
  27768. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27769. */
  27770. set computeParticleRotation(val: boolean);
  27771. /**
  27772. * Tells to `setParticles()` to compute the particle colors or not.
  27773. * Default value : true. The SPS is faster when it's set to false.
  27774. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27775. */
  27776. set computeParticleColor(val: boolean);
  27777. set computeParticleTexture(val: boolean);
  27778. /**
  27779. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27780. * Default value : false. The SPS is faster when it's set to false.
  27781. * Note : the particle custom vertex positions aren't stored values.
  27782. */
  27783. set computeParticleVertex(val: boolean);
  27784. /**
  27785. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27786. */
  27787. set computeBoundingBox(val: boolean);
  27788. /**
  27789. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27790. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27791. * Default : `true`
  27792. */
  27793. set depthSortParticles(val: boolean);
  27794. /**
  27795. * Gets if `setParticles()` computes the particle rotations or not.
  27796. * Default value : true. The SPS is faster when it's set to false.
  27797. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27798. */
  27799. get computeParticleRotation(): boolean;
  27800. /**
  27801. * Gets if `setParticles()` computes the particle colors or not.
  27802. * Default value : true. The SPS is faster when it's set to false.
  27803. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27804. */
  27805. get computeParticleColor(): boolean;
  27806. /**
  27807. * Gets if `setParticles()` computes the particle textures or not.
  27808. * Default value : true. The SPS is faster when it's set to false.
  27809. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27810. */
  27811. get computeParticleTexture(): boolean;
  27812. /**
  27813. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27814. * Default value : false. The SPS is faster when it's set to false.
  27815. * Note : the particle custom vertex positions aren't stored values.
  27816. */
  27817. get computeParticleVertex(): boolean;
  27818. /**
  27819. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27820. */
  27821. get computeBoundingBox(): boolean;
  27822. /**
  27823. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27824. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27825. * Default : `true`
  27826. */
  27827. get depthSortParticles(): boolean;
  27828. /**
  27829. * Gets if the SPS is created as expandable at construction time.
  27830. * Default : `false`
  27831. */
  27832. get expandable(): boolean;
  27833. /**
  27834. * Gets if the SPS supports the Multi Materials
  27835. */
  27836. get multimaterialEnabled(): boolean;
  27837. /**
  27838. * Gets if the SPS uses the model materials for its own multimaterial.
  27839. */
  27840. get useModelMaterial(): boolean;
  27841. /**
  27842. * The SPS used material array.
  27843. */
  27844. get materials(): Material[];
  27845. /**
  27846. * Sets the SPS MultiMaterial from the passed materials.
  27847. * Note : the passed array is internally copied and not used then by reference.
  27848. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27849. */
  27850. setMultiMaterial(materials: Material[]): void;
  27851. /**
  27852. * The SPS computed multimaterial object
  27853. */
  27854. get multimaterial(): MultiMaterial;
  27855. set multimaterial(mm: MultiMaterial);
  27856. /**
  27857. * If the subMeshes must be updated on the next call to setParticles()
  27858. */
  27859. get autoUpdateSubMeshes(): boolean;
  27860. set autoUpdateSubMeshes(val: boolean);
  27861. /**
  27862. * This function does nothing. It may be overwritten to set all the particle first values.
  27863. * The SPS doesn't call this function, you may have to call it by your own.
  27864. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27865. */
  27866. initParticles(): void;
  27867. /**
  27868. * This function does nothing. It may be overwritten to recycle a particle.
  27869. * The SPS doesn't call this function, you may have to call it by your own.
  27870. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27871. * @param particle The particle to recycle
  27872. * @returns the recycled particle
  27873. */
  27874. recycleParticle(particle: SolidParticle): SolidParticle;
  27875. /**
  27876. * Updates a particle : this function should be overwritten by the user.
  27877. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27878. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27879. * @example : just set a particle position or velocity and recycle conditions
  27880. * @param particle The particle to update
  27881. * @returns the updated particle
  27882. */
  27883. updateParticle(particle: SolidParticle): SolidParticle;
  27884. /**
  27885. * Updates a vertex of a particle : it can be overwritten by the user.
  27886. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27887. * @param particle the current particle
  27888. * @param vertex the current index of the current particle
  27889. * @param pt the index of the current vertex in the particle shape
  27890. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27891. * @example : just set a vertex particle position
  27892. * @returns the updated vertex
  27893. */
  27894. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27895. /**
  27896. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27897. * This does nothing and may be overwritten by the user.
  27898. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27899. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27900. * @param update the boolean update value actually passed to setParticles()
  27901. */
  27902. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27903. /**
  27904. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27905. * This will be passed three parameters.
  27906. * This does nothing and may be overwritten by the user.
  27907. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27908. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27909. * @param update the boolean update value actually passed to setParticles()
  27910. */
  27911. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27912. }
  27913. }
  27914. declare module BABYLON {
  27915. /**
  27916. * Represents one particle of a solid particle system.
  27917. */
  27918. export class SolidParticle {
  27919. /**
  27920. * particle global index
  27921. */
  27922. idx: number;
  27923. /**
  27924. * particle identifier
  27925. */
  27926. id: number;
  27927. /**
  27928. * The color of the particle
  27929. */
  27930. color: Nullable<Color4>;
  27931. /**
  27932. * The world space position of the particle.
  27933. */
  27934. position: Vector3;
  27935. /**
  27936. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27937. */
  27938. rotation: Vector3;
  27939. /**
  27940. * The world space rotation quaternion of the particle.
  27941. */
  27942. rotationQuaternion: Nullable<Quaternion>;
  27943. /**
  27944. * The scaling of the particle.
  27945. */
  27946. scaling: Vector3;
  27947. /**
  27948. * The uvs of the particle.
  27949. */
  27950. uvs: Vector4;
  27951. /**
  27952. * The current speed of the particle.
  27953. */
  27954. velocity: Vector3;
  27955. /**
  27956. * The pivot point in the particle local space.
  27957. */
  27958. pivot: Vector3;
  27959. /**
  27960. * Must the particle be translated from its pivot point in its local space ?
  27961. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27962. * Default : false
  27963. */
  27964. translateFromPivot: boolean;
  27965. /**
  27966. * Is the particle active or not ?
  27967. */
  27968. alive: boolean;
  27969. /**
  27970. * Is the particle visible or not ?
  27971. */
  27972. isVisible: boolean;
  27973. /**
  27974. * Index of this particle in the global "positions" array (Internal use)
  27975. * @hidden
  27976. */
  27977. _pos: number;
  27978. /**
  27979. * @hidden Index of this particle in the global "indices" array (Internal use)
  27980. */
  27981. _ind: number;
  27982. /**
  27983. * @hidden ModelShape of this particle (Internal use)
  27984. */
  27985. _model: ModelShape;
  27986. /**
  27987. * ModelShape id of this particle
  27988. */
  27989. shapeId: number;
  27990. /**
  27991. * Index of the particle in its shape id
  27992. */
  27993. idxInShape: number;
  27994. /**
  27995. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27996. */
  27997. _modelBoundingInfo: BoundingInfo;
  27998. /**
  27999. * @hidden Particle BoundingInfo object (Internal use)
  28000. */
  28001. _boundingInfo: BoundingInfo;
  28002. /**
  28003. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28004. */
  28005. _sps: SolidParticleSystem;
  28006. /**
  28007. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28008. */
  28009. _stillInvisible: boolean;
  28010. /**
  28011. * @hidden Last computed particle rotation matrix
  28012. */
  28013. _rotationMatrix: number[];
  28014. /**
  28015. * Parent particle Id, if any.
  28016. * Default null.
  28017. */
  28018. parentId: Nullable<number>;
  28019. /**
  28020. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28021. */
  28022. materialIndex: Nullable<number>;
  28023. /**
  28024. * Custom object or properties.
  28025. */
  28026. props: Nullable<any>;
  28027. /**
  28028. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28029. * The possible values are :
  28030. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28031. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28033. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28034. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28035. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28036. * */
  28037. cullingStrategy: number;
  28038. /**
  28039. * @hidden Internal global position in the SPS.
  28040. */
  28041. _globalPosition: Vector3;
  28042. /**
  28043. * Creates a Solid Particle object.
  28044. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28045. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28046. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28047. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28048. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28049. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28050. * @param shapeId (integer) is the model shape identifier in the SPS.
  28051. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28052. * @param sps defines the sps it is associated to
  28053. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28054. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28055. */
  28056. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28057. /**
  28058. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28059. * @param target the particle target
  28060. * @returns the current particle
  28061. */
  28062. copyToRef(target: SolidParticle): SolidParticle;
  28063. /**
  28064. * Legacy support, changed scale to scaling
  28065. */
  28066. get scale(): Vector3;
  28067. /**
  28068. * Legacy support, changed scale to scaling
  28069. */
  28070. set scale(scale: Vector3);
  28071. /**
  28072. * Legacy support, changed quaternion to rotationQuaternion
  28073. */
  28074. get quaternion(): Nullable<Quaternion>;
  28075. /**
  28076. * Legacy support, changed quaternion to rotationQuaternion
  28077. */
  28078. set quaternion(q: Nullable<Quaternion>);
  28079. /**
  28080. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28081. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28082. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28083. * @returns true if it intersects
  28084. */
  28085. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28086. /**
  28087. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28088. * A particle is in the frustum if its bounding box intersects the frustum
  28089. * @param frustumPlanes defines the frustum to test
  28090. * @returns true if the particle is in the frustum planes
  28091. */
  28092. isInFrustum(frustumPlanes: Plane[]): boolean;
  28093. /**
  28094. * get the rotation matrix of the particle
  28095. * @hidden
  28096. */
  28097. getRotationMatrix(m: Matrix): void;
  28098. }
  28099. /**
  28100. * Represents the shape of the model used by one particle of a solid particle system.
  28101. * SPS internal tool, don't use it manually.
  28102. */
  28103. export class ModelShape {
  28104. /**
  28105. * The shape id
  28106. * @hidden
  28107. */
  28108. shapeID: number;
  28109. /**
  28110. * flat array of model positions (internal use)
  28111. * @hidden
  28112. */
  28113. _shape: Vector3[];
  28114. /**
  28115. * flat array of model UVs (internal use)
  28116. * @hidden
  28117. */
  28118. _shapeUV: number[];
  28119. /**
  28120. * color array of the model
  28121. * @hidden
  28122. */
  28123. _shapeColors: number[];
  28124. /**
  28125. * indices array of the model
  28126. * @hidden
  28127. */
  28128. _indices: number[];
  28129. /**
  28130. * normals array of the model
  28131. * @hidden
  28132. */
  28133. _normals: number[];
  28134. /**
  28135. * length of the shape in the model indices array (internal use)
  28136. * @hidden
  28137. */
  28138. _indicesLength: number;
  28139. /**
  28140. * Custom position function (internal use)
  28141. * @hidden
  28142. */
  28143. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28144. /**
  28145. * Custom vertex function (internal use)
  28146. * @hidden
  28147. */
  28148. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28149. /**
  28150. * Model material (internal use)
  28151. * @hidden
  28152. */
  28153. _material: Nullable<Material>;
  28154. /**
  28155. * 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.
  28156. * SPS internal tool, don't use it manually.
  28157. * @hidden
  28158. */
  28159. 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>);
  28160. }
  28161. /**
  28162. * Represents a Depth Sorted Particle in the solid particle system.
  28163. * @hidden
  28164. */
  28165. export class DepthSortedParticle {
  28166. /**
  28167. * Particle index
  28168. */
  28169. idx: number;
  28170. /**
  28171. * Index of the particle in the "indices" array
  28172. */
  28173. ind: number;
  28174. /**
  28175. * Length of the particle shape in the "indices" array
  28176. */
  28177. indicesLength: number;
  28178. /**
  28179. * Squared distance from the particle to the camera
  28180. */
  28181. sqDistance: number;
  28182. /**
  28183. * Material index when used with MultiMaterials
  28184. */
  28185. materialIndex: number;
  28186. /**
  28187. * Creates a new sorted particle
  28188. * @param materialIndex
  28189. */
  28190. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28191. }
  28192. }
  28193. declare module BABYLON {
  28194. /**
  28195. * @hidden
  28196. */
  28197. export class _MeshCollisionData {
  28198. _checkCollisions: boolean;
  28199. _collisionMask: number;
  28200. _collisionGroup: number;
  28201. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28202. _collider: Nullable<Collider>;
  28203. _oldPositionForCollisions: Vector3;
  28204. _diffPositionForCollisions: Vector3;
  28205. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28206. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28207. }
  28208. }
  28209. declare module BABYLON {
  28210. /** @hidden */
  28211. class _FacetDataStorage {
  28212. facetPositions: Vector3[];
  28213. facetNormals: Vector3[];
  28214. facetPartitioning: number[][];
  28215. facetNb: number;
  28216. partitioningSubdivisions: number;
  28217. partitioningBBoxRatio: number;
  28218. facetDataEnabled: boolean;
  28219. facetParameters: any;
  28220. bbSize: Vector3;
  28221. subDiv: {
  28222. max: number;
  28223. X: number;
  28224. Y: number;
  28225. Z: number;
  28226. };
  28227. facetDepthSort: boolean;
  28228. facetDepthSortEnabled: boolean;
  28229. depthSortedIndices: IndicesArray;
  28230. depthSortedFacets: {
  28231. ind: number;
  28232. sqDistance: number;
  28233. }[];
  28234. facetDepthSortFunction: (f1: {
  28235. ind: number;
  28236. sqDistance: number;
  28237. }, f2: {
  28238. ind: number;
  28239. sqDistance: number;
  28240. }) => number;
  28241. facetDepthSortFrom: Vector3;
  28242. facetDepthSortOrigin: Vector3;
  28243. invertedMatrix: Matrix;
  28244. }
  28245. /**
  28246. * @hidden
  28247. **/
  28248. class _InternalAbstractMeshDataInfo {
  28249. _hasVertexAlpha: boolean;
  28250. _useVertexColors: boolean;
  28251. _numBoneInfluencers: number;
  28252. _applyFog: boolean;
  28253. _receiveShadows: boolean;
  28254. _facetData: _FacetDataStorage;
  28255. _visibility: number;
  28256. _skeleton: Nullable<Skeleton>;
  28257. _layerMask: number;
  28258. _computeBonesUsingShaders: boolean;
  28259. _isActive: boolean;
  28260. _onlyForInstances: boolean;
  28261. _isActiveIntermediate: boolean;
  28262. _onlyForInstancesIntermediate: boolean;
  28263. _actAsRegularMesh: boolean;
  28264. }
  28265. /**
  28266. * Class used to store all common mesh properties
  28267. */
  28268. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28269. /** No occlusion */
  28270. static OCCLUSION_TYPE_NONE: number;
  28271. /** Occlusion set to optimisitic */
  28272. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28273. /** Occlusion set to strict */
  28274. static OCCLUSION_TYPE_STRICT: number;
  28275. /** Use an accurante occlusion algorithm */
  28276. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28277. /** Use a conservative occlusion algorithm */
  28278. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28279. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28280. * Test order :
  28281. * Is the bounding sphere outside the frustum ?
  28282. * If not, are the bounding box vertices outside the frustum ?
  28283. * It not, then the cullable object is in the frustum.
  28284. */
  28285. static readonly CULLINGSTRATEGY_STANDARD: number;
  28286. /** Culling strategy : Bounding Sphere Only.
  28287. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28288. * It's also less accurate than the standard because some not visible objects can still be selected.
  28289. * Test : is the bounding sphere outside the frustum ?
  28290. * If not, then the cullable object is in the frustum.
  28291. */
  28292. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28293. /** Culling strategy : Optimistic Inclusion.
  28294. * This in an inclusion test first, then the standard exclusion test.
  28295. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28296. * 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.
  28297. * Anyway, it's as accurate as the standard strategy.
  28298. * Test :
  28299. * Is the cullable object bounding sphere center in the frustum ?
  28300. * If not, apply the default culling strategy.
  28301. */
  28302. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28303. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28304. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28305. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28306. * 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.
  28307. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28308. * Test :
  28309. * Is the cullable object bounding sphere center in the frustum ?
  28310. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28311. */
  28312. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28313. /**
  28314. * No billboard
  28315. */
  28316. static get BILLBOARDMODE_NONE(): number;
  28317. /** Billboard on X axis */
  28318. static get BILLBOARDMODE_X(): number;
  28319. /** Billboard on Y axis */
  28320. static get BILLBOARDMODE_Y(): number;
  28321. /** Billboard on Z axis */
  28322. static get BILLBOARDMODE_Z(): number;
  28323. /** Billboard on all axes */
  28324. static get BILLBOARDMODE_ALL(): number;
  28325. /** Billboard on using position instead of orientation */
  28326. static get BILLBOARDMODE_USE_POSITION(): number;
  28327. /** @hidden */
  28328. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28329. /**
  28330. * The culling strategy to use to check whether the mesh must be rendered or not.
  28331. * This value can be changed at any time and will be used on the next render mesh selection.
  28332. * The possible values are :
  28333. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28334. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28335. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28336. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28337. * Please read each static variable documentation to get details about the culling process.
  28338. * */
  28339. cullingStrategy: number;
  28340. /**
  28341. * Gets the number of facets in the mesh
  28342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28343. */
  28344. get facetNb(): number;
  28345. /**
  28346. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28347. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28348. */
  28349. get partitioningSubdivisions(): number;
  28350. set partitioningSubdivisions(nb: number);
  28351. /**
  28352. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28353. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28355. */
  28356. get partitioningBBoxRatio(): number;
  28357. set partitioningBBoxRatio(ratio: number);
  28358. /**
  28359. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28360. * Works only for updatable meshes.
  28361. * Doesn't work with multi-materials
  28362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28363. */
  28364. get mustDepthSortFacets(): boolean;
  28365. set mustDepthSortFacets(sort: boolean);
  28366. /**
  28367. * The location (Vector3) where the facet depth sort must be computed from.
  28368. * By default, the active camera position.
  28369. * Used only when facet depth sort is enabled
  28370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28371. */
  28372. get facetDepthSortFrom(): Vector3;
  28373. set facetDepthSortFrom(location: Vector3);
  28374. /**
  28375. * gets a boolean indicating if facetData is enabled
  28376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28377. */
  28378. get isFacetDataEnabled(): boolean;
  28379. /** @hidden */
  28380. _updateNonUniformScalingState(value: boolean): boolean;
  28381. /**
  28382. * An event triggered when this mesh collides with another one
  28383. */
  28384. onCollideObservable: Observable<AbstractMesh>;
  28385. /** Set a function to call when this mesh collides with another one */
  28386. set onCollide(callback: () => void);
  28387. /**
  28388. * An event triggered when the collision's position changes
  28389. */
  28390. onCollisionPositionChangeObservable: Observable<Vector3>;
  28391. /** Set a function to call when the collision's position changes */
  28392. set onCollisionPositionChange(callback: () => void);
  28393. /**
  28394. * An event triggered when material is changed
  28395. */
  28396. onMaterialChangedObservable: Observable<AbstractMesh>;
  28397. /**
  28398. * Gets or sets the orientation for POV movement & rotation
  28399. */
  28400. definedFacingForward: boolean;
  28401. /** @hidden */
  28402. _occlusionQuery: Nullable<WebGLQuery>;
  28403. /** @hidden */
  28404. _renderingGroup: Nullable<RenderingGroup>;
  28405. /**
  28406. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28407. */
  28408. get visibility(): number;
  28409. /**
  28410. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28411. */
  28412. set visibility(value: number);
  28413. /** Gets or sets the alpha index used to sort transparent meshes
  28414. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28415. */
  28416. alphaIndex: number;
  28417. /**
  28418. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28419. */
  28420. isVisible: boolean;
  28421. /**
  28422. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28423. */
  28424. isPickable: boolean;
  28425. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28426. showSubMeshesBoundingBox: boolean;
  28427. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28428. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28429. */
  28430. isBlocker: boolean;
  28431. /**
  28432. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28433. */
  28434. enablePointerMoveEvents: boolean;
  28435. /**
  28436. * Specifies the rendering group id for this mesh (0 by default)
  28437. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28438. */
  28439. renderingGroupId: number;
  28440. private _material;
  28441. /** Gets or sets current material */
  28442. get material(): Nullable<Material>;
  28443. set material(value: Nullable<Material>);
  28444. /**
  28445. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28446. * @see http://doc.babylonjs.com/babylon101/shadows
  28447. */
  28448. get receiveShadows(): boolean;
  28449. set receiveShadows(value: boolean);
  28450. /** Defines color to use when rendering outline */
  28451. outlineColor: Color3;
  28452. /** Define width to use when rendering outline */
  28453. outlineWidth: number;
  28454. /** Defines color to use when rendering overlay */
  28455. overlayColor: Color3;
  28456. /** Defines alpha to use when rendering overlay */
  28457. overlayAlpha: number;
  28458. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28459. get hasVertexAlpha(): boolean;
  28460. set hasVertexAlpha(value: boolean);
  28461. /** 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) */
  28462. get useVertexColors(): boolean;
  28463. set useVertexColors(value: boolean);
  28464. /**
  28465. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28466. */
  28467. get computeBonesUsingShaders(): boolean;
  28468. set computeBonesUsingShaders(value: boolean);
  28469. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28470. get numBoneInfluencers(): number;
  28471. set numBoneInfluencers(value: number);
  28472. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28473. get applyFog(): boolean;
  28474. set applyFog(value: boolean);
  28475. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28476. useOctreeForRenderingSelection: boolean;
  28477. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28478. useOctreeForPicking: boolean;
  28479. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28480. useOctreeForCollisions: boolean;
  28481. /**
  28482. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28483. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28484. */
  28485. get layerMask(): number;
  28486. set layerMask(value: number);
  28487. /**
  28488. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28489. */
  28490. alwaysSelectAsActiveMesh: boolean;
  28491. /**
  28492. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28493. */
  28494. doNotSyncBoundingInfo: boolean;
  28495. /**
  28496. * Gets or sets the current action manager
  28497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28498. */
  28499. actionManager: Nullable<AbstractActionManager>;
  28500. private _meshCollisionData;
  28501. /**
  28502. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28503. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28504. */
  28505. ellipsoid: Vector3;
  28506. /**
  28507. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28508. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28509. */
  28510. ellipsoidOffset: Vector3;
  28511. /**
  28512. * Gets or sets a collision mask used to mask collisions (default is -1).
  28513. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28514. */
  28515. get collisionMask(): number;
  28516. set collisionMask(mask: number);
  28517. /**
  28518. * Gets or sets the current collision group mask (-1 by default).
  28519. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28520. */
  28521. get collisionGroup(): number;
  28522. set collisionGroup(mask: number);
  28523. /**
  28524. * Gets or sets current surrounding meshes (null by default).
  28525. *
  28526. * By default collision detection is tested against every mesh in the scene.
  28527. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28528. * meshes will be tested for the collision.
  28529. *
  28530. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28531. */
  28532. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28533. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28534. /**
  28535. * Defines edge width used when edgesRenderer is enabled
  28536. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28537. */
  28538. edgesWidth: number;
  28539. /**
  28540. * Defines edge color used when edgesRenderer is enabled
  28541. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28542. */
  28543. edgesColor: Color4;
  28544. /** @hidden */
  28545. _edgesRenderer: Nullable<IEdgesRenderer>;
  28546. /** @hidden */
  28547. _masterMesh: Nullable<AbstractMesh>;
  28548. /** @hidden */
  28549. _boundingInfo: Nullable<BoundingInfo>;
  28550. /** @hidden */
  28551. _renderId: number;
  28552. /**
  28553. * Gets or sets the list of subMeshes
  28554. * @see http://doc.babylonjs.com/how_to/multi_materials
  28555. */
  28556. subMeshes: SubMesh[];
  28557. /** @hidden */
  28558. _intersectionsInProgress: AbstractMesh[];
  28559. /** @hidden */
  28560. _unIndexed: boolean;
  28561. /** @hidden */
  28562. _lightSources: Light[];
  28563. /** Gets the list of lights affecting that mesh */
  28564. get lightSources(): Light[];
  28565. /** @hidden */
  28566. get _positions(): Nullable<Vector3[]>;
  28567. /** @hidden */
  28568. _waitingData: {
  28569. lods: Nullable<any>;
  28570. actions: Nullable<any>;
  28571. freezeWorldMatrix: Nullable<boolean>;
  28572. };
  28573. /** @hidden */
  28574. _bonesTransformMatrices: Nullable<Float32Array>;
  28575. /** @hidden */
  28576. _transformMatrixTexture: Nullable<RawTexture>;
  28577. /**
  28578. * Gets or sets a skeleton to apply skining transformations
  28579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28580. */
  28581. set skeleton(value: Nullable<Skeleton>);
  28582. get skeleton(): Nullable<Skeleton>;
  28583. /**
  28584. * An event triggered when the mesh is rebuilt.
  28585. */
  28586. onRebuildObservable: Observable<AbstractMesh>;
  28587. /**
  28588. * Creates a new AbstractMesh
  28589. * @param name defines the name of the mesh
  28590. * @param scene defines the hosting scene
  28591. */
  28592. constructor(name: string, scene?: Nullable<Scene>);
  28593. /**
  28594. * Returns the string "AbstractMesh"
  28595. * @returns "AbstractMesh"
  28596. */
  28597. getClassName(): string;
  28598. /**
  28599. * Gets a string representation of the current mesh
  28600. * @param fullDetails defines a boolean indicating if full details must be included
  28601. * @returns a string representation of the current mesh
  28602. */
  28603. toString(fullDetails?: boolean): string;
  28604. /**
  28605. * @hidden
  28606. */
  28607. protected _getEffectiveParent(): Nullable<Node>;
  28608. /** @hidden */
  28609. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28610. /** @hidden */
  28611. _rebuild(): void;
  28612. /** @hidden */
  28613. _resyncLightSources(): void;
  28614. /** @hidden */
  28615. _resyncLightSource(light: Light): void;
  28616. /** @hidden */
  28617. _unBindEffect(): void;
  28618. /** @hidden */
  28619. _removeLightSource(light: Light, dispose: boolean): void;
  28620. private _markSubMeshesAsDirty;
  28621. /** @hidden */
  28622. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28623. /** @hidden */
  28624. _markSubMeshesAsAttributesDirty(): void;
  28625. /** @hidden */
  28626. _markSubMeshesAsMiscDirty(): void;
  28627. /**
  28628. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28629. */
  28630. get scaling(): Vector3;
  28631. set scaling(newScaling: Vector3);
  28632. /**
  28633. * Returns true if the mesh is blocked. Implemented by child classes
  28634. */
  28635. get isBlocked(): boolean;
  28636. /**
  28637. * Returns the mesh itself by default. Implemented by child classes
  28638. * @param camera defines the camera to use to pick the right LOD level
  28639. * @returns the currentAbstractMesh
  28640. */
  28641. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28642. /**
  28643. * Returns 0 by default. Implemented by child classes
  28644. * @returns an integer
  28645. */
  28646. getTotalVertices(): number;
  28647. /**
  28648. * Returns a positive integer : the total number of indices in this mesh geometry.
  28649. * @returns the numner of indices or zero if the mesh has no geometry.
  28650. */
  28651. getTotalIndices(): number;
  28652. /**
  28653. * Returns null by default. Implemented by child classes
  28654. * @returns null
  28655. */
  28656. getIndices(): Nullable<IndicesArray>;
  28657. /**
  28658. * Returns the array of the requested vertex data kind. Implemented by child classes
  28659. * @param kind defines the vertex data kind to use
  28660. * @returns null
  28661. */
  28662. getVerticesData(kind: string): Nullable<FloatArray>;
  28663. /**
  28664. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28665. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28666. * Note that a new underlying VertexBuffer object is created each call.
  28667. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28668. * @param kind defines vertex data kind:
  28669. * * VertexBuffer.PositionKind
  28670. * * VertexBuffer.UVKind
  28671. * * VertexBuffer.UV2Kind
  28672. * * VertexBuffer.UV3Kind
  28673. * * VertexBuffer.UV4Kind
  28674. * * VertexBuffer.UV5Kind
  28675. * * VertexBuffer.UV6Kind
  28676. * * VertexBuffer.ColorKind
  28677. * * VertexBuffer.MatricesIndicesKind
  28678. * * VertexBuffer.MatricesIndicesExtraKind
  28679. * * VertexBuffer.MatricesWeightsKind
  28680. * * VertexBuffer.MatricesWeightsExtraKind
  28681. * @param data defines the data source
  28682. * @param updatable defines if the data must be flagged as updatable (or static)
  28683. * @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
  28684. * @returns the current mesh
  28685. */
  28686. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28687. /**
  28688. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28689. * If the mesh has no geometry, it is simply returned as it is.
  28690. * @param kind defines vertex data kind:
  28691. * * VertexBuffer.PositionKind
  28692. * * VertexBuffer.UVKind
  28693. * * VertexBuffer.UV2Kind
  28694. * * VertexBuffer.UV3Kind
  28695. * * VertexBuffer.UV4Kind
  28696. * * VertexBuffer.UV5Kind
  28697. * * VertexBuffer.UV6Kind
  28698. * * VertexBuffer.ColorKind
  28699. * * VertexBuffer.MatricesIndicesKind
  28700. * * VertexBuffer.MatricesIndicesExtraKind
  28701. * * VertexBuffer.MatricesWeightsKind
  28702. * * VertexBuffer.MatricesWeightsExtraKind
  28703. * @param data defines the data source
  28704. * @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
  28705. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28706. * @returns the current mesh
  28707. */
  28708. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28709. /**
  28710. * Sets the mesh indices,
  28711. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28712. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28713. * @param totalVertices Defines the total number of vertices
  28714. * @returns the current mesh
  28715. */
  28716. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28717. /**
  28718. * Gets a boolean indicating if specific vertex data is present
  28719. * @param kind defines the vertex data kind to use
  28720. * @returns true is data kind is present
  28721. */
  28722. isVerticesDataPresent(kind: string): boolean;
  28723. /**
  28724. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28725. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28726. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28727. * @returns a BoundingInfo
  28728. */
  28729. getBoundingInfo(): BoundingInfo;
  28730. /**
  28731. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28732. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28733. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28734. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28735. * @returns the current mesh
  28736. */
  28737. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28738. /**
  28739. * Overwrite the current bounding info
  28740. * @param boundingInfo defines the new bounding info
  28741. * @returns the current mesh
  28742. */
  28743. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28744. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28745. get useBones(): boolean;
  28746. /** @hidden */
  28747. _preActivate(): void;
  28748. /** @hidden */
  28749. _preActivateForIntermediateRendering(renderId: number): void;
  28750. /** @hidden */
  28751. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28752. /** @hidden */
  28753. _postActivate(): void;
  28754. /** @hidden */
  28755. _freeze(): void;
  28756. /** @hidden */
  28757. _unFreeze(): void;
  28758. /**
  28759. * Gets the current world matrix
  28760. * @returns a Matrix
  28761. */
  28762. getWorldMatrix(): Matrix;
  28763. /** @hidden */
  28764. _getWorldMatrixDeterminant(): number;
  28765. /**
  28766. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28767. */
  28768. get isAnInstance(): boolean;
  28769. /**
  28770. * Gets a boolean indicating if this mesh has instances
  28771. */
  28772. get hasInstances(): boolean;
  28773. /**
  28774. * Perform relative position change from the point of view of behind the front of the mesh.
  28775. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28776. * Supports definition of mesh facing forward or backward
  28777. * @param amountRight defines the distance on the right axis
  28778. * @param amountUp defines the distance on the up axis
  28779. * @param amountForward defines the distance on the forward axis
  28780. * @returns the current mesh
  28781. */
  28782. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28783. /**
  28784. * Calculate relative position change from the point of view of behind the front of the mesh.
  28785. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28786. * Supports definition of mesh facing forward or backward
  28787. * @param amountRight defines the distance on the right axis
  28788. * @param amountUp defines the distance on the up axis
  28789. * @param amountForward defines the distance on the forward axis
  28790. * @returns the new displacement vector
  28791. */
  28792. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28793. /**
  28794. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28795. * Supports definition of mesh facing forward or backward
  28796. * @param flipBack defines the flip
  28797. * @param twirlClockwise defines the twirl
  28798. * @param tiltRight defines the tilt
  28799. * @returns the current mesh
  28800. */
  28801. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28802. /**
  28803. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28804. * Supports definition of mesh facing forward or backward.
  28805. * @param flipBack defines the flip
  28806. * @param twirlClockwise defines the twirl
  28807. * @param tiltRight defines the tilt
  28808. * @returns the new rotation vector
  28809. */
  28810. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28811. /**
  28812. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28813. * This means the mesh underlying bounding box and sphere are recomputed.
  28814. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28815. * @returns the current mesh
  28816. */
  28817. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28818. /** @hidden */
  28819. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28820. /** @hidden */
  28821. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28822. /** @hidden */
  28823. _updateBoundingInfo(): AbstractMesh;
  28824. /** @hidden */
  28825. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28826. /** @hidden */
  28827. protected _afterComputeWorldMatrix(): void;
  28828. /** @hidden */
  28829. get _effectiveMesh(): AbstractMesh;
  28830. /**
  28831. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28832. * A mesh is in the frustum if its bounding box intersects the frustum
  28833. * @param frustumPlanes defines the frustum to test
  28834. * @returns true if the mesh is in the frustum planes
  28835. */
  28836. isInFrustum(frustumPlanes: Plane[]): boolean;
  28837. /**
  28838. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28839. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28840. * @param frustumPlanes defines the frustum to test
  28841. * @returns true if the mesh is completely in the frustum planes
  28842. */
  28843. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28844. /**
  28845. * True if the mesh intersects another mesh or a SolidParticle object
  28846. * @param mesh defines a target mesh or SolidParticle to test
  28847. * @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)
  28848. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28849. * @returns true if there is an intersection
  28850. */
  28851. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28852. /**
  28853. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28854. * @param point defines the point to test
  28855. * @returns true if there is an intersection
  28856. */
  28857. intersectsPoint(point: Vector3): boolean;
  28858. /**
  28859. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28861. */
  28862. get checkCollisions(): boolean;
  28863. set checkCollisions(collisionEnabled: boolean);
  28864. /**
  28865. * Gets Collider object used to compute collisions (not physics)
  28866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28867. */
  28868. get collider(): Nullable<Collider>;
  28869. /**
  28870. * Move the mesh using collision engine
  28871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28872. * @param displacement defines the requested displacement vector
  28873. * @returns the current mesh
  28874. */
  28875. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28876. private _onCollisionPositionChange;
  28877. /** @hidden */
  28878. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28879. /** @hidden */
  28880. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28881. /** @hidden */
  28882. _checkCollision(collider: Collider): AbstractMesh;
  28883. /** @hidden */
  28884. _generatePointsArray(): boolean;
  28885. /**
  28886. * Checks if the passed Ray intersects with the mesh
  28887. * @param ray defines the ray to use
  28888. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28889. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28890. * @returns the picking info
  28891. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28892. */
  28893. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28894. /**
  28895. * Clones the current mesh
  28896. * @param name defines the mesh name
  28897. * @param newParent defines the new mesh parent
  28898. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28899. * @returns the new mesh
  28900. */
  28901. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28902. /**
  28903. * Disposes all the submeshes of the current meshnp
  28904. * @returns the current mesh
  28905. */
  28906. releaseSubMeshes(): AbstractMesh;
  28907. /**
  28908. * Releases resources associated with this abstract mesh.
  28909. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28910. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28911. */
  28912. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28913. /**
  28914. * Adds the passed mesh as a child to the current mesh
  28915. * @param mesh defines the child mesh
  28916. * @returns the current mesh
  28917. */
  28918. addChild(mesh: AbstractMesh): AbstractMesh;
  28919. /**
  28920. * Removes the passed mesh from the current mesh children list
  28921. * @param mesh defines the child mesh
  28922. * @returns the current mesh
  28923. */
  28924. removeChild(mesh: AbstractMesh): AbstractMesh;
  28925. /** @hidden */
  28926. private _initFacetData;
  28927. /**
  28928. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28929. * This method can be called within the render loop.
  28930. * 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
  28931. * @returns the current mesh
  28932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28933. */
  28934. updateFacetData(): AbstractMesh;
  28935. /**
  28936. * Returns the facetLocalNormals array.
  28937. * The normals are expressed in the mesh local spac
  28938. * @returns an array of Vector3
  28939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28940. */
  28941. getFacetLocalNormals(): Vector3[];
  28942. /**
  28943. * Returns the facetLocalPositions array.
  28944. * The facet positions are expressed in the mesh local space
  28945. * @returns an array of Vector3
  28946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28947. */
  28948. getFacetLocalPositions(): Vector3[];
  28949. /**
  28950. * Returns the facetLocalPartioning array
  28951. * @returns an array of array of numbers
  28952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28953. */
  28954. getFacetLocalPartitioning(): number[][];
  28955. /**
  28956. * Returns the i-th facet position in the world system.
  28957. * This method allocates a new Vector3 per call
  28958. * @param i defines the facet index
  28959. * @returns a new Vector3
  28960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28961. */
  28962. getFacetPosition(i: number): Vector3;
  28963. /**
  28964. * Sets the reference Vector3 with the i-th facet position in the world system
  28965. * @param i defines the facet index
  28966. * @param ref defines the target vector
  28967. * @returns the current mesh
  28968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28969. */
  28970. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28971. /**
  28972. * Returns the i-th facet normal in the world system.
  28973. * This method allocates a new Vector3 per call
  28974. * @param i defines the facet index
  28975. * @returns a new Vector3
  28976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28977. */
  28978. getFacetNormal(i: number): Vector3;
  28979. /**
  28980. * Sets the reference Vector3 with the i-th facet normal in the world system
  28981. * @param i defines the facet index
  28982. * @param ref defines the target vector
  28983. * @returns the current mesh
  28984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28985. */
  28986. getFacetNormalToRef(i: number, ref: Vector3): this;
  28987. /**
  28988. * 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)
  28989. * @param x defines x coordinate
  28990. * @param y defines y coordinate
  28991. * @param z defines z coordinate
  28992. * @returns the array of facet indexes
  28993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28994. */
  28995. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28996. /**
  28997. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28998. * @param projected sets as the (x,y,z) world projection on the facet
  28999. * @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
  29000. * @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
  29001. * @param x defines x coordinate
  29002. * @param y defines y coordinate
  29003. * @param z defines z coordinate
  29004. * @returns the face index if found (or null instead)
  29005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29006. */
  29007. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29008. /**
  29009. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29010. * @param projected sets as the (x,y,z) local projection on the facet
  29011. * @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
  29012. * @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
  29013. * @param x defines x coordinate
  29014. * @param y defines y coordinate
  29015. * @param z defines z coordinate
  29016. * @returns the face index if found (or null instead)
  29017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29018. */
  29019. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29020. /**
  29021. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29022. * @returns the parameters
  29023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29024. */
  29025. getFacetDataParameters(): any;
  29026. /**
  29027. * Disables the feature FacetData and frees the related memory
  29028. * @returns the current mesh
  29029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29030. */
  29031. disableFacetData(): AbstractMesh;
  29032. /**
  29033. * Updates the AbstractMesh indices array
  29034. * @param indices defines the data source
  29035. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29036. * @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)
  29037. * @returns the current mesh
  29038. */
  29039. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29040. /**
  29041. * Creates new normals data for the mesh
  29042. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29043. * @returns the current mesh
  29044. */
  29045. createNormals(updatable: boolean): AbstractMesh;
  29046. /**
  29047. * Align the mesh with a normal
  29048. * @param normal defines the normal to use
  29049. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29050. * @returns the current mesh
  29051. */
  29052. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29053. /** @hidden */
  29054. _checkOcclusionQuery(): boolean;
  29055. /**
  29056. * Disables the mesh edge rendering mode
  29057. * @returns the currentAbstractMesh
  29058. */
  29059. disableEdgesRendering(): AbstractMesh;
  29060. /**
  29061. * Enables the edge rendering mode on the mesh.
  29062. * This mode makes the mesh edges visible
  29063. * @param epsilon defines the maximal distance between two angles to detect a face
  29064. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29065. * @returns the currentAbstractMesh
  29066. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29067. */
  29068. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29069. }
  29070. }
  29071. declare module BABYLON {
  29072. /**
  29073. * Interface used to define ActionEvent
  29074. */
  29075. export interface IActionEvent {
  29076. /** The mesh or sprite that triggered the action */
  29077. source: any;
  29078. /** The X mouse cursor position at the time of the event */
  29079. pointerX: number;
  29080. /** The Y mouse cursor position at the time of the event */
  29081. pointerY: number;
  29082. /** The mesh that is currently pointed at (can be null) */
  29083. meshUnderPointer: Nullable<AbstractMesh>;
  29084. /** the original (browser) event that triggered the ActionEvent */
  29085. sourceEvent?: any;
  29086. /** additional data for the event */
  29087. additionalData?: any;
  29088. }
  29089. /**
  29090. * ActionEvent is the event being sent when an action is triggered.
  29091. */
  29092. export class ActionEvent implements IActionEvent {
  29093. /** The mesh or sprite that triggered the action */
  29094. source: any;
  29095. /** The X mouse cursor position at the time of the event */
  29096. pointerX: number;
  29097. /** The Y mouse cursor position at the time of the event */
  29098. pointerY: number;
  29099. /** The mesh that is currently pointed at (can be null) */
  29100. meshUnderPointer: Nullable<AbstractMesh>;
  29101. /** the original (browser) event that triggered the ActionEvent */
  29102. sourceEvent?: any;
  29103. /** additional data for the event */
  29104. additionalData?: any;
  29105. /**
  29106. * Creates a new ActionEvent
  29107. * @param source The mesh or sprite that triggered the action
  29108. * @param pointerX The X mouse cursor position at the time of the event
  29109. * @param pointerY The Y mouse cursor position at the time of the event
  29110. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29111. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29112. * @param additionalData additional data for the event
  29113. */
  29114. constructor(
  29115. /** The mesh or sprite that triggered the action */
  29116. source: any,
  29117. /** The X mouse cursor position at the time of the event */
  29118. pointerX: number,
  29119. /** The Y mouse cursor position at the time of the event */
  29120. pointerY: number,
  29121. /** The mesh that is currently pointed at (can be null) */
  29122. meshUnderPointer: Nullable<AbstractMesh>,
  29123. /** the original (browser) event that triggered the ActionEvent */
  29124. sourceEvent?: any,
  29125. /** additional data for the event */
  29126. additionalData?: any);
  29127. /**
  29128. * Helper function to auto-create an ActionEvent from a source mesh.
  29129. * @param source The source mesh that triggered the event
  29130. * @param evt The original (browser) event
  29131. * @param additionalData additional data for the event
  29132. * @returns the new ActionEvent
  29133. */
  29134. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29135. /**
  29136. * Helper function to auto-create an ActionEvent from a source sprite
  29137. * @param source The source sprite that triggered the event
  29138. * @param scene Scene associated with the sprite
  29139. * @param evt The original (browser) event
  29140. * @param additionalData additional data for the event
  29141. * @returns the new ActionEvent
  29142. */
  29143. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29144. /**
  29145. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29146. * @param scene the scene where the event occurred
  29147. * @param evt The original (browser) event
  29148. * @returns the new ActionEvent
  29149. */
  29150. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29151. /**
  29152. * Helper function to auto-create an ActionEvent from a primitive
  29153. * @param prim defines the target primitive
  29154. * @param pointerPos defines the pointer position
  29155. * @param evt The original (browser) event
  29156. * @param additionalData additional data for the event
  29157. * @returns the new ActionEvent
  29158. */
  29159. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29160. }
  29161. }
  29162. declare module BABYLON {
  29163. /**
  29164. * Abstract class used to decouple action Manager from scene and meshes.
  29165. * Do not instantiate.
  29166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29167. */
  29168. export abstract class AbstractActionManager implements IDisposable {
  29169. /** Gets the list of active triggers */
  29170. static Triggers: {
  29171. [key: string]: number;
  29172. };
  29173. /** Gets the cursor to use when hovering items */
  29174. hoverCursor: string;
  29175. /** Gets the list of actions */
  29176. actions: IAction[];
  29177. /**
  29178. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29179. */
  29180. isRecursive: boolean;
  29181. /**
  29182. * Releases all associated resources
  29183. */
  29184. abstract dispose(): void;
  29185. /**
  29186. * Does this action manager has pointer triggers
  29187. */
  29188. abstract get hasPointerTriggers(): boolean;
  29189. /**
  29190. * Does this action manager has pick triggers
  29191. */
  29192. abstract get hasPickTriggers(): boolean;
  29193. /**
  29194. * Process a specific trigger
  29195. * @param trigger defines the trigger to process
  29196. * @param evt defines the event details to be processed
  29197. */
  29198. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29199. /**
  29200. * Does this action manager handles actions of any of the given triggers
  29201. * @param triggers defines the triggers to be tested
  29202. * @return a boolean indicating whether one (or more) of the triggers is handled
  29203. */
  29204. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29205. /**
  29206. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29207. * speed.
  29208. * @param triggerA defines the trigger to be tested
  29209. * @param triggerB defines the trigger to be tested
  29210. * @return a boolean indicating whether one (or more) of the triggers is handled
  29211. */
  29212. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29213. /**
  29214. * Does this action manager handles actions of a given trigger
  29215. * @param trigger defines the trigger to be tested
  29216. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29217. * @return whether the trigger is handled
  29218. */
  29219. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29220. /**
  29221. * Serialize this manager to a JSON object
  29222. * @param name defines the property name to store this manager
  29223. * @returns a JSON representation of this manager
  29224. */
  29225. abstract serialize(name: string): any;
  29226. /**
  29227. * Registers an action to this action manager
  29228. * @param action defines the action to be registered
  29229. * @return the action amended (prepared) after registration
  29230. */
  29231. abstract registerAction(action: IAction): Nullable<IAction>;
  29232. /**
  29233. * Unregisters an action to this action manager
  29234. * @param action defines the action to be unregistered
  29235. * @return a boolean indicating whether the action has been unregistered
  29236. */
  29237. abstract unregisterAction(action: IAction): Boolean;
  29238. /**
  29239. * Does exist one action manager with at least one trigger
  29240. **/
  29241. static get HasTriggers(): boolean;
  29242. /**
  29243. * Does exist one action manager with at least one pick trigger
  29244. **/
  29245. static get HasPickTriggers(): boolean;
  29246. /**
  29247. * Does exist one action manager that handles actions of a given trigger
  29248. * @param trigger defines the trigger to be tested
  29249. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29250. **/
  29251. static HasSpecificTrigger(trigger: number): boolean;
  29252. }
  29253. }
  29254. declare module BABYLON {
  29255. /**
  29256. * Defines how a node can be built from a string name.
  29257. */
  29258. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29259. /**
  29260. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29261. */
  29262. export class Node implements IBehaviorAware<Node> {
  29263. /** @hidden */
  29264. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29265. private static _NodeConstructors;
  29266. /**
  29267. * Add a new node constructor
  29268. * @param type defines the type name of the node to construct
  29269. * @param constructorFunc defines the constructor function
  29270. */
  29271. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29272. /**
  29273. * Returns a node constructor based on type name
  29274. * @param type defines the type name
  29275. * @param name defines the new node name
  29276. * @param scene defines the hosting scene
  29277. * @param options defines optional options to transmit to constructors
  29278. * @returns the new constructor or null
  29279. */
  29280. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29281. /**
  29282. * Gets or sets the name of the node
  29283. */
  29284. name: string;
  29285. /**
  29286. * Gets or sets the id of the node
  29287. */
  29288. id: string;
  29289. /**
  29290. * Gets or sets the unique id of the node
  29291. */
  29292. uniqueId: number;
  29293. /**
  29294. * Gets or sets a string used to store user defined state for the node
  29295. */
  29296. state: string;
  29297. /**
  29298. * Gets or sets an object used to store user defined information for the node
  29299. */
  29300. metadata: any;
  29301. /**
  29302. * For internal use only. Please do not use.
  29303. */
  29304. reservedDataStore: any;
  29305. /**
  29306. * List of inspectable custom properties (used by the Inspector)
  29307. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29308. */
  29309. inspectableCustomProperties: IInspectable[];
  29310. private _doNotSerialize;
  29311. /**
  29312. * Gets or sets a boolean used to define if the node must be serialized
  29313. */
  29314. get doNotSerialize(): boolean;
  29315. set doNotSerialize(value: boolean);
  29316. /** @hidden */
  29317. _isDisposed: boolean;
  29318. /**
  29319. * Gets a list of Animations associated with the node
  29320. */
  29321. animations: Animation[];
  29322. protected _ranges: {
  29323. [name: string]: Nullable<AnimationRange>;
  29324. };
  29325. /**
  29326. * Callback raised when the node is ready to be used
  29327. */
  29328. onReady: Nullable<(node: Node) => void>;
  29329. private _isEnabled;
  29330. private _isParentEnabled;
  29331. private _isReady;
  29332. /** @hidden */
  29333. _currentRenderId: number;
  29334. private _parentUpdateId;
  29335. /** @hidden */
  29336. _childUpdateId: number;
  29337. /** @hidden */
  29338. _waitingParentId: Nullable<string>;
  29339. /** @hidden */
  29340. _scene: Scene;
  29341. /** @hidden */
  29342. _cache: any;
  29343. private _parentNode;
  29344. private _children;
  29345. /** @hidden */
  29346. _worldMatrix: Matrix;
  29347. /** @hidden */
  29348. _worldMatrixDeterminant: number;
  29349. /** @hidden */
  29350. _worldMatrixDeterminantIsDirty: boolean;
  29351. /** @hidden */
  29352. private _sceneRootNodesIndex;
  29353. /**
  29354. * Gets a boolean indicating if the node has been disposed
  29355. * @returns true if the node was disposed
  29356. */
  29357. isDisposed(): boolean;
  29358. /**
  29359. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29360. * @see https://doc.babylonjs.com/how_to/parenting
  29361. */
  29362. set parent(parent: Nullable<Node>);
  29363. get parent(): Nullable<Node>;
  29364. /** @hidden */
  29365. _addToSceneRootNodes(): void;
  29366. /** @hidden */
  29367. _removeFromSceneRootNodes(): void;
  29368. private _animationPropertiesOverride;
  29369. /**
  29370. * Gets or sets the animation properties override
  29371. */
  29372. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29373. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29374. /**
  29375. * Gets a string idenfifying the name of the class
  29376. * @returns "Node" string
  29377. */
  29378. getClassName(): string;
  29379. /** @hidden */
  29380. readonly _isNode: boolean;
  29381. /**
  29382. * An event triggered when the mesh is disposed
  29383. */
  29384. onDisposeObservable: Observable<Node>;
  29385. private _onDisposeObserver;
  29386. /**
  29387. * Sets a callback that will be raised when the node will be disposed
  29388. */
  29389. set onDispose(callback: () => void);
  29390. /**
  29391. * Creates a new Node
  29392. * @param name the name and id to be given to this node
  29393. * @param scene the scene this node will be added to
  29394. */
  29395. constructor(name: string, scene?: Nullable<Scene>);
  29396. /**
  29397. * Gets the scene of the node
  29398. * @returns a scene
  29399. */
  29400. getScene(): Scene;
  29401. /**
  29402. * Gets the engine of the node
  29403. * @returns a Engine
  29404. */
  29405. getEngine(): Engine;
  29406. private _behaviors;
  29407. /**
  29408. * Attach a behavior to the node
  29409. * @see http://doc.babylonjs.com/features/behaviour
  29410. * @param behavior defines the behavior to attach
  29411. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29412. * @returns the current Node
  29413. */
  29414. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29415. /**
  29416. * Remove an attached behavior
  29417. * @see http://doc.babylonjs.com/features/behaviour
  29418. * @param behavior defines the behavior to attach
  29419. * @returns the current Node
  29420. */
  29421. removeBehavior(behavior: Behavior<Node>): Node;
  29422. /**
  29423. * Gets the list of attached behaviors
  29424. * @see http://doc.babylonjs.com/features/behaviour
  29425. */
  29426. get behaviors(): Behavior<Node>[];
  29427. /**
  29428. * Gets an attached behavior by name
  29429. * @param name defines the name of the behavior to look for
  29430. * @see http://doc.babylonjs.com/features/behaviour
  29431. * @returns null if behavior was not found else the requested behavior
  29432. */
  29433. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29434. /**
  29435. * Returns the latest update of the World matrix
  29436. * @returns a Matrix
  29437. */
  29438. getWorldMatrix(): Matrix;
  29439. /** @hidden */
  29440. _getWorldMatrixDeterminant(): number;
  29441. /**
  29442. * Returns directly the latest state of the mesh World matrix.
  29443. * A Matrix is returned.
  29444. */
  29445. get worldMatrixFromCache(): Matrix;
  29446. /** @hidden */
  29447. _initCache(): void;
  29448. /** @hidden */
  29449. updateCache(force?: boolean): void;
  29450. /** @hidden */
  29451. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29452. /** @hidden */
  29453. _updateCache(ignoreParentClass?: boolean): void;
  29454. /** @hidden */
  29455. _isSynchronized(): boolean;
  29456. /** @hidden */
  29457. _markSyncedWithParent(): void;
  29458. /** @hidden */
  29459. isSynchronizedWithParent(): boolean;
  29460. /** @hidden */
  29461. isSynchronized(): boolean;
  29462. /**
  29463. * Is this node ready to be used/rendered
  29464. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29465. * @return true if the node is ready
  29466. */
  29467. isReady(completeCheck?: boolean): boolean;
  29468. /**
  29469. * Is this node enabled?
  29470. * 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
  29471. * @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
  29472. * @return whether this node (and its parent) is enabled
  29473. */
  29474. isEnabled(checkAncestors?: boolean): boolean;
  29475. /** @hidden */
  29476. protected _syncParentEnabledState(): void;
  29477. /**
  29478. * Set the enabled state of this node
  29479. * @param value defines the new enabled state
  29480. */
  29481. setEnabled(value: boolean): void;
  29482. /**
  29483. * Is this node a descendant of the given node?
  29484. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29485. * @param ancestor defines the parent node to inspect
  29486. * @returns a boolean indicating if this node is a descendant of the given node
  29487. */
  29488. isDescendantOf(ancestor: Node): boolean;
  29489. /** @hidden */
  29490. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29491. /**
  29492. * Will return all nodes that have this node as ascendant
  29493. * @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
  29494. * @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
  29495. * @return all children nodes of all types
  29496. */
  29497. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29498. /**
  29499. * Get all child-meshes of this node
  29500. * @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)
  29501. * @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
  29502. * @returns an array of AbstractMesh
  29503. */
  29504. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29505. /**
  29506. * Get all direct children of this node
  29507. * @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
  29508. * @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)
  29509. * @returns an array of Node
  29510. */
  29511. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29512. /** @hidden */
  29513. _setReady(state: boolean): void;
  29514. /**
  29515. * Get an animation by name
  29516. * @param name defines the name of the animation to look for
  29517. * @returns null if not found else the requested animation
  29518. */
  29519. getAnimationByName(name: string): Nullable<Animation>;
  29520. /**
  29521. * Creates an animation range for this node
  29522. * @param name defines the name of the range
  29523. * @param from defines the starting key
  29524. * @param to defines the end key
  29525. */
  29526. createAnimationRange(name: string, from: number, to: number): void;
  29527. /**
  29528. * Delete a specific animation range
  29529. * @param name defines the name of the range to delete
  29530. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29531. */
  29532. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29533. /**
  29534. * Get an animation range by name
  29535. * @param name defines the name of the animation range to look for
  29536. * @returns null if not found else the requested animation range
  29537. */
  29538. getAnimationRange(name: string): Nullable<AnimationRange>;
  29539. /**
  29540. * Gets the list of all animation ranges defined on this node
  29541. * @returns an array
  29542. */
  29543. getAnimationRanges(): Nullable<AnimationRange>[];
  29544. /**
  29545. * Will start the animation sequence
  29546. * @param name defines the range frames for animation sequence
  29547. * @param loop defines if the animation should loop (false by default)
  29548. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29549. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29550. * @returns the object created for this animation. If range does not exist, it will return null
  29551. */
  29552. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29553. /**
  29554. * Serialize animation ranges into a JSON compatible object
  29555. * @returns serialization object
  29556. */
  29557. serializeAnimationRanges(): any;
  29558. /**
  29559. * Computes the world matrix of the node
  29560. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29561. * @returns the world matrix
  29562. */
  29563. computeWorldMatrix(force?: boolean): Matrix;
  29564. /**
  29565. * Releases resources associated with this node.
  29566. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29567. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29568. */
  29569. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29570. /**
  29571. * Parse animation range data from a serialization object and store them into a given node
  29572. * @param node defines where to store the animation ranges
  29573. * @param parsedNode defines the serialization object to read data from
  29574. * @param scene defines the hosting scene
  29575. */
  29576. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29577. /**
  29578. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29579. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29580. * @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
  29581. * @returns the new bounding vectors
  29582. */
  29583. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29584. min: Vector3;
  29585. max: Vector3;
  29586. };
  29587. }
  29588. }
  29589. declare module BABYLON {
  29590. /**
  29591. * @hidden
  29592. */
  29593. export class _IAnimationState {
  29594. key: number;
  29595. repeatCount: number;
  29596. workValue?: any;
  29597. loopMode?: number;
  29598. offsetValue?: any;
  29599. highLimitValue?: any;
  29600. }
  29601. /**
  29602. * Class used to store any kind of animation
  29603. */
  29604. export class Animation {
  29605. /**Name of the animation */
  29606. name: string;
  29607. /**Property to animate */
  29608. targetProperty: string;
  29609. /**The frames per second of the animation */
  29610. framePerSecond: number;
  29611. /**The data type of the animation */
  29612. dataType: number;
  29613. /**The loop mode of the animation */
  29614. loopMode?: number | undefined;
  29615. /**Specifies if blending should be enabled */
  29616. enableBlending?: boolean | undefined;
  29617. /**
  29618. * Use matrix interpolation instead of using direct key value when animating matrices
  29619. */
  29620. static AllowMatricesInterpolation: boolean;
  29621. /**
  29622. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29623. */
  29624. static AllowMatrixDecomposeForInterpolation: boolean;
  29625. /**
  29626. * Stores the key frames of the animation
  29627. */
  29628. private _keys;
  29629. /**
  29630. * Stores the easing function of the animation
  29631. */
  29632. private _easingFunction;
  29633. /**
  29634. * @hidden Internal use only
  29635. */
  29636. _runtimeAnimations: RuntimeAnimation[];
  29637. /**
  29638. * The set of event that will be linked to this animation
  29639. */
  29640. private _events;
  29641. /**
  29642. * Stores an array of target property paths
  29643. */
  29644. targetPropertyPath: string[];
  29645. /**
  29646. * Stores the blending speed of the animation
  29647. */
  29648. blendingSpeed: number;
  29649. /**
  29650. * Stores the animation ranges for the animation
  29651. */
  29652. private _ranges;
  29653. /**
  29654. * @hidden Internal use
  29655. */
  29656. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29657. /**
  29658. * Sets up an animation
  29659. * @param property The property to animate
  29660. * @param animationType The animation type to apply
  29661. * @param framePerSecond The frames per second of the animation
  29662. * @param easingFunction The easing function used in the animation
  29663. * @returns The created animation
  29664. */
  29665. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29666. /**
  29667. * Create and start an animation on a node
  29668. * @param name defines the name of the global animation that will be run on all nodes
  29669. * @param node defines the root node where the animation will take place
  29670. * @param targetProperty defines property to animate
  29671. * @param framePerSecond defines the number of frame per second yo use
  29672. * @param totalFrame defines the number of frames in total
  29673. * @param from defines the initial value
  29674. * @param to defines the final value
  29675. * @param loopMode defines which loop mode you want to use (off by default)
  29676. * @param easingFunction defines the easing function to use (linear by default)
  29677. * @param onAnimationEnd defines the callback to call when animation end
  29678. * @returns the animatable created for this animation
  29679. */
  29680. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29681. /**
  29682. * Create and start an animation on a node and its descendants
  29683. * @param name defines the name of the global animation that will be run on all nodes
  29684. * @param node defines the root node where the animation will take place
  29685. * @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
  29686. * @param targetProperty defines property to animate
  29687. * @param framePerSecond defines the number of frame per second to use
  29688. * @param totalFrame defines the number of frames in total
  29689. * @param from defines the initial value
  29690. * @param to defines the final value
  29691. * @param loopMode defines which loop mode you want to use (off by default)
  29692. * @param easingFunction defines the easing function to use (linear by default)
  29693. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29694. * @returns the list of animatables created for all nodes
  29695. * @example https://www.babylonjs-playground.com/#MH0VLI
  29696. */
  29697. 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[]>;
  29698. /**
  29699. * Creates a new animation, merges it with the existing animations and starts it
  29700. * @param name Name of the animation
  29701. * @param node Node which contains the scene that begins the animations
  29702. * @param targetProperty Specifies which property to animate
  29703. * @param framePerSecond The frames per second of the animation
  29704. * @param totalFrame The total number of frames
  29705. * @param from The frame at the beginning of the animation
  29706. * @param to The frame at the end of the animation
  29707. * @param loopMode Specifies the loop mode of the animation
  29708. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29709. * @param onAnimationEnd Callback to run once the animation is complete
  29710. * @returns Nullable animation
  29711. */
  29712. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29713. /**
  29714. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29715. * @param sourceAnimation defines the Animation containing keyframes to convert
  29716. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29717. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29718. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29719. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29720. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29721. */
  29722. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29723. /**
  29724. * Transition property of an host to the target Value
  29725. * @param property The property to transition
  29726. * @param targetValue The target Value of the property
  29727. * @param host The object where the property to animate belongs
  29728. * @param scene Scene used to run the animation
  29729. * @param frameRate Framerate (in frame/s) to use
  29730. * @param transition The transition type we want to use
  29731. * @param duration The duration of the animation, in milliseconds
  29732. * @param onAnimationEnd Callback trigger at the end of the animation
  29733. * @returns Nullable animation
  29734. */
  29735. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29736. /**
  29737. * Return the array of runtime animations currently using this animation
  29738. */
  29739. get runtimeAnimations(): RuntimeAnimation[];
  29740. /**
  29741. * Specifies if any of the runtime animations are currently running
  29742. */
  29743. get hasRunningRuntimeAnimations(): boolean;
  29744. /**
  29745. * Initializes the animation
  29746. * @param name Name of the animation
  29747. * @param targetProperty Property to animate
  29748. * @param framePerSecond The frames per second of the animation
  29749. * @param dataType The data type of the animation
  29750. * @param loopMode The loop mode of the animation
  29751. * @param enableBlending Specifies if blending should be enabled
  29752. */
  29753. constructor(
  29754. /**Name of the animation */
  29755. name: string,
  29756. /**Property to animate */
  29757. targetProperty: string,
  29758. /**The frames per second of the animation */
  29759. framePerSecond: number,
  29760. /**The data type of the animation */
  29761. dataType: number,
  29762. /**The loop mode of the animation */
  29763. loopMode?: number | undefined,
  29764. /**Specifies if blending should be enabled */
  29765. enableBlending?: boolean | undefined);
  29766. /**
  29767. * Converts the animation to a string
  29768. * @param fullDetails support for multiple levels of logging within scene loading
  29769. * @returns String form of the animation
  29770. */
  29771. toString(fullDetails?: boolean): string;
  29772. /**
  29773. * Add an event to this animation
  29774. * @param event Event to add
  29775. */
  29776. addEvent(event: AnimationEvent): void;
  29777. /**
  29778. * Remove all events found at the given frame
  29779. * @param frame The frame to remove events from
  29780. */
  29781. removeEvents(frame: number): void;
  29782. /**
  29783. * Retrieves all the events from the animation
  29784. * @returns Events from the animation
  29785. */
  29786. getEvents(): AnimationEvent[];
  29787. /**
  29788. * Creates an animation range
  29789. * @param name Name of the animation range
  29790. * @param from Starting frame of the animation range
  29791. * @param to Ending frame of the animation
  29792. */
  29793. createRange(name: string, from: number, to: number): void;
  29794. /**
  29795. * Deletes an animation range by name
  29796. * @param name Name of the animation range to delete
  29797. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29798. */
  29799. deleteRange(name: string, deleteFrames?: boolean): void;
  29800. /**
  29801. * Gets the animation range by name, or null if not defined
  29802. * @param name Name of the animation range
  29803. * @returns Nullable animation range
  29804. */
  29805. getRange(name: string): Nullable<AnimationRange>;
  29806. /**
  29807. * Gets the key frames from the animation
  29808. * @returns The key frames of the animation
  29809. */
  29810. getKeys(): Array<IAnimationKey>;
  29811. /**
  29812. * Gets the highest frame rate of the animation
  29813. * @returns Highest frame rate of the animation
  29814. */
  29815. getHighestFrame(): number;
  29816. /**
  29817. * Gets the easing function of the animation
  29818. * @returns Easing function of the animation
  29819. */
  29820. getEasingFunction(): IEasingFunction;
  29821. /**
  29822. * Sets the easing function of the animation
  29823. * @param easingFunction A custom mathematical formula for animation
  29824. */
  29825. setEasingFunction(easingFunction: EasingFunction): void;
  29826. /**
  29827. * Interpolates a scalar linearly
  29828. * @param startValue Start value of the animation curve
  29829. * @param endValue End value of the animation curve
  29830. * @param gradient Scalar amount to interpolate
  29831. * @returns Interpolated scalar value
  29832. */
  29833. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29834. /**
  29835. * Interpolates a scalar cubically
  29836. * @param startValue Start value of the animation curve
  29837. * @param outTangent End tangent of the animation
  29838. * @param endValue End value of the animation curve
  29839. * @param inTangent Start tangent of the animation curve
  29840. * @param gradient Scalar amount to interpolate
  29841. * @returns Interpolated scalar value
  29842. */
  29843. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29844. /**
  29845. * Interpolates a quaternion using a spherical linear interpolation
  29846. * @param startValue Start value of the animation curve
  29847. * @param endValue End value of the animation curve
  29848. * @param gradient Scalar amount to interpolate
  29849. * @returns Interpolated quaternion value
  29850. */
  29851. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29852. /**
  29853. * Interpolates a quaternion cubically
  29854. * @param startValue Start value of the animation curve
  29855. * @param outTangent End tangent of the animation curve
  29856. * @param endValue End value of the animation curve
  29857. * @param inTangent Start tangent of the animation curve
  29858. * @param gradient Scalar amount to interpolate
  29859. * @returns Interpolated quaternion value
  29860. */
  29861. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29862. /**
  29863. * Interpolates a Vector3 linearl
  29864. * @param startValue Start value of the animation curve
  29865. * @param endValue End value of the animation curve
  29866. * @param gradient Scalar amount to interpolate
  29867. * @returns Interpolated scalar value
  29868. */
  29869. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29870. /**
  29871. * Interpolates a Vector3 cubically
  29872. * @param startValue Start value of the animation curve
  29873. * @param outTangent End tangent of the animation
  29874. * @param endValue End value of the animation curve
  29875. * @param inTangent Start tangent of the animation curve
  29876. * @param gradient Scalar amount to interpolate
  29877. * @returns InterpolatedVector3 value
  29878. */
  29879. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29880. /**
  29881. * Interpolates a Vector2 linearly
  29882. * @param startValue Start value of the animation curve
  29883. * @param endValue End value of the animation curve
  29884. * @param gradient Scalar amount to interpolate
  29885. * @returns Interpolated Vector2 value
  29886. */
  29887. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29888. /**
  29889. * Interpolates a Vector2 cubically
  29890. * @param startValue Start value of the animation curve
  29891. * @param outTangent End tangent of the animation
  29892. * @param endValue End value of the animation curve
  29893. * @param inTangent Start tangent of the animation curve
  29894. * @param gradient Scalar amount to interpolate
  29895. * @returns Interpolated Vector2 value
  29896. */
  29897. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29898. /**
  29899. * Interpolates a size linearly
  29900. * @param startValue Start value of the animation curve
  29901. * @param endValue End value of the animation curve
  29902. * @param gradient Scalar amount to interpolate
  29903. * @returns Interpolated Size value
  29904. */
  29905. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29906. /**
  29907. * Interpolates a Color3 linearly
  29908. * @param startValue Start value of the animation curve
  29909. * @param endValue End value of the animation curve
  29910. * @param gradient Scalar amount to interpolate
  29911. * @returns Interpolated Color3 value
  29912. */
  29913. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29914. /**
  29915. * Interpolates a Color4 linearly
  29916. * @param startValue Start value of the animation curve
  29917. * @param endValue End value of the animation curve
  29918. * @param gradient Scalar amount to interpolate
  29919. * @returns Interpolated Color3 value
  29920. */
  29921. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29922. /**
  29923. * @hidden Internal use only
  29924. */
  29925. _getKeyValue(value: any): any;
  29926. /**
  29927. * @hidden Internal use only
  29928. */
  29929. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29930. /**
  29931. * Defines the function to use to interpolate matrices
  29932. * @param startValue defines the start matrix
  29933. * @param endValue defines the end matrix
  29934. * @param gradient defines the gradient between both matrices
  29935. * @param result defines an optional target matrix where to store the interpolation
  29936. * @returns the interpolated matrix
  29937. */
  29938. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29939. /**
  29940. * Makes a copy of the animation
  29941. * @returns Cloned animation
  29942. */
  29943. clone(): Animation;
  29944. /**
  29945. * Sets the key frames of the animation
  29946. * @param values The animation key frames to set
  29947. */
  29948. setKeys(values: Array<IAnimationKey>): void;
  29949. /**
  29950. * Serializes the animation to an object
  29951. * @returns Serialized object
  29952. */
  29953. serialize(): any;
  29954. /**
  29955. * Float animation type
  29956. */
  29957. static readonly ANIMATIONTYPE_FLOAT: number;
  29958. /**
  29959. * Vector3 animation type
  29960. */
  29961. static readonly ANIMATIONTYPE_VECTOR3: number;
  29962. /**
  29963. * Quaternion animation type
  29964. */
  29965. static readonly ANIMATIONTYPE_QUATERNION: number;
  29966. /**
  29967. * Matrix animation type
  29968. */
  29969. static readonly ANIMATIONTYPE_MATRIX: number;
  29970. /**
  29971. * Color3 animation type
  29972. */
  29973. static readonly ANIMATIONTYPE_COLOR3: number;
  29974. /**
  29975. * Color3 animation type
  29976. */
  29977. static readonly ANIMATIONTYPE_COLOR4: number;
  29978. /**
  29979. * Vector2 animation type
  29980. */
  29981. static readonly ANIMATIONTYPE_VECTOR2: number;
  29982. /**
  29983. * Size animation type
  29984. */
  29985. static readonly ANIMATIONTYPE_SIZE: number;
  29986. /**
  29987. * Relative Loop Mode
  29988. */
  29989. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29990. /**
  29991. * Cycle Loop Mode
  29992. */
  29993. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29994. /**
  29995. * Constant Loop Mode
  29996. */
  29997. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29998. /** @hidden */
  29999. static _UniversalLerp(left: any, right: any, amount: number): any;
  30000. /**
  30001. * Parses an animation object and creates an animation
  30002. * @param parsedAnimation Parsed animation object
  30003. * @returns Animation object
  30004. */
  30005. static Parse(parsedAnimation: any): Animation;
  30006. /**
  30007. * Appends the serialized animations from the source animations
  30008. * @param source Source containing the animations
  30009. * @param destination Target to store the animations
  30010. */
  30011. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30012. }
  30013. }
  30014. declare module BABYLON {
  30015. /**
  30016. * Interface containing an array of animations
  30017. */
  30018. export interface IAnimatable {
  30019. /**
  30020. * Array of animations
  30021. */
  30022. animations: Nullable<Array<Animation>>;
  30023. }
  30024. }
  30025. declare module BABYLON {
  30026. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30027. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30028. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30029. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30030. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30031. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30032. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30033. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30034. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30035. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30036. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30037. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30038. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30039. /**
  30040. * Decorator used to define property that can be serialized as reference to a camera
  30041. * @param sourceName defines the name of the property to decorate
  30042. */
  30043. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30044. /**
  30045. * Class used to help serialization objects
  30046. */
  30047. export class SerializationHelper {
  30048. /** @hidden */
  30049. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30050. /** @hidden */
  30051. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30052. /** @hidden */
  30053. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30054. /** @hidden */
  30055. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30056. /**
  30057. * Appends the serialized animations from the source animations
  30058. * @param source Source containing the animations
  30059. * @param destination Target to store the animations
  30060. */
  30061. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30062. /**
  30063. * Static function used to serialized a specific entity
  30064. * @param entity defines the entity to serialize
  30065. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30066. * @returns a JSON compatible object representing the serialization of the entity
  30067. */
  30068. static Serialize<T>(entity: T, serializationObject?: any): any;
  30069. /**
  30070. * Creates a new entity from a serialization data object
  30071. * @param creationFunction defines a function used to instanciated the new entity
  30072. * @param source defines the source serialization data
  30073. * @param scene defines the hosting scene
  30074. * @param rootUrl defines the root url for resources
  30075. * @returns a new entity
  30076. */
  30077. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30078. /**
  30079. * Clones an object
  30080. * @param creationFunction defines the function used to instanciate the new object
  30081. * @param source defines the source object
  30082. * @returns the cloned object
  30083. */
  30084. static Clone<T>(creationFunction: () => T, source: T): T;
  30085. /**
  30086. * Instanciates a new object based on a source one (some data will be shared between both object)
  30087. * @param creationFunction defines the function used to instanciate the new object
  30088. * @param source defines the source object
  30089. * @returns the new object
  30090. */
  30091. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30092. }
  30093. }
  30094. declare module BABYLON {
  30095. /**
  30096. * Base class of all the textures in babylon.
  30097. * It groups all the common properties the materials, post process, lights... might need
  30098. * in order to make a correct use of the texture.
  30099. */
  30100. export class BaseTexture implements IAnimatable {
  30101. /**
  30102. * Default anisotropic filtering level for the application.
  30103. * It is set to 4 as a good tradeoff between perf and quality.
  30104. */
  30105. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30106. /**
  30107. * Gets or sets the unique id of the texture
  30108. */
  30109. uniqueId: number;
  30110. /**
  30111. * Define the name of the texture.
  30112. */
  30113. name: string;
  30114. /**
  30115. * Gets or sets an object used to store user defined information.
  30116. */
  30117. metadata: any;
  30118. /**
  30119. * For internal use only. Please do not use.
  30120. */
  30121. reservedDataStore: any;
  30122. private _hasAlpha;
  30123. /**
  30124. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30125. */
  30126. set hasAlpha(value: boolean);
  30127. get hasAlpha(): boolean;
  30128. /**
  30129. * Defines if the alpha value should be determined via the rgb values.
  30130. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30131. */
  30132. getAlphaFromRGB: boolean;
  30133. /**
  30134. * Intensity or strength of the texture.
  30135. * It is commonly used by materials to fine tune the intensity of the texture
  30136. */
  30137. level: number;
  30138. /**
  30139. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30140. * This is part of the texture as textures usually maps to one uv set.
  30141. */
  30142. coordinatesIndex: number;
  30143. private _coordinatesMode;
  30144. /**
  30145. * How a texture is mapped.
  30146. *
  30147. * | Value | Type | Description |
  30148. * | ----- | ----------------------------------- | ----------- |
  30149. * | 0 | EXPLICIT_MODE | |
  30150. * | 1 | SPHERICAL_MODE | |
  30151. * | 2 | PLANAR_MODE | |
  30152. * | 3 | CUBIC_MODE | |
  30153. * | 4 | PROJECTION_MODE | |
  30154. * | 5 | SKYBOX_MODE | |
  30155. * | 6 | INVCUBIC_MODE | |
  30156. * | 7 | EQUIRECTANGULAR_MODE | |
  30157. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30158. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30159. */
  30160. set coordinatesMode(value: number);
  30161. get coordinatesMode(): number;
  30162. /**
  30163. * | Value | Type | Description |
  30164. * | ----- | ------------------ | ----------- |
  30165. * | 0 | CLAMP_ADDRESSMODE | |
  30166. * | 1 | WRAP_ADDRESSMODE | |
  30167. * | 2 | MIRROR_ADDRESSMODE | |
  30168. */
  30169. wrapU: number;
  30170. /**
  30171. * | Value | Type | Description |
  30172. * | ----- | ------------------ | ----------- |
  30173. * | 0 | CLAMP_ADDRESSMODE | |
  30174. * | 1 | WRAP_ADDRESSMODE | |
  30175. * | 2 | MIRROR_ADDRESSMODE | |
  30176. */
  30177. wrapV: number;
  30178. /**
  30179. * | Value | Type | Description |
  30180. * | ----- | ------------------ | ----------- |
  30181. * | 0 | CLAMP_ADDRESSMODE | |
  30182. * | 1 | WRAP_ADDRESSMODE | |
  30183. * | 2 | MIRROR_ADDRESSMODE | |
  30184. */
  30185. wrapR: number;
  30186. /**
  30187. * With compliant hardware and browser (supporting anisotropic filtering)
  30188. * this defines the level of anisotropic filtering in the texture.
  30189. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30190. */
  30191. anisotropicFilteringLevel: number;
  30192. /**
  30193. * Define if the texture is a cube texture or if false a 2d texture.
  30194. */
  30195. get isCube(): boolean;
  30196. set isCube(value: boolean);
  30197. /**
  30198. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30199. */
  30200. get is3D(): boolean;
  30201. set is3D(value: boolean);
  30202. /**
  30203. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30204. */
  30205. get is2DArray(): boolean;
  30206. set is2DArray(value: boolean);
  30207. /**
  30208. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30209. * HDR texture are usually stored in linear space.
  30210. * This only impacts the PBR and Background materials
  30211. */
  30212. gammaSpace: boolean;
  30213. /**
  30214. * Gets or sets whether or not the texture contains RGBD data.
  30215. */
  30216. get isRGBD(): boolean;
  30217. set isRGBD(value: boolean);
  30218. /**
  30219. * Is Z inverted in the texture (useful in a cube texture).
  30220. */
  30221. invertZ: boolean;
  30222. /**
  30223. * Are mip maps generated for this texture or not.
  30224. */
  30225. get noMipmap(): boolean;
  30226. /**
  30227. * @hidden
  30228. */
  30229. lodLevelInAlpha: boolean;
  30230. /**
  30231. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30232. */
  30233. get lodGenerationOffset(): number;
  30234. set lodGenerationOffset(value: number);
  30235. /**
  30236. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30237. */
  30238. get lodGenerationScale(): number;
  30239. set lodGenerationScale(value: number);
  30240. /**
  30241. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30242. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30243. * average roughness values.
  30244. */
  30245. get linearSpecularLOD(): boolean;
  30246. set linearSpecularLOD(value: boolean);
  30247. /**
  30248. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30249. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30250. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30251. */
  30252. get irradianceTexture(): Nullable<BaseTexture>;
  30253. set irradianceTexture(value: Nullable<BaseTexture>);
  30254. /**
  30255. * Define if the texture is a render target.
  30256. */
  30257. isRenderTarget: boolean;
  30258. /**
  30259. * Define the unique id of the texture in the scene.
  30260. */
  30261. get uid(): string;
  30262. /**
  30263. * Return a string representation of the texture.
  30264. * @returns the texture as a string
  30265. */
  30266. toString(): string;
  30267. /**
  30268. * Get the class name of the texture.
  30269. * @returns "BaseTexture"
  30270. */
  30271. getClassName(): string;
  30272. /**
  30273. * Define the list of animation attached to the texture.
  30274. */
  30275. animations: Animation[];
  30276. /**
  30277. * An event triggered when the texture is disposed.
  30278. */
  30279. onDisposeObservable: Observable<BaseTexture>;
  30280. private _onDisposeObserver;
  30281. /**
  30282. * Callback triggered when the texture has been disposed.
  30283. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30284. */
  30285. set onDispose(callback: () => void);
  30286. /**
  30287. * Define the current state of the loading sequence when in delayed load mode.
  30288. */
  30289. delayLoadState: number;
  30290. private _scene;
  30291. /** @hidden */
  30292. _texture: Nullable<InternalTexture>;
  30293. private _uid;
  30294. /**
  30295. * Define if the texture is preventinga material to render or not.
  30296. * If not and the texture is not ready, the engine will use a default black texture instead.
  30297. */
  30298. get isBlocking(): boolean;
  30299. /**
  30300. * Instantiates a new BaseTexture.
  30301. * Base class of all the textures in babylon.
  30302. * It groups all the common properties the materials, post process, lights... might need
  30303. * in order to make a correct use of the texture.
  30304. * @param scene Define the scene the texture blongs to
  30305. */
  30306. constructor(scene: Nullable<Scene>);
  30307. /**
  30308. * Get the scene the texture belongs to.
  30309. * @returns the scene or null if undefined
  30310. */
  30311. getScene(): Nullable<Scene>;
  30312. /**
  30313. * Get the texture transform matrix used to offset tile the texture for istance.
  30314. * @returns the transformation matrix
  30315. */
  30316. getTextureMatrix(): Matrix;
  30317. /**
  30318. * Get the texture reflection matrix used to rotate/transform the reflection.
  30319. * @returns the reflection matrix
  30320. */
  30321. getReflectionTextureMatrix(): Matrix;
  30322. /**
  30323. * Get the underlying lower level texture from Babylon.
  30324. * @returns the insternal texture
  30325. */
  30326. getInternalTexture(): Nullable<InternalTexture>;
  30327. /**
  30328. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30329. * @returns true if ready or not blocking
  30330. */
  30331. isReadyOrNotBlocking(): boolean;
  30332. /**
  30333. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30334. * @returns true if fully ready
  30335. */
  30336. isReady(): boolean;
  30337. private _cachedSize;
  30338. /**
  30339. * Get the size of the texture.
  30340. * @returns the texture size.
  30341. */
  30342. getSize(): ISize;
  30343. /**
  30344. * Get the base size of the texture.
  30345. * It can be different from the size if the texture has been resized for POT for instance
  30346. * @returns the base size
  30347. */
  30348. getBaseSize(): ISize;
  30349. /**
  30350. * Update the sampling mode of the texture.
  30351. * Default is Trilinear mode.
  30352. *
  30353. * | Value | Type | Description |
  30354. * | ----- | ------------------ | ----------- |
  30355. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30356. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30357. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30358. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30359. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30360. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30361. * | 7 | NEAREST_LINEAR | |
  30362. * | 8 | NEAREST_NEAREST | |
  30363. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30364. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30365. * | 11 | LINEAR_LINEAR | |
  30366. * | 12 | LINEAR_NEAREST | |
  30367. *
  30368. * > _mag_: magnification filter (close to the viewer)
  30369. * > _min_: minification filter (far from the viewer)
  30370. * > _mip_: filter used between mip map levels
  30371. *@param samplingMode Define the new sampling mode of the texture
  30372. */
  30373. updateSamplingMode(samplingMode: number): void;
  30374. /**
  30375. * Scales the texture if is `canRescale()`
  30376. * @param ratio the resize factor we want to use to rescale
  30377. */
  30378. scale(ratio: number): void;
  30379. /**
  30380. * Get if the texture can rescale.
  30381. */
  30382. get canRescale(): boolean;
  30383. /** @hidden */
  30384. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30385. /** @hidden */
  30386. _rebuild(): void;
  30387. /**
  30388. * Triggers the load sequence in delayed load mode.
  30389. */
  30390. delayLoad(): void;
  30391. /**
  30392. * Clones the texture.
  30393. * @returns the cloned texture
  30394. */
  30395. clone(): Nullable<BaseTexture>;
  30396. /**
  30397. * Get the texture underlying type (INT, FLOAT...)
  30398. */
  30399. get textureType(): number;
  30400. /**
  30401. * Get the texture underlying format (RGB, RGBA...)
  30402. */
  30403. get textureFormat(): number;
  30404. /**
  30405. * Indicates that textures need to be re-calculated for all materials
  30406. */
  30407. protected _markAllSubMeshesAsTexturesDirty(): void;
  30408. /**
  30409. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30410. * This will returns an RGBA array buffer containing either in values (0-255) or
  30411. * float values (0-1) depending of the underlying buffer type.
  30412. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30413. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30414. * @param buffer defines a user defined buffer to fill with data (can be null)
  30415. * @returns The Array buffer containing the pixels data.
  30416. */
  30417. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30418. /**
  30419. * Release and destroy the underlying lower level texture aka internalTexture.
  30420. */
  30421. releaseInternalTexture(): void;
  30422. /** @hidden */
  30423. get _lodTextureHigh(): Nullable<BaseTexture>;
  30424. /** @hidden */
  30425. get _lodTextureMid(): Nullable<BaseTexture>;
  30426. /** @hidden */
  30427. get _lodTextureLow(): Nullable<BaseTexture>;
  30428. /**
  30429. * Dispose the texture and release its associated resources.
  30430. */
  30431. dispose(): void;
  30432. /**
  30433. * Serialize the texture into a JSON representation that can be parsed later on.
  30434. * @returns the JSON representation of the texture
  30435. */
  30436. serialize(): any;
  30437. /**
  30438. * Helper function to be called back once a list of texture contains only ready textures.
  30439. * @param textures Define the list of textures to wait for
  30440. * @param callback Define the callback triggered once the entire list will be ready
  30441. */
  30442. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30443. }
  30444. }
  30445. declare module BABYLON {
  30446. /**
  30447. * Options to be used when creating an effect.
  30448. */
  30449. export interface IEffectCreationOptions {
  30450. /**
  30451. * Atrributes that will be used in the shader.
  30452. */
  30453. attributes: string[];
  30454. /**
  30455. * Uniform varible names that will be set in the shader.
  30456. */
  30457. uniformsNames: string[];
  30458. /**
  30459. * Uniform buffer variable names that will be set in the shader.
  30460. */
  30461. uniformBuffersNames: string[];
  30462. /**
  30463. * Sampler texture variable names that will be set in the shader.
  30464. */
  30465. samplers: string[];
  30466. /**
  30467. * Define statements that will be set in the shader.
  30468. */
  30469. defines: any;
  30470. /**
  30471. * Possible fallbacks for this effect to improve performance when needed.
  30472. */
  30473. fallbacks: Nullable<IEffectFallbacks>;
  30474. /**
  30475. * Callback that will be called when the shader is compiled.
  30476. */
  30477. onCompiled: Nullable<(effect: Effect) => void>;
  30478. /**
  30479. * Callback that will be called if an error occurs during shader compilation.
  30480. */
  30481. onError: Nullable<(effect: Effect, errors: string) => void>;
  30482. /**
  30483. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30484. */
  30485. indexParameters?: any;
  30486. /**
  30487. * Max number of lights that can be used in the shader.
  30488. */
  30489. maxSimultaneousLights?: number;
  30490. /**
  30491. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30492. */
  30493. transformFeedbackVaryings?: Nullable<string[]>;
  30494. }
  30495. /**
  30496. * Effect containing vertex and fragment shader that can be executed on an object.
  30497. */
  30498. export class Effect implements IDisposable {
  30499. /**
  30500. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30501. */
  30502. static ShadersRepository: string;
  30503. /**
  30504. * Enable logging of the shader code when a compilation error occurs
  30505. */
  30506. static LogShaderCodeOnCompilationError: boolean;
  30507. /**
  30508. * Name of the effect.
  30509. */
  30510. name: any;
  30511. /**
  30512. * String container all the define statements that should be set on the shader.
  30513. */
  30514. defines: string;
  30515. /**
  30516. * Callback that will be called when the shader is compiled.
  30517. */
  30518. onCompiled: Nullable<(effect: Effect) => void>;
  30519. /**
  30520. * Callback that will be called if an error occurs during shader compilation.
  30521. */
  30522. onError: Nullable<(effect: Effect, errors: string) => void>;
  30523. /**
  30524. * Callback that will be called when effect is bound.
  30525. */
  30526. onBind: Nullable<(effect: Effect) => void>;
  30527. /**
  30528. * Unique ID of the effect.
  30529. */
  30530. uniqueId: number;
  30531. /**
  30532. * Observable that will be called when the shader is compiled.
  30533. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30534. */
  30535. onCompileObservable: Observable<Effect>;
  30536. /**
  30537. * Observable that will be called if an error occurs during shader compilation.
  30538. */
  30539. onErrorObservable: Observable<Effect>;
  30540. /** @hidden */
  30541. _onBindObservable: Nullable<Observable<Effect>>;
  30542. /**
  30543. * @hidden
  30544. * Specifies if the effect was previously ready
  30545. */
  30546. _wasPreviouslyReady: boolean;
  30547. /**
  30548. * Observable that will be called when effect is bound.
  30549. */
  30550. get onBindObservable(): Observable<Effect>;
  30551. /** @hidden */
  30552. _bonesComputationForcedToCPU: boolean;
  30553. private static _uniqueIdSeed;
  30554. private _engine;
  30555. private _uniformBuffersNames;
  30556. private _uniformBuffersNamesList;
  30557. private _uniformsNames;
  30558. private _samplerList;
  30559. private _samplers;
  30560. private _isReady;
  30561. private _compilationError;
  30562. private _allFallbacksProcessed;
  30563. private _attributesNames;
  30564. private _attributes;
  30565. private _attributeLocationByName;
  30566. private _uniforms;
  30567. /**
  30568. * Key for the effect.
  30569. * @hidden
  30570. */
  30571. _key: string;
  30572. private _indexParameters;
  30573. private _fallbacks;
  30574. private _vertexSourceCode;
  30575. private _fragmentSourceCode;
  30576. private _vertexSourceCodeOverride;
  30577. private _fragmentSourceCodeOverride;
  30578. private _transformFeedbackVaryings;
  30579. /**
  30580. * Compiled shader to webGL program.
  30581. * @hidden
  30582. */
  30583. _pipelineContext: Nullable<IPipelineContext>;
  30584. private _valueCache;
  30585. private static _baseCache;
  30586. /**
  30587. * Instantiates an effect.
  30588. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30589. * @param baseName Name of the effect.
  30590. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30591. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30592. * @param samplers List of sampler variables that will be passed to the shader.
  30593. * @param engine Engine to be used to render the effect
  30594. * @param defines Define statements to be added to the shader.
  30595. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30596. * @param onCompiled Callback that will be called when the shader is compiled.
  30597. * @param onError Callback that will be called if an error occurs during shader compilation.
  30598. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30599. */
  30600. 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);
  30601. private _useFinalCode;
  30602. /**
  30603. * Unique key for this effect
  30604. */
  30605. get key(): string;
  30606. /**
  30607. * If the effect has been compiled and prepared.
  30608. * @returns if the effect is compiled and prepared.
  30609. */
  30610. isReady(): boolean;
  30611. private _isReadyInternal;
  30612. /**
  30613. * The engine the effect was initialized with.
  30614. * @returns the engine.
  30615. */
  30616. getEngine(): Engine;
  30617. /**
  30618. * The pipeline context for this effect
  30619. * @returns the associated pipeline context
  30620. */
  30621. getPipelineContext(): Nullable<IPipelineContext>;
  30622. /**
  30623. * The set of names of attribute variables for the shader.
  30624. * @returns An array of attribute names.
  30625. */
  30626. getAttributesNames(): string[];
  30627. /**
  30628. * Returns the attribute at the given index.
  30629. * @param index The index of the attribute.
  30630. * @returns The location of the attribute.
  30631. */
  30632. getAttributeLocation(index: number): number;
  30633. /**
  30634. * Returns the attribute based on the name of the variable.
  30635. * @param name of the attribute to look up.
  30636. * @returns the attribute location.
  30637. */
  30638. getAttributeLocationByName(name: string): number;
  30639. /**
  30640. * The number of attributes.
  30641. * @returns the numnber of attributes.
  30642. */
  30643. getAttributesCount(): number;
  30644. /**
  30645. * Gets the index of a uniform variable.
  30646. * @param uniformName of the uniform to look up.
  30647. * @returns the index.
  30648. */
  30649. getUniformIndex(uniformName: string): number;
  30650. /**
  30651. * Returns the attribute based on the name of the variable.
  30652. * @param uniformName of the uniform to look up.
  30653. * @returns the location of the uniform.
  30654. */
  30655. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30656. /**
  30657. * Returns an array of sampler variable names
  30658. * @returns The array of sampler variable names.
  30659. */
  30660. getSamplers(): string[];
  30661. /**
  30662. * Returns an array of uniform variable names
  30663. * @returns The array of uniform variable names.
  30664. */
  30665. getUniformNames(): string[];
  30666. /**
  30667. * Returns an array of uniform buffer variable names
  30668. * @returns The array of uniform buffer variable names.
  30669. */
  30670. getUniformBuffersNames(): string[];
  30671. /**
  30672. * Returns the index parameters used to create the effect
  30673. * @returns The index parameters object
  30674. */
  30675. getIndexParameters(): any;
  30676. /**
  30677. * The error from the last compilation.
  30678. * @returns the error string.
  30679. */
  30680. getCompilationError(): string;
  30681. /**
  30682. * Gets a boolean indicating that all fallbacks were used during compilation
  30683. * @returns true if all fallbacks were used
  30684. */
  30685. allFallbacksProcessed(): boolean;
  30686. /**
  30687. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30688. * @param func The callback to be used.
  30689. */
  30690. executeWhenCompiled(func: (effect: Effect) => void): void;
  30691. private _checkIsReady;
  30692. private _loadShader;
  30693. /**
  30694. * Gets the vertex shader source code of this effect
  30695. */
  30696. get vertexSourceCode(): string;
  30697. /**
  30698. * Gets the fragment shader source code of this effect
  30699. */
  30700. get fragmentSourceCode(): string;
  30701. /**
  30702. * Recompiles the webGL program
  30703. * @param vertexSourceCode The source code for the vertex shader.
  30704. * @param fragmentSourceCode The source code for the fragment shader.
  30705. * @param onCompiled Callback called when completed.
  30706. * @param onError Callback called on error.
  30707. * @hidden
  30708. */
  30709. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30710. /**
  30711. * Prepares the effect
  30712. * @hidden
  30713. */
  30714. _prepareEffect(): void;
  30715. private _getShaderCodeAndErrorLine;
  30716. private _processCompilationErrors;
  30717. /**
  30718. * Checks if the effect is supported. (Must be called after compilation)
  30719. */
  30720. get isSupported(): boolean;
  30721. /**
  30722. * Binds a texture to the engine to be used as output of the shader.
  30723. * @param channel Name of the output variable.
  30724. * @param texture Texture to bind.
  30725. * @hidden
  30726. */
  30727. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30728. /**
  30729. * Sets a texture on the engine to be used in the shader.
  30730. * @param channel Name of the sampler variable.
  30731. * @param texture Texture to set.
  30732. */
  30733. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30734. /**
  30735. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30736. * @param channel Name of the sampler variable.
  30737. * @param texture Texture to set.
  30738. */
  30739. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30740. /**
  30741. * Sets an array of textures on the engine to be used in the shader.
  30742. * @param channel Name of the variable.
  30743. * @param textures Textures to set.
  30744. */
  30745. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30746. /**
  30747. * 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)
  30748. * @param channel Name of the sampler variable.
  30749. * @param postProcess Post process to get the input texture from.
  30750. */
  30751. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30752. /**
  30753. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30754. * 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)
  30755. * @param channel Name of the sampler variable.
  30756. * @param postProcess Post process to get the output texture from.
  30757. */
  30758. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30759. /** @hidden */
  30760. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30761. /** @hidden */
  30762. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30763. /** @hidden */
  30764. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30765. /** @hidden */
  30766. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30767. /**
  30768. * Binds a buffer to a uniform.
  30769. * @param buffer Buffer to bind.
  30770. * @param name Name of the uniform variable to bind to.
  30771. */
  30772. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30773. /**
  30774. * Binds block to a uniform.
  30775. * @param blockName Name of the block to bind.
  30776. * @param index Index to bind.
  30777. */
  30778. bindUniformBlock(blockName: string, index: number): void;
  30779. /**
  30780. * Sets an interger value on a uniform variable.
  30781. * @param uniformName Name of the variable.
  30782. * @param value Value to be set.
  30783. * @returns this effect.
  30784. */
  30785. setInt(uniformName: string, value: number): Effect;
  30786. /**
  30787. * Sets an int array on a uniform variable.
  30788. * @param uniformName Name of the variable.
  30789. * @param array array to be set.
  30790. * @returns this effect.
  30791. */
  30792. setIntArray(uniformName: string, array: Int32Array): Effect;
  30793. /**
  30794. * 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)
  30795. * @param uniformName Name of the variable.
  30796. * @param array array to be set.
  30797. * @returns this effect.
  30798. */
  30799. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30800. /**
  30801. * 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)
  30802. * @param uniformName Name of the variable.
  30803. * @param array array to be set.
  30804. * @returns this effect.
  30805. */
  30806. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30807. /**
  30808. * 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)
  30809. * @param uniformName Name of the variable.
  30810. * @param array array to be set.
  30811. * @returns this effect.
  30812. */
  30813. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30814. /**
  30815. * Sets an float array on a uniform variable.
  30816. * @param uniformName Name of the variable.
  30817. * @param array array to be set.
  30818. * @returns this effect.
  30819. */
  30820. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30821. /**
  30822. * 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)
  30823. * @param uniformName Name of the variable.
  30824. * @param array array to be set.
  30825. * @returns this effect.
  30826. */
  30827. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30828. /**
  30829. * 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)
  30830. * @param uniformName Name of the variable.
  30831. * @param array array to be set.
  30832. * @returns this effect.
  30833. */
  30834. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30835. /**
  30836. * 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)
  30837. * @param uniformName Name of the variable.
  30838. * @param array array to be set.
  30839. * @returns this effect.
  30840. */
  30841. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30842. /**
  30843. * Sets an array on a uniform variable.
  30844. * @param uniformName Name of the variable.
  30845. * @param array array to be set.
  30846. * @returns this effect.
  30847. */
  30848. setArray(uniformName: string, array: number[]): Effect;
  30849. /**
  30850. * 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)
  30851. * @param uniformName Name of the variable.
  30852. * @param array array to be set.
  30853. * @returns this effect.
  30854. */
  30855. setArray2(uniformName: string, array: number[]): Effect;
  30856. /**
  30857. * 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)
  30858. * @param uniformName Name of the variable.
  30859. * @param array array to be set.
  30860. * @returns this effect.
  30861. */
  30862. setArray3(uniformName: string, array: number[]): Effect;
  30863. /**
  30864. * 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)
  30865. * @param uniformName Name of the variable.
  30866. * @param array array to be set.
  30867. * @returns this effect.
  30868. */
  30869. setArray4(uniformName: string, array: number[]): Effect;
  30870. /**
  30871. * Sets matrices on a uniform variable.
  30872. * @param uniformName Name of the variable.
  30873. * @param matrices matrices to be set.
  30874. * @returns this effect.
  30875. */
  30876. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30877. /**
  30878. * Sets matrix on a uniform variable.
  30879. * @param uniformName Name of the variable.
  30880. * @param matrix matrix to be set.
  30881. * @returns this effect.
  30882. */
  30883. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30884. /**
  30885. * 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)
  30886. * @param uniformName Name of the variable.
  30887. * @param matrix matrix to be set.
  30888. * @returns this effect.
  30889. */
  30890. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30891. /**
  30892. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30893. * @param uniformName Name of the variable.
  30894. * @param matrix matrix to be set.
  30895. * @returns this effect.
  30896. */
  30897. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30898. /**
  30899. * Sets a float on a uniform variable.
  30900. * @param uniformName Name of the variable.
  30901. * @param value value to be set.
  30902. * @returns this effect.
  30903. */
  30904. setFloat(uniformName: string, value: number): Effect;
  30905. /**
  30906. * Sets a boolean on a uniform variable.
  30907. * @param uniformName Name of the variable.
  30908. * @param bool value to be set.
  30909. * @returns this effect.
  30910. */
  30911. setBool(uniformName: string, bool: boolean): Effect;
  30912. /**
  30913. * Sets a Vector2 on a uniform variable.
  30914. * @param uniformName Name of the variable.
  30915. * @param vector2 vector2 to be set.
  30916. * @returns this effect.
  30917. */
  30918. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30919. /**
  30920. * Sets a float2 on a uniform variable.
  30921. * @param uniformName Name of the variable.
  30922. * @param x First float in float2.
  30923. * @param y Second float in float2.
  30924. * @returns this effect.
  30925. */
  30926. setFloat2(uniformName: string, x: number, y: number): Effect;
  30927. /**
  30928. * Sets a Vector3 on a uniform variable.
  30929. * @param uniformName Name of the variable.
  30930. * @param vector3 Value to be set.
  30931. * @returns this effect.
  30932. */
  30933. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30934. /**
  30935. * Sets a float3 on a uniform variable.
  30936. * @param uniformName Name of the variable.
  30937. * @param x First float in float3.
  30938. * @param y Second float in float3.
  30939. * @param z Third float in float3.
  30940. * @returns this effect.
  30941. */
  30942. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30943. /**
  30944. * Sets a Vector4 on a uniform variable.
  30945. * @param uniformName Name of the variable.
  30946. * @param vector4 Value to be set.
  30947. * @returns this effect.
  30948. */
  30949. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30950. /**
  30951. * Sets a float4 on a uniform variable.
  30952. * @param uniformName Name of the variable.
  30953. * @param x First float in float4.
  30954. * @param y Second float in float4.
  30955. * @param z Third float in float4.
  30956. * @param w Fourth float in float4.
  30957. * @returns this effect.
  30958. */
  30959. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30960. /**
  30961. * Sets a Color3 on a uniform variable.
  30962. * @param uniformName Name of the variable.
  30963. * @param color3 Value to be set.
  30964. * @returns this effect.
  30965. */
  30966. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30967. /**
  30968. * Sets a Color4 on a uniform variable.
  30969. * @param uniformName Name of the variable.
  30970. * @param color3 Value to be set.
  30971. * @param alpha Alpha value to be set.
  30972. * @returns this effect.
  30973. */
  30974. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30975. /**
  30976. * Sets a Color4 on a uniform variable
  30977. * @param uniformName defines the name of the variable
  30978. * @param color4 defines the value to be set
  30979. * @returns this effect.
  30980. */
  30981. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30982. /** Release all associated resources */
  30983. dispose(): void;
  30984. /**
  30985. * This function will add a new shader to the shader store
  30986. * @param name the name of the shader
  30987. * @param pixelShader optional pixel shader content
  30988. * @param vertexShader optional vertex shader content
  30989. */
  30990. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30991. /**
  30992. * Store of each shader (The can be looked up using effect.key)
  30993. */
  30994. static ShadersStore: {
  30995. [key: string]: string;
  30996. };
  30997. /**
  30998. * Store of each included file for a shader (The can be looked up using effect.key)
  30999. */
  31000. static IncludesShadersStore: {
  31001. [key: string]: string;
  31002. };
  31003. /**
  31004. * Resets the cache of effects.
  31005. */
  31006. static ResetCache(): void;
  31007. }
  31008. }
  31009. declare module BABYLON {
  31010. /**
  31011. * Interface used to describe the capabilities of the engine relatively to the current browser
  31012. */
  31013. export interface EngineCapabilities {
  31014. /** Maximum textures units per fragment shader */
  31015. maxTexturesImageUnits: number;
  31016. /** Maximum texture units per vertex shader */
  31017. maxVertexTextureImageUnits: number;
  31018. /** Maximum textures units in the entire pipeline */
  31019. maxCombinedTexturesImageUnits: number;
  31020. /** Maximum texture size */
  31021. maxTextureSize: number;
  31022. /** Maximum texture samples */
  31023. maxSamples?: number;
  31024. /** Maximum cube texture size */
  31025. maxCubemapTextureSize: number;
  31026. /** Maximum render texture size */
  31027. maxRenderTextureSize: number;
  31028. /** Maximum number of vertex attributes */
  31029. maxVertexAttribs: number;
  31030. /** Maximum number of varyings */
  31031. maxVaryingVectors: number;
  31032. /** Maximum number of uniforms per vertex shader */
  31033. maxVertexUniformVectors: number;
  31034. /** Maximum number of uniforms per fragment shader */
  31035. maxFragmentUniformVectors: number;
  31036. /** Defines if standard derivates (dx/dy) are supported */
  31037. standardDerivatives: boolean;
  31038. /** Defines if s3tc texture compression is supported */
  31039. s3tc?: WEBGL_compressed_texture_s3tc;
  31040. /** Defines if pvrtc texture compression is supported */
  31041. pvrtc: any;
  31042. /** Defines if etc1 texture compression is supported */
  31043. etc1: any;
  31044. /** Defines if etc2 texture compression is supported */
  31045. etc2: any;
  31046. /** Defines if astc texture compression is supported */
  31047. astc: any;
  31048. /** Defines if float textures are supported */
  31049. textureFloat: boolean;
  31050. /** Defines if vertex array objects are supported */
  31051. vertexArrayObject: boolean;
  31052. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31053. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31054. /** Gets the maximum level of anisotropy supported */
  31055. maxAnisotropy: number;
  31056. /** Defines if instancing is supported */
  31057. instancedArrays: boolean;
  31058. /** Defines if 32 bits indices are supported */
  31059. uintIndices: boolean;
  31060. /** Defines if high precision shaders are supported */
  31061. highPrecisionShaderSupported: boolean;
  31062. /** Defines if depth reading in the fragment shader is supported */
  31063. fragmentDepthSupported: boolean;
  31064. /** Defines if float texture linear filtering is supported*/
  31065. textureFloatLinearFiltering: boolean;
  31066. /** Defines if rendering to float textures is supported */
  31067. textureFloatRender: boolean;
  31068. /** Defines if half float textures are supported*/
  31069. textureHalfFloat: boolean;
  31070. /** Defines if half float texture linear filtering is supported*/
  31071. textureHalfFloatLinearFiltering: boolean;
  31072. /** Defines if rendering to half float textures is supported */
  31073. textureHalfFloatRender: boolean;
  31074. /** Defines if textureLOD shader command is supported */
  31075. textureLOD: boolean;
  31076. /** Defines if draw buffers extension is supported */
  31077. drawBuffersExtension: boolean;
  31078. /** Defines if depth textures are supported */
  31079. depthTextureExtension: boolean;
  31080. /** Defines if float color buffer are supported */
  31081. colorBufferFloat: boolean;
  31082. /** Gets disjoint timer query extension (null if not supported) */
  31083. timerQuery?: EXT_disjoint_timer_query;
  31084. /** Defines if timestamp can be used with timer query */
  31085. canUseTimestampForTimerQuery: boolean;
  31086. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31087. multiview?: any;
  31088. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31089. oculusMultiview?: any;
  31090. /** Function used to let the system compiles shaders in background */
  31091. parallelShaderCompile?: {
  31092. COMPLETION_STATUS_KHR: number;
  31093. };
  31094. /** Max number of texture samples for MSAA */
  31095. maxMSAASamples: number;
  31096. /** Defines if the blend min max extension is supported */
  31097. blendMinMax: boolean;
  31098. }
  31099. }
  31100. declare module BABYLON {
  31101. /**
  31102. * @hidden
  31103. **/
  31104. export class DepthCullingState {
  31105. private _isDepthTestDirty;
  31106. private _isDepthMaskDirty;
  31107. private _isDepthFuncDirty;
  31108. private _isCullFaceDirty;
  31109. private _isCullDirty;
  31110. private _isZOffsetDirty;
  31111. private _isFrontFaceDirty;
  31112. private _depthTest;
  31113. private _depthMask;
  31114. private _depthFunc;
  31115. private _cull;
  31116. private _cullFace;
  31117. private _zOffset;
  31118. private _frontFace;
  31119. /**
  31120. * Initializes the state.
  31121. */
  31122. constructor();
  31123. get isDirty(): boolean;
  31124. get zOffset(): number;
  31125. set zOffset(value: number);
  31126. get cullFace(): Nullable<number>;
  31127. set cullFace(value: Nullable<number>);
  31128. get cull(): Nullable<boolean>;
  31129. set cull(value: Nullable<boolean>);
  31130. get depthFunc(): Nullable<number>;
  31131. set depthFunc(value: Nullable<number>);
  31132. get depthMask(): boolean;
  31133. set depthMask(value: boolean);
  31134. get depthTest(): boolean;
  31135. set depthTest(value: boolean);
  31136. get frontFace(): Nullable<number>;
  31137. set frontFace(value: Nullable<number>);
  31138. reset(): void;
  31139. apply(gl: WebGLRenderingContext): void;
  31140. }
  31141. }
  31142. declare module BABYLON {
  31143. /**
  31144. * @hidden
  31145. **/
  31146. export class StencilState {
  31147. /** 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 */
  31148. static readonly ALWAYS: number;
  31149. /** Passed to stencilOperation to specify that stencil value must be kept */
  31150. static readonly KEEP: number;
  31151. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31152. static readonly REPLACE: number;
  31153. private _isStencilTestDirty;
  31154. private _isStencilMaskDirty;
  31155. private _isStencilFuncDirty;
  31156. private _isStencilOpDirty;
  31157. private _stencilTest;
  31158. private _stencilMask;
  31159. private _stencilFunc;
  31160. private _stencilFuncRef;
  31161. private _stencilFuncMask;
  31162. private _stencilOpStencilFail;
  31163. private _stencilOpDepthFail;
  31164. private _stencilOpStencilDepthPass;
  31165. get isDirty(): boolean;
  31166. get stencilFunc(): number;
  31167. set stencilFunc(value: number);
  31168. get stencilFuncRef(): number;
  31169. set stencilFuncRef(value: number);
  31170. get stencilFuncMask(): number;
  31171. set stencilFuncMask(value: number);
  31172. get stencilOpStencilFail(): number;
  31173. set stencilOpStencilFail(value: number);
  31174. get stencilOpDepthFail(): number;
  31175. set stencilOpDepthFail(value: number);
  31176. get stencilOpStencilDepthPass(): number;
  31177. set stencilOpStencilDepthPass(value: number);
  31178. get stencilMask(): number;
  31179. set stencilMask(value: number);
  31180. get stencilTest(): boolean;
  31181. set stencilTest(value: boolean);
  31182. constructor();
  31183. reset(): void;
  31184. apply(gl: WebGLRenderingContext): void;
  31185. }
  31186. }
  31187. declare module BABYLON {
  31188. /**
  31189. * @hidden
  31190. **/
  31191. export class AlphaState {
  31192. private _isAlphaBlendDirty;
  31193. private _isBlendFunctionParametersDirty;
  31194. private _isBlendEquationParametersDirty;
  31195. private _isBlendConstantsDirty;
  31196. private _alphaBlend;
  31197. private _blendFunctionParameters;
  31198. private _blendEquationParameters;
  31199. private _blendConstants;
  31200. /**
  31201. * Initializes the state.
  31202. */
  31203. constructor();
  31204. get isDirty(): boolean;
  31205. get alphaBlend(): boolean;
  31206. set alphaBlend(value: boolean);
  31207. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31208. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31209. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31210. reset(): void;
  31211. apply(gl: WebGLRenderingContext): void;
  31212. }
  31213. }
  31214. declare module BABYLON {
  31215. /** @hidden */
  31216. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31217. attributeProcessor(attribute: string): string;
  31218. varyingProcessor(varying: string, isFragment: boolean): string;
  31219. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31220. }
  31221. }
  31222. declare module BABYLON {
  31223. /**
  31224. * Interface for attribute information associated with buffer instanciation
  31225. */
  31226. export interface InstancingAttributeInfo {
  31227. /**
  31228. * Name of the GLSL attribute
  31229. * if attribute index is not specified, this is used to retrieve the index from the effect
  31230. */
  31231. attributeName: string;
  31232. /**
  31233. * Index/offset of the attribute in the vertex shader
  31234. * if not specified, this will be computes from the name.
  31235. */
  31236. index?: number;
  31237. /**
  31238. * size of the attribute, 1, 2, 3 or 4
  31239. */
  31240. attributeSize: number;
  31241. /**
  31242. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31243. */
  31244. offset: number;
  31245. /**
  31246. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31247. * default to 1
  31248. */
  31249. divisor?: number;
  31250. /**
  31251. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31252. * default is FLOAT
  31253. */
  31254. attributeType?: number;
  31255. /**
  31256. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31257. */
  31258. normalized?: boolean;
  31259. }
  31260. }
  31261. declare module BABYLON {
  31262. interface ThinEngine {
  31263. /**
  31264. * Update a video texture
  31265. * @param texture defines the texture to update
  31266. * @param video defines the video element to use
  31267. * @param invertY defines if data must be stored with Y axis inverted
  31268. */
  31269. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31270. }
  31271. }
  31272. declare module BABYLON {
  31273. /**
  31274. * Settings for finer control over video usage
  31275. */
  31276. export interface VideoTextureSettings {
  31277. /**
  31278. * Applies `autoplay` to video, if specified
  31279. */
  31280. autoPlay?: boolean;
  31281. /**
  31282. * Applies `loop` to video, if specified
  31283. */
  31284. loop?: boolean;
  31285. /**
  31286. * Automatically updates internal texture from video at every frame in the render loop
  31287. */
  31288. autoUpdateTexture: boolean;
  31289. /**
  31290. * Image src displayed during the video loading or until the user interacts with the video.
  31291. */
  31292. poster?: string;
  31293. }
  31294. /**
  31295. * If you want to display a video in your scene, this is the special texture for that.
  31296. * This special texture works similar to other textures, with the exception of a few parameters.
  31297. * @see https://doc.babylonjs.com/how_to/video_texture
  31298. */
  31299. export class VideoTexture extends Texture {
  31300. /**
  31301. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31302. */
  31303. readonly autoUpdateTexture: boolean;
  31304. /**
  31305. * The video instance used by the texture internally
  31306. */
  31307. readonly video: HTMLVideoElement;
  31308. private _onUserActionRequestedObservable;
  31309. /**
  31310. * Event triggerd when a dom action is required by the user to play the video.
  31311. * This happens due to recent changes in browser policies preventing video to auto start.
  31312. */
  31313. get onUserActionRequestedObservable(): Observable<Texture>;
  31314. private _generateMipMaps;
  31315. private _engine;
  31316. private _stillImageCaptured;
  31317. private _displayingPosterTexture;
  31318. private _settings;
  31319. private _createInternalTextureOnEvent;
  31320. private _frameId;
  31321. private _currentSrc;
  31322. /**
  31323. * Creates a video texture.
  31324. * If you want to display a video in your scene, this is the special texture for that.
  31325. * This special texture works similar to other textures, with the exception of a few parameters.
  31326. * @see https://doc.babylonjs.com/how_to/video_texture
  31327. * @param name optional name, will detect from video source, if not defined
  31328. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31329. * @param scene is obviously the current scene.
  31330. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31331. * @param invertY is false by default but can be used to invert video on Y axis
  31332. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31333. * @param settings allows finer control over video usage
  31334. */
  31335. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31336. private _getName;
  31337. private _getVideo;
  31338. private _createInternalTexture;
  31339. private reset;
  31340. /**
  31341. * @hidden Internal method to initiate `update`.
  31342. */
  31343. _rebuild(): void;
  31344. /**
  31345. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31346. */
  31347. update(): void;
  31348. /**
  31349. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31350. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31351. */
  31352. updateTexture(isVisible: boolean): void;
  31353. protected _updateInternalTexture: () => void;
  31354. /**
  31355. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31356. * @param url New url.
  31357. */
  31358. updateURL(url: string): void;
  31359. /**
  31360. * Clones the texture.
  31361. * @returns the cloned texture
  31362. */
  31363. clone(): VideoTexture;
  31364. /**
  31365. * Dispose the texture and release its associated resources.
  31366. */
  31367. dispose(): void;
  31368. /**
  31369. * Creates a video texture straight from a stream.
  31370. * @param scene Define the scene the texture should be created in
  31371. * @param stream Define the stream the texture should be created from
  31372. * @returns The created video texture as a promise
  31373. */
  31374. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31375. /**
  31376. * Creates a video texture straight from your WebCam video feed.
  31377. * @param scene Define the scene the texture should be created in
  31378. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31379. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31380. * @returns The created video texture as a promise
  31381. */
  31382. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31383. minWidth: number;
  31384. maxWidth: number;
  31385. minHeight: number;
  31386. maxHeight: number;
  31387. deviceId: string;
  31388. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31389. /**
  31390. * Creates a video texture straight from your WebCam video feed.
  31391. * @param scene Define the scene the texture should be created in
  31392. * @param onReady Define a callback to triggered once the texture will be ready
  31393. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31394. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31395. */
  31396. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31397. minWidth: number;
  31398. maxWidth: number;
  31399. minHeight: number;
  31400. maxHeight: number;
  31401. deviceId: string;
  31402. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31403. }
  31404. }
  31405. declare module BABYLON {
  31406. /**
  31407. * Defines the interface used by objects working like Scene
  31408. * @hidden
  31409. */
  31410. export interface ISceneLike {
  31411. _addPendingData(data: any): void;
  31412. _removePendingData(data: any): void;
  31413. offlineProvider: IOfflineProvider;
  31414. }
  31415. /** Interface defining initialization parameters for Engine class */
  31416. export interface EngineOptions extends WebGLContextAttributes {
  31417. /**
  31418. * Defines if the engine should no exceed a specified device ratio
  31419. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31420. */
  31421. limitDeviceRatio?: number;
  31422. /**
  31423. * Defines if webvr should be enabled automatically
  31424. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31425. */
  31426. autoEnableWebVR?: boolean;
  31427. /**
  31428. * Defines if webgl2 should be turned off even if supported
  31429. * @see http://doc.babylonjs.com/features/webgl2
  31430. */
  31431. disableWebGL2Support?: boolean;
  31432. /**
  31433. * Defines if webaudio should be initialized as well
  31434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31435. */
  31436. audioEngine?: boolean;
  31437. /**
  31438. * Defines if animations should run using a deterministic lock step
  31439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31440. */
  31441. deterministicLockstep?: boolean;
  31442. /** Defines the maximum steps to use with deterministic lock step mode */
  31443. lockstepMaxSteps?: number;
  31444. /** Defines the seconds between each deterministic lock step */
  31445. timeStep?: number;
  31446. /**
  31447. * Defines that engine should ignore context lost events
  31448. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31449. */
  31450. doNotHandleContextLost?: boolean;
  31451. /**
  31452. * Defines that engine should ignore modifying touch action attribute and style
  31453. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31454. */
  31455. doNotHandleTouchAction?: boolean;
  31456. /**
  31457. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31458. */
  31459. useHighPrecisionFloats?: boolean;
  31460. }
  31461. /**
  31462. * The base engine class (root of all engines)
  31463. */
  31464. export class ThinEngine {
  31465. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31466. static ExceptionList: ({
  31467. key: string;
  31468. capture: string;
  31469. captureConstraint: number;
  31470. targets: string[];
  31471. } | {
  31472. key: string;
  31473. capture: null;
  31474. captureConstraint: null;
  31475. targets: string[];
  31476. })[];
  31477. /** @hidden */
  31478. static _TextureLoaders: IInternalTextureLoader[];
  31479. /**
  31480. * Returns the current npm package of the sdk
  31481. */
  31482. static get NpmPackage(): string;
  31483. /**
  31484. * Returns the current version of the framework
  31485. */
  31486. static get Version(): string;
  31487. /**
  31488. * Returns a string describing the current engine
  31489. */
  31490. get description(): string;
  31491. /**
  31492. * Gets or sets the epsilon value used by collision engine
  31493. */
  31494. static CollisionsEpsilon: number;
  31495. /**
  31496. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31497. */
  31498. static get ShadersRepository(): string;
  31499. static set ShadersRepository(value: string);
  31500. /** @hidden */
  31501. _shaderProcessor: IShaderProcessor;
  31502. /**
  31503. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31504. */
  31505. forcePOTTextures: boolean;
  31506. /**
  31507. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31508. */
  31509. isFullscreen: boolean;
  31510. /**
  31511. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31512. */
  31513. cullBackFaces: boolean;
  31514. /**
  31515. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31516. */
  31517. renderEvenInBackground: boolean;
  31518. /**
  31519. * Gets or sets a boolean indicating that cache can be kept between frames
  31520. */
  31521. preventCacheWipeBetweenFrames: boolean;
  31522. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31523. validateShaderPrograms: boolean;
  31524. /**
  31525. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31526. * This can provide greater z depth for distant objects.
  31527. */
  31528. useReverseDepthBuffer: boolean;
  31529. /**
  31530. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31531. */
  31532. disableUniformBuffers: boolean;
  31533. /** @hidden */
  31534. _uniformBuffers: UniformBuffer[];
  31535. /**
  31536. * Gets a boolean indicating that the engine supports uniform buffers
  31537. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31538. */
  31539. get supportsUniformBuffers(): boolean;
  31540. /** @hidden */
  31541. _gl: WebGLRenderingContext;
  31542. /** @hidden */
  31543. _webGLVersion: number;
  31544. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31545. protected _windowIsBackground: boolean;
  31546. protected _creationOptions: EngineOptions;
  31547. protected _highPrecisionShadersAllowed: boolean;
  31548. /** @hidden */
  31549. get _shouldUseHighPrecisionShader(): boolean;
  31550. /**
  31551. * Gets a boolean indicating that only power of 2 textures are supported
  31552. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31553. */
  31554. get needPOTTextures(): boolean;
  31555. /** @hidden */
  31556. _badOS: boolean;
  31557. /** @hidden */
  31558. _badDesktopOS: boolean;
  31559. private _hardwareScalingLevel;
  31560. /** @hidden */
  31561. _caps: EngineCapabilities;
  31562. private _isStencilEnable;
  31563. private _glVersion;
  31564. private _glRenderer;
  31565. private _glVendor;
  31566. /** @hidden */
  31567. _videoTextureSupported: boolean;
  31568. protected _renderingQueueLaunched: boolean;
  31569. protected _activeRenderLoops: (() => void)[];
  31570. /**
  31571. * Observable signaled when a context lost event is raised
  31572. */
  31573. onContextLostObservable: Observable<ThinEngine>;
  31574. /**
  31575. * Observable signaled when a context restored event is raised
  31576. */
  31577. onContextRestoredObservable: Observable<ThinEngine>;
  31578. private _onContextLost;
  31579. private _onContextRestored;
  31580. protected _contextWasLost: boolean;
  31581. /** @hidden */
  31582. _doNotHandleContextLost: boolean;
  31583. /**
  31584. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31586. */
  31587. get doNotHandleContextLost(): boolean;
  31588. set doNotHandleContextLost(value: boolean);
  31589. /**
  31590. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31591. */
  31592. disableVertexArrayObjects: boolean;
  31593. /** @hidden */
  31594. protected _colorWrite: boolean;
  31595. /** @hidden */
  31596. protected _colorWriteChanged: boolean;
  31597. /** @hidden */
  31598. protected _depthCullingState: DepthCullingState;
  31599. /** @hidden */
  31600. protected _stencilState: StencilState;
  31601. /** @hidden */
  31602. _alphaState: AlphaState;
  31603. /** @hidden */
  31604. _alphaMode: number;
  31605. /** @hidden */
  31606. _alphaEquation: number;
  31607. /** @hidden */
  31608. _internalTexturesCache: InternalTexture[];
  31609. /** @hidden */
  31610. protected _activeChannel: number;
  31611. private _currentTextureChannel;
  31612. /** @hidden */
  31613. protected _boundTexturesCache: {
  31614. [key: string]: Nullable<InternalTexture>;
  31615. };
  31616. /** @hidden */
  31617. protected _currentEffect: Nullable<Effect>;
  31618. /** @hidden */
  31619. protected _currentProgram: Nullable<WebGLProgram>;
  31620. private _compiledEffects;
  31621. private _vertexAttribArraysEnabled;
  31622. /** @hidden */
  31623. protected _cachedViewport: Nullable<IViewportLike>;
  31624. private _cachedVertexArrayObject;
  31625. /** @hidden */
  31626. protected _cachedVertexBuffers: any;
  31627. /** @hidden */
  31628. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31629. /** @hidden */
  31630. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31631. /** @hidden */
  31632. _currentRenderTarget: Nullable<InternalTexture>;
  31633. private _uintIndicesCurrentlySet;
  31634. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31635. /** @hidden */
  31636. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31637. private _currentBufferPointers;
  31638. private _currentInstanceLocations;
  31639. private _currentInstanceBuffers;
  31640. private _textureUnits;
  31641. /** @hidden */
  31642. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31643. /** @hidden */
  31644. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31645. /** @hidden */
  31646. _boundRenderFunction: any;
  31647. private _vaoRecordInProgress;
  31648. private _mustWipeVertexAttributes;
  31649. private _emptyTexture;
  31650. private _emptyCubeTexture;
  31651. private _emptyTexture3D;
  31652. private _emptyTexture2DArray;
  31653. /** @hidden */
  31654. _frameHandler: number;
  31655. private _nextFreeTextureSlots;
  31656. private _maxSimultaneousTextures;
  31657. private _activeRequests;
  31658. /** @hidden */
  31659. _transformTextureUrl: Nullable<(url: string) => string>;
  31660. protected get _supportsHardwareTextureRescaling(): boolean;
  31661. private _framebufferDimensionsObject;
  31662. /**
  31663. * sets the object from which width and height will be taken from when getting render width and height
  31664. * Will fallback to the gl object
  31665. * @param dimensions the framebuffer width and height that will be used.
  31666. */
  31667. set framebufferDimensionsObject(dimensions: Nullable<{
  31668. framebufferWidth: number;
  31669. framebufferHeight: number;
  31670. }>);
  31671. /**
  31672. * Gets the current viewport
  31673. */
  31674. get currentViewport(): Nullable<IViewportLike>;
  31675. /**
  31676. * Gets the default empty texture
  31677. */
  31678. get emptyTexture(): InternalTexture;
  31679. /**
  31680. * Gets the default empty 3D texture
  31681. */
  31682. get emptyTexture3D(): InternalTexture;
  31683. /**
  31684. * Gets the default empty 2D array texture
  31685. */
  31686. get emptyTexture2DArray(): InternalTexture;
  31687. /**
  31688. * Gets the default empty cube texture
  31689. */
  31690. get emptyCubeTexture(): InternalTexture;
  31691. /**
  31692. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31693. */
  31694. readonly premultipliedAlpha: boolean;
  31695. /**
  31696. * Observable event triggered before each texture is initialized
  31697. */
  31698. onBeforeTextureInitObservable: Observable<Texture>;
  31699. /**
  31700. * Creates a new engine
  31701. * @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
  31702. * @param antialias defines enable antialiasing (default: false)
  31703. * @param options defines further options to be sent to the getContext() function
  31704. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31705. */
  31706. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31707. private _rebuildInternalTextures;
  31708. private _rebuildEffects;
  31709. /**
  31710. * Gets a boolean indicating if all created effects are ready
  31711. * @returns true if all effects are ready
  31712. */
  31713. areAllEffectsReady(): boolean;
  31714. protected _rebuildBuffers(): void;
  31715. protected _initGLContext(): void;
  31716. /**
  31717. * Gets version of the current webGL context
  31718. */
  31719. get webGLVersion(): number;
  31720. /**
  31721. * Gets a string idenfifying the name of the class
  31722. * @returns "Engine" string
  31723. */
  31724. getClassName(): string;
  31725. /**
  31726. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31727. */
  31728. get isStencilEnable(): boolean;
  31729. /** @hidden */
  31730. _prepareWorkingCanvas(): void;
  31731. /**
  31732. * Reset the texture cache to empty state
  31733. */
  31734. resetTextureCache(): void;
  31735. /**
  31736. * Gets an object containing information about the current webGL context
  31737. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31738. */
  31739. getGlInfo(): {
  31740. vendor: string;
  31741. renderer: string;
  31742. version: string;
  31743. };
  31744. /**
  31745. * Defines the hardware scaling level.
  31746. * By default the hardware scaling level is computed from the window device ratio.
  31747. * 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.
  31748. * @param level defines the level to use
  31749. */
  31750. setHardwareScalingLevel(level: number): void;
  31751. /**
  31752. * Gets the current hardware scaling level.
  31753. * By default the hardware scaling level is computed from the window device ratio.
  31754. * 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.
  31755. * @returns a number indicating the current hardware scaling level
  31756. */
  31757. getHardwareScalingLevel(): number;
  31758. /**
  31759. * Gets the list of loaded textures
  31760. * @returns an array containing all loaded textures
  31761. */
  31762. getLoadedTexturesCache(): InternalTexture[];
  31763. /**
  31764. * Gets the object containing all engine capabilities
  31765. * @returns the EngineCapabilities object
  31766. */
  31767. getCaps(): EngineCapabilities;
  31768. /**
  31769. * stop executing a render loop function and remove it from the execution array
  31770. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31771. */
  31772. stopRenderLoop(renderFunction?: () => void): void;
  31773. /** @hidden */
  31774. _renderLoop(): void;
  31775. /**
  31776. * Gets the HTML canvas attached with the current webGL context
  31777. * @returns a HTML canvas
  31778. */
  31779. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31780. /**
  31781. * Gets host window
  31782. * @returns the host window object
  31783. */
  31784. getHostWindow(): Nullable<Window>;
  31785. /**
  31786. * Gets the current render width
  31787. * @param useScreen defines if screen size must be used (or the current render target if any)
  31788. * @returns a number defining the current render width
  31789. */
  31790. getRenderWidth(useScreen?: boolean): number;
  31791. /**
  31792. * Gets the current render height
  31793. * @param useScreen defines if screen size must be used (or the current render target if any)
  31794. * @returns a number defining the current render height
  31795. */
  31796. getRenderHeight(useScreen?: boolean): number;
  31797. /**
  31798. * Can be used to override the current requestAnimationFrame requester.
  31799. * @hidden
  31800. */
  31801. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31802. /**
  31803. * Register and execute a render loop. The engine can have more than one render function
  31804. * @param renderFunction defines the function to continuously execute
  31805. */
  31806. runRenderLoop(renderFunction: () => void): void;
  31807. /**
  31808. * Clear the current render buffer or the current render target (if any is set up)
  31809. * @param color defines the color to use
  31810. * @param backBuffer defines if the back buffer must be cleared
  31811. * @param depth defines if the depth buffer must be cleared
  31812. * @param stencil defines if the stencil buffer must be cleared
  31813. */
  31814. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31815. private _viewportCached;
  31816. /** @hidden */
  31817. _viewport(x: number, y: number, width: number, height: number): void;
  31818. /**
  31819. * Set the WebGL's viewport
  31820. * @param viewport defines the viewport element to be used
  31821. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31822. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31823. */
  31824. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31825. /**
  31826. * Begin a new frame
  31827. */
  31828. beginFrame(): void;
  31829. /**
  31830. * Enf the current frame
  31831. */
  31832. endFrame(): void;
  31833. /**
  31834. * Resize the view according to the canvas' size
  31835. */
  31836. resize(): void;
  31837. /**
  31838. * Force a specific size of the canvas
  31839. * @param width defines the new canvas' width
  31840. * @param height defines the new canvas' height
  31841. */
  31842. setSize(width: number, height: number): void;
  31843. /**
  31844. * Binds the frame buffer to the specified texture.
  31845. * @param texture The texture to render to or null for the default canvas
  31846. * @param faceIndex The face of the texture to render to in case of cube texture
  31847. * @param requiredWidth The width of the target to render to
  31848. * @param requiredHeight The height of the target to render to
  31849. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31850. * @param lodLevel defines the lod level to bind to the frame buffer
  31851. * @param layer defines the 2d array index to bind to frame buffer to
  31852. */
  31853. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31854. /** @hidden */
  31855. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31856. /**
  31857. * Unbind the current render target texture from the webGL context
  31858. * @param texture defines the render target texture to unbind
  31859. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31860. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31861. */
  31862. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31863. /**
  31864. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31865. */
  31866. flushFramebuffer(): void;
  31867. /**
  31868. * Unbind the current render target and bind the default framebuffer
  31869. */
  31870. restoreDefaultFramebuffer(): void;
  31871. /** @hidden */
  31872. protected _resetVertexBufferBinding(): void;
  31873. /**
  31874. * Creates a vertex buffer
  31875. * @param data the data for the vertex buffer
  31876. * @returns the new WebGL static buffer
  31877. */
  31878. createVertexBuffer(data: DataArray): DataBuffer;
  31879. private _createVertexBuffer;
  31880. /**
  31881. * Creates a dynamic vertex buffer
  31882. * @param data the data for the dynamic vertex buffer
  31883. * @returns the new WebGL dynamic buffer
  31884. */
  31885. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31886. protected _resetIndexBufferBinding(): void;
  31887. /**
  31888. * Creates a new index buffer
  31889. * @param indices defines the content of the index buffer
  31890. * @param updatable defines if the index buffer must be updatable
  31891. * @returns a new webGL buffer
  31892. */
  31893. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31894. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31895. /**
  31896. * Bind a webGL buffer to the webGL context
  31897. * @param buffer defines the buffer to bind
  31898. */
  31899. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31900. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31901. private bindBuffer;
  31902. /**
  31903. * update the bound buffer with the given data
  31904. * @param data defines the data to update
  31905. */
  31906. updateArrayBuffer(data: Float32Array): void;
  31907. private _vertexAttribPointer;
  31908. /** @hidden */
  31909. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31910. private _bindVertexBuffersAttributes;
  31911. /**
  31912. * Records a vertex array object
  31913. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31914. * @param vertexBuffers defines the list of vertex buffers to store
  31915. * @param indexBuffer defines the index buffer to store
  31916. * @param effect defines the effect to store
  31917. * @returns the new vertex array object
  31918. */
  31919. recordVertexArrayObject(vertexBuffers: {
  31920. [key: string]: VertexBuffer;
  31921. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31922. /**
  31923. * Bind a specific vertex array object
  31924. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31925. * @param vertexArrayObject defines the vertex array object to bind
  31926. * @param indexBuffer defines the index buffer to bind
  31927. */
  31928. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31929. /**
  31930. * Bind webGl buffers directly to the webGL context
  31931. * @param vertexBuffer defines the vertex buffer to bind
  31932. * @param indexBuffer defines the index buffer to bind
  31933. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31934. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31935. * @param effect defines the effect associated with the vertex buffer
  31936. */
  31937. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31938. private _unbindVertexArrayObject;
  31939. /**
  31940. * Bind a list of vertex buffers to the webGL context
  31941. * @param vertexBuffers defines the list of vertex buffers to bind
  31942. * @param indexBuffer defines the index buffer to bind
  31943. * @param effect defines the effect associated with the vertex buffers
  31944. */
  31945. bindBuffers(vertexBuffers: {
  31946. [key: string]: Nullable<VertexBuffer>;
  31947. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31948. /**
  31949. * Unbind all instance attributes
  31950. */
  31951. unbindInstanceAttributes(): void;
  31952. /**
  31953. * Release and free the memory of a vertex array object
  31954. * @param vao defines the vertex array object to delete
  31955. */
  31956. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31957. /** @hidden */
  31958. _releaseBuffer(buffer: DataBuffer): boolean;
  31959. protected _deleteBuffer(buffer: DataBuffer): void;
  31960. /**
  31961. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31962. * @param instancesBuffer defines the webGL buffer to update and bind
  31963. * @param data defines the data to store in the buffer
  31964. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31965. */
  31966. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31967. /**
  31968. * Bind the content of a webGL buffer used with instantiation
  31969. * @param instancesBuffer defines the webGL buffer to bind
  31970. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31971. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31972. */
  31973. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31974. /**
  31975. * Disable the instance attribute corresponding to the name in parameter
  31976. * @param name defines the name of the attribute to disable
  31977. */
  31978. disableInstanceAttributeByName(name: string): void;
  31979. /**
  31980. * Disable the instance attribute corresponding to the location in parameter
  31981. * @param attributeLocation defines the attribute location of the attribute to disable
  31982. */
  31983. disableInstanceAttribute(attributeLocation: number): void;
  31984. /**
  31985. * Disable the attribute corresponding to the location in parameter
  31986. * @param attributeLocation defines the attribute location of the attribute to disable
  31987. */
  31988. disableAttributeByIndex(attributeLocation: number): void;
  31989. /**
  31990. * Send a draw order
  31991. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31992. * @param indexStart defines the starting index
  31993. * @param indexCount defines the number of index to draw
  31994. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31995. */
  31996. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31997. /**
  31998. * Draw a list of points
  31999. * @param verticesStart defines the index of first vertex to draw
  32000. * @param verticesCount defines the count of vertices to draw
  32001. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32002. */
  32003. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32004. /**
  32005. * Draw a list of unindexed primitives
  32006. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32007. * @param verticesStart defines the index of first vertex to draw
  32008. * @param verticesCount defines the count of vertices to draw
  32009. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32010. */
  32011. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32012. /**
  32013. * Draw a list of indexed primitives
  32014. * @param fillMode defines the primitive to use
  32015. * @param indexStart defines the starting index
  32016. * @param indexCount defines the number of index to draw
  32017. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32018. */
  32019. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32020. /**
  32021. * Draw a list of unindexed primitives
  32022. * @param fillMode defines the primitive to use
  32023. * @param verticesStart defines the index of first vertex to draw
  32024. * @param verticesCount defines the count of vertices to draw
  32025. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32026. */
  32027. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32028. private _drawMode;
  32029. /** @hidden */
  32030. protected _reportDrawCall(): void;
  32031. /** @hidden */
  32032. _releaseEffect(effect: Effect): void;
  32033. /** @hidden */
  32034. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32035. /**
  32036. * Create a new effect (used to store vertex/fragment shaders)
  32037. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32038. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32039. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32040. * @param samplers defines an array of string used to represent textures
  32041. * @param defines defines the string containing the defines to use to compile the shaders
  32042. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32043. * @param onCompiled defines a function to call when the effect creation is successful
  32044. * @param onError defines a function to call when the effect creation has failed
  32045. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32046. * @returns the new Effect
  32047. */
  32048. 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;
  32049. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32050. private _compileShader;
  32051. private _compileRawShader;
  32052. /** @hidden */
  32053. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32054. /**
  32055. * Directly creates a webGL program
  32056. * @param pipelineContext defines the pipeline context to attach to
  32057. * @param vertexCode defines the vertex shader code to use
  32058. * @param fragmentCode defines the fragment shader code to use
  32059. * @param context defines the webGL context to use (if not set, the current one will be used)
  32060. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32061. * @returns the new webGL program
  32062. */
  32063. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32064. /**
  32065. * Creates a webGL program
  32066. * @param pipelineContext defines the pipeline context to attach to
  32067. * @param vertexCode defines the vertex shader code to use
  32068. * @param fragmentCode defines the fragment shader code to use
  32069. * @param defines defines the string containing the defines to use to compile the shaders
  32070. * @param context defines the webGL context to use (if not set, the current one will be used)
  32071. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32072. * @returns the new webGL program
  32073. */
  32074. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32075. /**
  32076. * Creates a new pipeline context
  32077. * @returns the new pipeline
  32078. */
  32079. createPipelineContext(): IPipelineContext;
  32080. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32081. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32082. /** @hidden */
  32083. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32084. /** @hidden */
  32085. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32086. /** @hidden */
  32087. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32088. /**
  32089. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32090. * @param pipelineContext defines the pipeline context to use
  32091. * @param uniformsNames defines the list of uniform names
  32092. * @returns an array of webGL uniform locations
  32093. */
  32094. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32095. /**
  32096. * Gets the lsit of active attributes for a given webGL program
  32097. * @param pipelineContext defines the pipeline context to use
  32098. * @param attributesNames defines the list of attribute names to get
  32099. * @returns an array of indices indicating the offset of each attribute
  32100. */
  32101. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32102. /**
  32103. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32104. * @param effect defines the effect to activate
  32105. */
  32106. enableEffect(effect: Nullable<Effect>): void;
  32107. /**
  32108. * Set the value of an uniform to a number (int)
  32109. * @param uniform defines the webGL uniform location where to store the value
  32110. * @param value defines the int number to store
  32111. */
  32112. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32113. /**
  32114. * Set the value of an uniform to an array of int32
  32115. * @param uniform defines the webGL uniform location where to store the value
  32116. * @param array defines the array of int32 to store
  32117. */
  32118. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32119. /**
  32120. * Set the value of an uniform to an array of int32 (stored as vec2)
  32121. * @param uniform defines the webGL uniform location where to store the value
  32122. * @param array defines the array of int32 to store
  32123. */
  32124. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32125. /**
  32126. * Set the value of an uniform to an array of int32 (stored as vec3)
  32127. * @param uniform defines the webGL uniform location where to store the value
  32128. * @param array defines the array of int32 to store
  32129. */
  32130. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32131. /**
  32132. * Set the value of an uniform to an array of int32 (stored as vec4)
  32133. * @param uniform defines the webGL uniform location where to store the value
  32134. * @param array defines the array of int32 to store
  32135. */
  32136. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32137. /**
  32138. * Set the value of an uniform to an array of number
  32139. * @param uniform defines the webGL uniform location where to store the value
  32140. * @param array defines the array of number to store
  32141. */
  32142. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32143. /**
  32144. * Set the value of an uniform to an array of number (stored as vec2)
  32145. * @param uniform defines the webGL uniform location where to store the value
  32146. * @param array defines the array of number to store
  32147. */
  32148. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32149. /**
  32150. * Set the value of an uniform to an array of number (stored as vec3)
  32151. * @param uniform defines the webGL uniform location where to store the value
  32152. * @param array defines the array of number to store
  32153. */
  32154. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32155. /**
  32156. * Set the value of an uniform to an array of number (stored as vec4)
  32157. * @param uniform defines the webGL uniform location where to store the value
  32158. * @param array defines the array of number to store
  32159. */
  32160. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32161. /**
  32162. * Set the value of an uniform to an array of float32 (stored as matrices)
  32163. * @param uniform defines the webGL uniform location where to store the value
  32164. * @param matrices defines the array of float32 to store
  32165. */
  32166. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32167. /**
  32168. * Set the value of an uniform to a matrix (3x3)
  32169. * @param uniform defines the webGL uniform location where to store the value
  32170. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32171. */
  32172. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32173. /**
  32174. * Set the value of an uniform to a matrix (2x2)
  32175. * @param uniform defines the webGL uniform location where to store the value
  32176. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32177. */
  32178. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32179. /**
  32180. * Set the value of an uniform to a number (float)
  32181. * @param uniform defines the webGL uniform location where to store the value
  32182. * @param value defines the float number to store
  32183. */
  32184. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32185. /**
  32186. * Set the value of an uniform to a vec2
  32187. * @param uniform defines the webGL uniform location where to store the value
  32188. * @param x defines the 1st component of the value
  32189. * @param y defines the 2nd component of the value
  32190. */
  32191. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32192. /**
  32193. * Set the value of an uniform to a vec3
  32194. * @param uniform defines the webGL uniform location where to store the value
  32195. * @param x defines the 1st component of the value
  32196. * @param y defines the 2nd component of the value
  32197. * @param z defines the 3rd component of the value
  32198. */
  32199. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32200. /**
  32201. * Set the value of an uniform to a vec4
  32202. * @param uniform defines the webGL uniform location where to store the value
  32203. * @param x defines the 1st component of the value
  32204. * @param y defines the 2nd component of the value
  32205. * @param z defines the 3rd component of the value
  32206. * @param w defines the 4th component of the value
  32207. */
  32208. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32209. /**
  32210. * Apply all cached states (depth, culling, stencil and alpha)
  32211. */
  32212. applyStates(): void;
  32213. /**
  32214. * Enable or disable color writing
  32215. * @param enable defines the state to set
  32216. */
  32217. setColorWrite(enable: boolean): void;
  32218. /**
  32219. * Gets a boolean indicating if color writing is enabled
  32220. * @returns the current color writing state
  32221. */
  32222. getColorWrite(): boolean;
  32223. /**
  32224. * Gets the depth culling state manager
  32225. */
  32226. get depthCullingState(): DepthCullingState;
  32227. /**
  32228. * Gets the alpha state manager
  32229. */
  32230. get alphaState(): AlphaState;
  32231. /**
  32232. * Gets the stencil state manager
  32233. */
  32234. get stencilState(): StencilState;
  32235. /**
  32236. * Clears the list of texture accessible through engine.
  32237. * This can help preventing texture load conflict due to name collision.
  32238. */
  32239. clearInternalTexturesCache(): void;
  32240. /**
  32241. * Force the entire cache to be cleared
  32242. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32243. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32244. */
  32245. wipeCaches(bruteForce?: boolean): void;
  32246. /** @hidden */
  32247. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32248. min: number;
  32249. mag: number;
  32250. };
  32251. /** @hidden */
  32252. _createTexture(): WebGLTexture;
  32253. /**
  32254. * Usually called from Texture.ts.
  32255. * Passed information to create a WebGLTexture
  32256. * @param url defines a value which contains one of the following:
  32257. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32258. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32259. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32260. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32261. * @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)
  32262. * @param scene needed for loading to the correct scene
  32263. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32264. * @param onLoad optional callback to be called upon successful completion
  32265. * @param onError optional callback to be called upon failure
  32266. * @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
  32267. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32268. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32269. * @param forcedExtension defines the extension to use to pick the right loader
  32270. * @param mimeType defines an optional mime type
  32271. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32272. */
  32273. 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;
  32274. /**
  32275. * Loads an image as an HTMLImageElement.
  32276. * @param input url string, ArrayBuffer, or Blob to load
  32277. * @param onLoad callback called when the image successfully loads
  32278. * @param onError callback called when the image fails to load
  32279. * @param offlineProvider offline provider for caching
  32280. * @param mimeType optional mime type
  32281. * @returns the HTMLImageElement of the loaded image
  32282. * @hidden
  32283. */
  32284. 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>;
  32285. /**
  32286. * @hidden
  32287. */
  32288. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32289. private _unpackFlipYCached;
  32290. /**
  32291. * In case you are sharing the context with other applications, it might
  32292. * be interested to not cache the unpack flip y state to ensure a consistent
  32293. * value would be set.
  32294. */
  32295. enableUnpackFlipYCached: boolean;
  32296. /** @hidden */
  32297. _unpackFlipY(value: boolean): void;
  32298. /** @hidden */
  32299. _getUnpackAlignement(): number;
  32300. private _getTextureTarget;
  32301. /**
  32302. * Update the sampling mode of a given texture
  32303. * @param samplingMode defines the required sampling mode
  32304. * @param texture defines the texture to update
  32305. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32306. */
  32307. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32308. /**
  32309. * Update the sampling mode of a given texture
  32310. * @param texture defines the texture to update
  32311. * @param wrapU defines the texture wrap mode of the u coordinates
  32312. * @param wrapV defines the texture wrap mode of the v coordinates
  32313. * @param wrapR defines the texture wrap mode of the r coordinates
  32314. */
  32315. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32316. /** @hidden */
  32317. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32318. width: number;
  32319. height: number;
  32320. layers?: number;
  32321. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32322. /** @hidden */
  32323. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32324. /** @hidden */
  32325. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32326. /**
  32327. * Update a portion of an internal texture
  32328. * @param texture defines the texture to update
  32329. * @param imageData defines the data to store into the texture
  32330. * @param xOffset defines the x coordinates of the update rectangle
  32331. * @param yOffset defines the y coordinates of the update rectangle
  32332. * @param width defines the width of the update rectangle
  32333. * @param height defines the height of the update rectangle
  32334. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32335. * @param lod defines the lod level to update (0 by default)
  32336. */
  32337. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32338. /** @hidden */
  32339. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32340. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32341. private _prepareWebGLTexture;
  32342. /** @hidden */
  32343. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32344. private _getDepthStencilBuffer;
  32345. /** @hidden */
  32346. _releaseFramebufferObjects(texture: InternalTexture): void;
  32347. /** @hidden */
  32348. _releaseTexture(texture: InternalTexture): void;
  32349. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32350. protected _setProgram(program: WebGLProgram): void;
  32351. protected _boundUniforms: {
  32352. [key: number]: WebGLUniformLocation;
  32353. };
  32354. /**
  32355. * Binds an effect to the webGL context
  32356. * @param effect defines the effect to bind
  32357. */
  32358. bindSamplers(effect: Effect): void;
  32359. private _activateCurrentTexture;
  32360. /** @hidden */
  32361. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32362. /** @hidden */
  32363. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32364. /**
  32365. * Unbind all textures from the webGL context
  32366. */
  32367. unbindAllTextures(): void;
  32368. /**
  32369. * Sets a texture to the according uniform.
  32370. * @param channel The texture channel
  32371. * @param uniform The uniform to set
  32372. * @param texture The texture to apply
  32373. */
  32374. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32375. private _bindSamplerUniformToChannel;
  32376. private _getTextureWrapMode;
  32377. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32378. /**
  32379. * Sets an array of texture to the webGL context
  32380. * @param channel defines the channel where the texture array must be set
  32381. * @param uniform defines the associated uniform location
  32382. * @param textures defines the array of textures to bind
  32383. */
  32384. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32385. /** @hidden */
  32386. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32387. private _setTextureParameterFloat;
  32388. private _setTextureParameterInteger;
  32389. /**
  32390. * Unbind all vertex attributes from the webGL context
  32391. */
  32392. unbindAllAttributes(): void;
  32393. /**
  32394. * 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
  32395. */
  32396. releaseEffects(): void;
  32397. /**
  32398. * Dispose and release all associated resources
  32399. */
  32400. dispose(): void;
  32401. /**
  32402. * Attach a new callback raised when context lost event is fired
  32403. * @param callback defines the callback to call
  32404. */
  32405. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32406. /**
  32407. * Attach a new callback raised when context restored event is fired
  32408. * @param callback defines the callback to call
  32409. */
  32410. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32411. /**
  32412. * Get the current error code of the webGL context
  32413. * @returns the error code
  32414. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32415. */
  32416. getError(): number;
  32417. private _canRenderToFloatFramebuffer;
  32418. private _canRenderToHalfFloatFramebuffer;
  32419. private _canRenderToFramebuffer;
  32420. /** @hidden */
  32421. _getWebGLTextureType(type: number): number;
  32422. /** @hidden */
  32423. _getInternalFormat(format: number): number;
  32424. /** @hidden */
  32425. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32426. /** @hidden */
  32427. _getRGBAMultiSampleBufferFormat(type: number): number;
  32428. /** @hidden */
  32429. _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;
  32430. /**
  32431. * Loads a file from a url
  32432. * @param url url to load
  32433. * @param onSuccess callback called when the file successfully loads
  32434. * @param onProgress callback called while file is loading (if the server supports this mode)
  32435. * @param offlineProvider defines the offline provider for caching
  32436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32437. * @param onError callback called when the file fails to load
  32438. * @returns a file request object
  32439. * @hidden
  32440. */
  32441. 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;
  32442. /**
  32443. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32444. * @param x defines the x coordinate of the rectangle where pixels must be read
  32445. * @param y defines the y coordinate of the rectangle where pixels must be read
  32446. * @param width defines the width of the rectangle where pixels must be read
  32447. * @param height defines the height of the rectangle where pixels must be read
  32448. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32449. * @returns a Uint8Array containing RGBA colors
  32450. */
  32451. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32452. private static _isSupported;
  32453. /**
  32454. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32455. * @returns true if the engine can be created
  32456. * @ignorenaming
  32457. */
  32458. static isSupported(): boolean;
  32459. /**
  32460. * Find the next highest power of two.
  32461. * @param x Number to start search from.
  32462. * @return Next highest power of two.
  32463. */
  32464. static CeilingPOT(x: number): number;
  32465. /**
  32466. * Find the next lowest power of two.
  32467. * @param x Number to start search from.
  32468. * @return Next lowest power of two.
  32469. */
  32470. static FloorPOT(x: number): number;
  32471. /**
  32472. * Find the nearest power of two.
  32473. * @param x Number to start search from.
  32474. * @return Next nearest power of two.
  32475. */
  32476. static NearestPOT(x: number): number;
  32477. /**
  32478. * Get the closest exponent of two
  32479. * @param value defines the value to approximate
  32480. * @param max defines the maximum value to return
  32481. * @param mode defines how to define the closest value
  32482. * @returns closest exponent of two of the given value
  32483. */
  32484. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32485. /**
  32486. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32487. * @param func - the function to be called
  32488. * @param requester - the object that will request the next frame. Falls back to window.
  32489. * @returns frame number
  32490. */
  32491. static QueueNewFrame(func: () => void, requester?: any): number;
  32492. /**
  32493. * Gets host document
  32494. * @returns the host document object
  32495. */
  32496. getHostDocument(): Nullable<Document>;
  32497. }
  32498. }
  32499. declare module BABYLON {
  32500. /**
  32501. * Class representing spherical harmonics coefficients to the 3rd degree
  32502. */
  32503. export class SphericalHarmonics {
  32504. /**
  32505. * Defines whether or not the harmonics have been prescaled for rendering.
  32506. */
  32507. preScaled: boolean;
  32508. /**
  32509. * The l0,0 coefficients of the spherical harmonics
  32510. */
  32511. l00: Vector3;
  32512. /**
  32513. * The l1,-1 coefficients of the spherical harmonics
  32514. */
  32515. l1_1: Vector3;
  32516. /**
  32517. * The l1,0 coefficients of the spherical harmonics
  32518. */
  32519. l10: Vector3;
  32520. /**
  32521. * The l1,1 coefficients of the spherical harmonics
  32522. */
  32523. l11: Vector3;
  32524. /**
  32525. * The l2,-2 coefficients of the spherical harmonics
  32526. */
  32527. l2_2: Vector3;
  32528. /**
  32529. * The l2,-1 coefficients of the spherical harmonics
  32530. */
  32531. l2_1: Vector3;
  32532. /**
  32533. * The l2,0 coefficients of the spherical harmonics
  32534. */
  32535. l20: Vector3;
  32536. /**
  32537. * The l2,1 coefficients of the spherical harmonics
  32538. */
  32539. l21: Vector3;
  32540. /**
  32541. * The l2,2 coefficients of the spherical harmonics
  32542. */
  32543. l22: Vector3;
  32544. /**
  32545. * Adds a light to the spherical harmonics
  32546. * @param direction the direction of the light
  32547. * @param color the color of the light
  32548. * @param deltaSolidAngle the delta solid angle of the light
  32549. */
  32550. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32551. /**
  32552. * Scales the spherical harmonics by the given amount
  32553. * @param scale the amount to scale
  32554. */
  32555. scaleInPlace(scale: number): void;
  32556. /**
  32557. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32558. *
  32559. * ```
  32560. * E_lm = A_l * L_lm
  32561. * ```
  32562. *
  32563. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32564. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32565. * the scaling factors are given in equation 9.
  32566. */
  32567. convertIncidentRadianceToIrradiance(): void;
  32568. /**
  32569. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32570. *
  32571. * ```
  32572. * L = (1/pi) * E * rho
  32573. * ```
  32574. *
  32575. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32576. */
  32577. convertIrradianceToLambertianRadiance(): void;
  32578. /**
  32579. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32580. * required operations at run time.
  32581. *
  32582. * This is simply done by scaling back the SH with Ylm constants parameter.
  32583. * The trigonometric part being applied by the shader at run time.
  32584. */
  32585. preScaleForRendering(): void;
  32586. /**
  32587. * Constructs a spherical harmonics from an array.
  32588. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32589. * @returns the spherical harmonics
  32590. */
  32591. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32592. /**
  32593. * Gets the spherical harmonics from polynomial
  32594. * @param polynomial the spherical polynomial
  32595. * @returns the spherical harmonics
  32596. */
  32597. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32598. }
  32599. /**
  32600. * Class representing spherical polynomial coefficients to the 3rd degree
  32601. */
  32602. export class SphericalPolynomial {
  32603. private _harmonics;
  32604. /**
  32605. * The spherical harmonics used to create the polynomials.
  32606. */
  32607. get preScaledHarmonics(): SphericalHarmonics;
  32608. /**
  32609. * The x coefficients of the spherical polynomial
  32610. */
  32611. x: Vector3;
  32612. /**
  32613. * The y coefficients of the spherical polynomial
  32614. */
  32615. y: Vector3;
  32616. /**
  32617. * The z coefficients of the spherical polynomial
  32618. */
  32619. z: Vector3;
  32620. /**
  32621. * The xx coefficients of the spherical polynomial
  32622. */
  32623. xx: Vector3;
  32624. /**
  32625. * The yy coefficients of the spherical polynomial
  32626. */
  32627. yy: Vector3;
  32628. /**
  32629. * The zz coefficients of the spherical polynomial
  32630. */
  32631. zz: Vector3;
  32632. /**
  32633. * The xy coefficients of the spherical polynomial
  32634. */
  32635. xy: Vector3;
  32636. /**
  32637. * The yz coefficients of the spherical polynomial
  32638. */
  32639. yz: Vector3;
  32640. /**
  32641. * The zx coefficients of the spherical polynomial
  32642. */
  32643. zx: Vector3;
  32644. /**
  32645. * Adds an ambient color to the spherical polynomial
  32646. * @param color the color to add
  32647. */
  32648. addAmbient(color: Color3): void;
  32649. /**
  32650. * Scales the spherical polynomial by the given amount
  32651. * @param scale the amount to scale
  32652. */
  32653. scaleInPlace(scale: number): void;
  32654. /**
  32655. * Gets the spherical polynomial from harmonics
  32656. * @param harmonics the spherical harmonics
  32657. * @returns the spherical polynomial
  32658. */
  32659. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32660. /**
  32661. * Constructs a spherical polynomial from an array.
  32662. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32663. * @returns the spherical polynomial
  32664. */
  32665. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32666. }
  32667. }
  32668. declare module BABYLON {
  32669. /**
  32670. * Defines the source of the internal texture
  32671. */
  32672. export enum InternalTextureSource {
  32673. /**
  32674. * The source of the texture data is unknown
  32675. */
  32676. Unknown = 0,
  32677. /**
  32678. * Texture data comes from an URL
  32679. */
  32680. Url = 1,
  32681. /**
  32682. * Texture data is only used for temporary storage
  32683. */
  32684. Temp = 2,
  32685. /**
  32686. * Texture data comes from raw data (ArrayBuffer)
  32687. */
  32688. Raw = 3,
  32689. /**
  32690. * Texture content is dynamic (video or dynamic texture)
  32691. */
  32692. Dynamic = 4,
  32693. /**
  32694. * Texture content is generated by rendering to it
  32695. */
  32696. RenderTarget = 5,
  32697. /**
  32698. * Texture content is part of a multi render target process
  32699. */
  32700. MultiRenderTarget = 6,
  32701. /**
  32702. * Texture data comes from a cube data file
  32703. */
  32704. Cube = 7,
  32705. /**
  32706. * Texture data comes from a raw cube data
  32707. */
  32708. CubeRaw = 8,
  32709. /**
  32710. * Texture data come from a prefiltered cube data file
  32711. */
  32712. CubePrefiltered = 9,
  32713. /**
  32714. * Texture content is raw 3D data
  32715. */
  32716. Raw3D = 10,
  32717. /**
  32718. * Texture content is raw 2D array data
  32719. */
  32720. Raw2DArray = 11,
  32721. /**
  32722. * Texture content is a depth texture
  32723. */
  32724. Depth = 12,
  32725. /**
  32726. * Texture data comes from a raw cube data encoded with RGBD
  32727. */
  32728. CubeRawRGBD = 13
  32729. }
  32730. /**
  32731. * Class used to store data associated with WebGL texture data for the engine
  32732. * This class should not be used directly
  32733. */
  32734. export class InternalTexture {
  32735. /** @hidden */
  32736. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32737. /**
  32738. * Defines if the texture is ready
  32739. */
  32740. isReady: boolean;
  32741. /**
  32742. * Defines if the texture is a cube texture
  32743. */
  32744. isCube: boolean;
  32745. /**
  32746. * Defines if the texture contains 3D data
  32747. */
  32748. is3D: boolean;
  32749. /**
  32750. * Defines if the texture contains 2D array data
  32751. */
  32752. is2DArray: boolean;
  32753. /**
  32754. * Defines if the texture contains multiview data
  32755. */
  32756. isMultiview: boolean;
  32757. /**
  32758. * Gets the URL used to load this texture
  32759. */
  32760. url: string;
  32761. /**
  32762. * Gets the sampling mode of the texture
  32763. */
  32764. samplingMode: number;
  32765. /**
  32766. * Gets a boolean indicating if the texture needs mipmaps generation
  32767. */
  32768. generateMipMaps: boolean;
  32769. /**
  32770. * Gets the number of samples used by the texture (WebGL2+ only)
  32771. */
  32772. samples: number;
  32773. /**
  32774. * Gets the type of the texture (int, float...)
  32775. */
  32776. type: number;
  32777. /**
  32778. * Gets the format of the texture (RGB, RGBA...)
  32779. */
  32780. format: number;
  32781. /**
  32782. * Observable called when the texture is loaded
  32783. */
  32784. onLoadedObservable: Observable<InternalTexture>;
  32785. /**
  32786. * Gets the width of the texture
  32787. */
  32788. width: number;
  32789. /**
  32790. * Gets the height of the texture
  32791. */
  32792. height: number;
  32793. /**
  32794. * Gets the depth of the texture
  32795. */
  32796. depth: number;
  32797. /**
  32798. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32799. */
  32800. baseWidth: number;
  32801. /**
  32802. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32803. */
  32804. baseHeight: number;
  32805. /**
  32806. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32807. */
  32808. baseDepth: number;
  32809. /**
  32810. * Gets a boolean indicating if the texture is inverted on Y axis
  32811. */
  32812. invertY: boolean;
  32813. /** @hidden */
  32814. _invertVScale: boolean;
  32815. /** @hidden */
  32816. _associatedChannel: number;
  32817. /** @hidden */
  32818. _source: InternalTextureSource;
  32819. /** @hidden */
  32820. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32821. /** @hidden */
  32822. _bufferView: Nullable<ArrayBufferView>;
  32823. /** @hidden */
  32824. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32825. /** @hidden */
  32826. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32827. /** @hidden */
  32828. _size: number;
  32829. /** @hidden */
  32830. _extension: string;
  32831. /** @hidden */
  32832. _files: Nullable<string[]>;
  32833. /** @hidden */
  32834. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32835. /** @hidden */
  32836. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32837. /** @hidden */
  32838. _framebuffer: Nullable<WebGLFramebuffer>;
  32839. /** @hidden */
  32840. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32841. /** @hidden */
  32842. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32843. /** @hidden */
  32844. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32845. /** @hidden */
  32846. _attachments: Nullable<number[]>;
  32847. /** @hidden */
  32848. _cachedCoordinatesMode: Nullable<number>;
  32849. /** @hidden */
  32850. _cachedWrapU: Nullable<number>;
  32851. /** @hidden */
  32852. _cachedWrapV: Nullable<number>;
  32853. /** @hidden */
  32854. _cachedWrapR: Nullable<number>;
  32855. /** @hidden */
  32856. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32857. /** @hidden */
  32858. _isDisabled: boolean;
  32859. /** @hidden */
  32860. _compression: Nullable<string>;
  32861. /** @hidden */
  32862. _generateStencilBuffer: boolean;
  32863. /** @hidden */
  32864. _generateDepthBuffer: boolean;
  32865. /** @hidden */
  32866. _comparisonFunction: number;
  32867. /** @hidden */
  32868. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32869. /** @hidden */
  32870. _lodGenerationScale: number;
  32871. /** @hidden */
  32872. _lodGenerationOffset: number;
  32873. /** @hidden */
  32874. _depthStencilTexture: Nullable<InternalTexture>;
  32875. /** @hidden */
  32876. _colorTextureArray: Nullable<WebGLTexture>;
  32877. /** @hidden */
  32878. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32879. /** @hidden */
  32880. _lodTextureHigh: Nullable<BaseTexture>;
  32881. /** @hidden */
  32882. _lodTextureMid: Nullable<BaseTexture>;
  32883. /** @hidden */
  32884. _lodTextureLow: Nullable<BaseTexture>;
  32885. /** @hidden */
  32886. _isRGBD: boolean;
  32887. /** @hidden */
  32888. _linearSpecularLOD: boolean;
  32889. /** @hidden */
  32890. _irradianceTexture: Nullable<BaseTexture>;
  32891. /** @hidden */
  32892. _webGLTexture: Nullable<WebGLTexture>;
  32893. /** @hidden */
  32894. _references: number;
  32895. private _engine;
  32896. /**
  32897. * Gets the Engine the texture belongs to.
  32898. * @returns The babylon engine
  32899. */
  32900. getEngine(): ThinEngine;
  32901. /**
  32902. * Gets the data source type of the texture
  32903. */
  32904. get source(): InternalTextureSource;
  32905. /**
  32906. * Creates a new InternalTexture
  32907. * @param engine defines the engine to use
  32908. * @param source defines the type of data that will be used
  32909. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32910. */
  32911. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32912. /**
  32913. * Increments the number of references (ie. the number of Texture that point to it)
  32914. */
  32915. incrementReferences(): void;
  32916. /**
  32917. * Change the size of the texture (not the size of the content)
  32918. * @param width defines the new width
  32919. * @param height defines the new height
  32920. * @param depth defines the new depth (1 by default)
  32921. */
  32922. updateSize(width: int, height: int, depth?: int): void;
  32923. /** @hidden */
  32924. _rebuild(): void;
  32925. /** @hidden */
  32926. _swapAndDie(target: InternalTexture): void;
  32927. /**
  32928. * Dispose the current allocated resources
  32929. */
  32930. dispose(): void;
  32931. }
  32932. }
  32933. declare module BABYLON {
  32934. /**
  32935. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32937. */
  32938. export class Analyser {
  32939. /**
  32940. * Gets or sets the smoothing
  32941. * @ignorenaming
  32942. */
  32943. SMOOTHING: number;
  32944. /**
  32945. * Gets or sets the FFT table size
  32946. * @ignorenaming
  32947. */
  32948. FFT_SIZE: number;
  32949. /**
  32950. * Gets or sets the bar graph amplitude
  32951. * @ignorenaming
  32952. */
  32953. BARGRAPHAMPLITUDE: number;
  32954. /**
  32955. * Gets or sets the position of the debug canvas
  32956. * @ignorenaming
  32957. */
  32958. DEBUGCANVASPOS: {
  32959. x: number;
  32960. y: number;
  32961. };
  32962. /**
  32963. * Gets or sets the debug canvas size
  32964. * @ignorenaming
  32965. */
  32966. DEBUGCANVASSIZE: {
  32967. width: number;
  32968. height: number;
  32969. };
  32970. private _byteFreqs;
  32971. private _byteTime;
  32972. private _floatFreqs;
  32973. private _webAudioAnalyser;
  32974. private _debugCanvas;
  32975. private _debugCanvasContext;
  32976. private _scene;
  32977. private _registerFunc;
  32978. private _audioEngine;
  32979. /**
  32980. * Creates a new analyser
  32981. * @param scene defines hosting scene
  32982. */
  32983. constructor(scene: Scene);
  32984. /**
  32985. * Get the number of data values you will have to play with for the visualization
  32986. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32987. * @returns a number
  32988. */
  32989. getFrequencyBinCount(): number;
  32990. /**
  32991. * Gets the current frequency data as a byte array
  32992. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32993. * @returns a Uint8Array
  32994. */
  32995. getByteFrequencyData(): Uint8Array;
  32996. /**
  32997. * Gets the current waveform as a byte array
  32998. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32999. * @returns a Uint8Array
  33000. */
  33001. getByteTimeDomainData(): Uint8Array;
  33002. /**
  33003. * Gets the current frequency data as a float array
  33004. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33005. * @returns a Float32Array
  33006. */
  33007. getFloatFrequencyData(): Float32Array;
  33008. /**
  33009. * Renders the debug canvas
  33010. */
  33011. drawDebugCanvas(): void;
  33012. /**
  33013. * Stops rendering the debug canvas and removes it
  33014. */
  33015. stopDebugCanvas(): void;
  33016. /**
  33017. * Connects two audio nodes
  33018. * @param inputAudioNode defines first node to connect
  33019. * @param outputAudioNode defines second node to connect
  33020. */
  33021. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33022. /**
  33023. * Releases all associated resources
  33024. */
  33025. dispose(): void;
  33026. }
  33027. }
  33028. declare module BABYLON {
  33029. /**
  33030. * This represents an audio engine and it is responsible
  33031. * to play, synchronize and analyse sounds throughout the application.
  33032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33033. */
  33034. export interface IAudioEngine extends IDisposable {
  33035. /**
  33036. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33037. */
  33038. readonly canUseWebAudio: boolean;
  33039. /**
  33040. * Gets the current AudioContext if available.
  33041. */
  33042. readonly audioContext: Nullable<AudioContext>;
  33043. /**
  33044. * The master gain node defines the global audio volume of your audio engine.
  33045. */
  33046. readonly masterGain: GainNode;
  33047. /**
  33048. * Gets whether or not mp3 are supported by your browser.
  33049. */
  33050. readonly isMP3supported: boolean;
  33051. /**
  33052. * Gets whether or not ogg are supported by your browser.
  33053. */
  33054. readonly isOGGsupported: boolean;
  33055. /**
  33056. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33057. * @ignoreNaming
  33058. */
  33059. WarnedWebAudioUnsupported: boolean;
  33060. /**
  33061. * Defines if the audio engine relies on a custom unlocked button.
  33062. * In this case, the embedded button will not be displayed.
  33063. */
  33064. useCustomUnlockedButton: boolean;
  33065. /**
  33066. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33067. */
  33068. readonly unlocked: boolean;
  33069. /**
  33070. * Event raised when audio has been unlocked on the browser.
  33071. */
  33072. onAudioUnlockedObservable: Observable<AudioEngine>;
  33073. /**
  33074. * Event raised when audio has been locked on the browser.
  33075. */
  33076. onAudioLockedObservable: Observable<AudioEngine>;
  33077. /**
  33078. * Flags the audio engine in Locked state.
  33079. * This happens due to new browser policies preventing audio to autoplay.
  33080. */
  33081. lock(): void;
  33082. /**
  33083. * Unlocks the audio engine once a user action has been done on the dom.
  33084. * This is helpful to resume play once browser policies have been satisfied.
  33085. */
  33086. unlock(): void;
  33087. /**
  33088. * Gets the global volume sets on the master gain.
  33089. * @returns the global volume if set or -1 otherwise
  33090. */
  33091. getGlobalVolume(): number;
  33092. /**
  33093. * Sets the global volume of your experience (sets on the master gain).
  33094. * @param newVolume Defines the new global volume of the application
  33095. */
  33096. setGlobalVolume(newVolume: number): void;
  33097. /**
  33098. * Connect the audio engine to an audio analyser allowing some amazing
  33099. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33101. * @param analyser The analyser to connect to the engine
  33102. */
  33103. connectToAnalyser(analyser: Analyser): void;
  33104. }
  33105. /**
  33106. * This represents the default audio engine used in babylon.
  33107. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33109. */
  33110. export class AudioEngine implements IAudioEngine {
  33111. private _audioContext;
  33112. private _audioContextInitialized;
  33113. private _muteButton;
  33114. private _hostElement;
  33115. /**
  33116. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33117. */
  33118. canUseWebAudio: boolean;
  33119. /**
  33120. * The master gain node defines the global audio volume of your audio engine.
  33121. */
  33122. masterGain: GainNode;
  33123. /**
  33124. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33125. * @ignoreNaming
  33126. */
  33127. WarnedWebAudioUnsupported: boolean;
  33128. /**
  33129. * Gets whether or not mp3 are supported by your browser.
  33130. */
  33131. isMP3supported: boolean;
  33132. /**
  33133. * Gets whether or not ogg are supported by your browser.
  33134. */
  33135. isOGGsupported: boolean;
  33136. /**
  33137. * Gets whether audio has been unlocked on the device.
  33138. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33139. * a user interaction has happened.
  33140. */
  33141. unlocked: boolean;
  33142. /**
  33143. * Defines if the audio engine relies on a custom unlocked button.
  33144. * In this case, the embedded button will not be displayed.
  33145. */
  33146. useCustomUnlockedButton: boolean;
  33147. /**
  33148. * Event raised when audio has been unlocked on the browser.
  33149. */
  33150. onAudioUnlockedObservable: Observable<AudioEngine>;
  33151. /**
  33152. * Event raised when audio has been locked on the browser.
  33153. */
  33154. onAudioLockedObservable: Observable<AudioEngine>;
  33155. /**
  33156. * Gets the current AudioContext if available.
  33157. */
  33158. get audioContext(): Nullable<AudioContext>;
  33159. private _connectedAnalyser;
  33160. /**
  33161. * Instantiates a new audio engine.
  33162. *
  33163. * There should be only one per page as some browsers restrict the number
  33164. * of audio contexts you can create.
  33165. * @param hostElement defines the host element where to display the mute icon if necessary
  33166. */
  33167. constructor(hostElement?: Nullable<HTMLElement>);
  33168. /**
  33169. * Flags the audio engine in Locked state.
  33170. * This happens due to new browser policies preventing audio to autoplay.
  33171. */
  33172. lock(): void;
  33173. /**
  33174. * Unlocks the audio engine once a user action has been done on the dom.
  33175. * This is helpful to resume play once browser policies have been satisfied.
  33176. */
  33177. unlock(): void;
  33178. private _resumeAudioContext;
  33179. private _initializeAudioContext;
  33180. private _tryToRun;
  33181. private _triggerRunningState;
  33182. private _triggerSuspendedState;
  33183. private _displayMuteButton;
  33184. private _moveButtonToTopLeft;
  33185. private _onResize;
  33186. private _hideMuteButton;
  33187. /**
  33188. * Destroy and release the resources associated with the audio ccontext.
  33189. */
  33190. dispose(): void;
  33191. /**
  33192. * Gets the global volume sets on the master gain.
  33193. * @returns the global volume if set or -1 otherwise
  33194. */
  33195. getGlobalVolume(): number;
  33196. /**
  33197. * Sets the global volume of your experience (sets on the master gain).
  33198. * @param newVolume Defines the new global volume of the application
  33199. */
  33200. setGlobalVolume(newVolume: number): void;
  33201. /**
  33202. * Connect the audio engine to an audio analyser allowing some amazing
  33203. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33205. * @param analyser The analyser to connect to the engine
  33206. */
  33207. connectToAnalyser(analyser: Analyser): void;
  33208. }
  33209. }
  33210. declare module BABYLON {
  33211. /**
  33212. * Interface used to present a loading screen while loading a scene
  33213. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33214. */
  33215. export interface ILoadingScreen {
  33216. /**
  33217. * Function called to display the loading screen
  33218. */
  33219. displayLoadingUI: () => void;
  33220. /**
  33221. * Function called to hide the loading screen
  33222. */
  33223. hideLoadingUI: () => void;
  33224. /**
  33225. * Gets or sets the color to use for the background
  33226. */
  33227. loadingUIBackgroundColor: string;
  33228. /**
  33229. * Gets or sets the text to display while loading
  33230. */
  33231. loadingUIText: string;
  33232. }
  33233. /**
  33234. * Class used for the default loading screen
  33235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33236. */
  33237. export class DefaultLoadingScreen implements ILoadingScreen {
  33238. private _renderingCanvas;
  33239. private _loadingText;
  33240. private _loadingDivBackgroundColor;
  33241. private _loadingDiv;
  33242. private _loadingTextDiv;
  33243. /** Gets or sets the logo url to use for the default loading screen */
  33244. static DefaultLogoUrl: string;
  33245. /** Gets or sets the spinner url to use for the default loading screen */
  33246. static DefaultSpinnerUrl: string;
  33247. /**
  33248. * Creates a new default loading screen
  33249. * @param _renderingCanvas defines the canvas used to render the scene
  33250. * @param _loadingText defines the default text to display
  33251. * @param _loadingDivBackgroundColor defines the default background color
  33252. */
  33253. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33254. /**
  33255. * Function called to display the loading screen
  33256. */
  33257. displayLoadingUI(): void;
  33258. /**
  33259. * Function called to hide the loading screen
  33260. */
  33261. hideLoadingUI(): void;
  33262. /**
  33263. * Gets or sets the text to display while loading
  33264. */
  33265. set loadingUIText(text: string);
  33266. get loadingUIText(): string;
  33267. /**
  33268. * Gets or sets the color to use for the background
  33269. */
  33270. get loadingUIBackgroundColor(): string;
  33271. set loadingUIBackgroundColor(color: string);
  33272. private _resizeLoadingUI;
  33273. }
  33274. }
  33275. declare module BABYLON {
  33276. /**
  33277. * Interface for any object that can request an animation frame
  33278. */
  33279. export interface ICustomAnimationFrameRequester {
  33280. /**
  33281. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33282. */
  33283. renderFunction?: Function;
  33284. /**
  33285. * Called to request the next frame to render to
  33286. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33287. */
  33288. requestAnimationFrame: Function;
  33289. /**
  33290. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33291. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33292. */
  33293. requestID?: number;
  33294. }
  33295. }
  33296. declare module BABYLON {
  33297. /**
  33298. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33299. */
  33300. export class PerformanceMonitor {
  33301. private _enabled;
  33302. private _rollingFrameTime;
  33303. private _lastFrameTimeMs;
  33304. /**
  33305. * constructor
  33306. * @param frameSampleSize The number of samples required to saturate the sliding window
  33307. */
  33308. constructor(frameSampleSize?: number);
  33309. /**
  33310. * Samples current frame
  33311. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33312. */
  33313. sampleFrame(timeMs?: number): void;
  33314. /**
  33315. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33316. */
  33317. get averageFrameTime(): number;
  33318. /**
  33319. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33320. */
  33321. get averageFrameTimeVariance(): number;
  33322. /**
  33323. * Returns the frame time of the most recent frame
  33324. */
  33325. get instantaneousFrameTime(): number;
  33326. /**
  33327. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33328. */
  33329. get averageFPS(): number;
  33330. /**
  33331. * Returns the average framerate in frames per second using the most recent frame time
  33332. */
  33333. get instantaneousFPS(): number;
  33334. /**
  33335. * Returns true if enough samples have been taken to completely fill the sliding window
  33336. */
  33337. get isSaturated(): boolean;
  33338. /**
  33339. * Enables contributions to the sliding window sample set
  33340. */
  33341. enable(): void;
  33342. /**
  33343. * Disables contributions to the sliding window sample set
  33344. * Samples will not be interpolated over the disabled period
  33345. */
  33346. disable(): void;
  33347. /**
  33348. * Returns true if sampling is enabled
  33349. */
  33350. get isEnabled(): boolean;
  33351. /**
  33352. * Resets performance monitor
  33353. */
  33354. reset(): void;
  33355. }
  33356. /**
  33357. * RollingAverage
  33358. *
  33359. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33360. */
  33361. export class RollingAverage {
  33362. /**
  33363. * Current average
  33364. */
  33365. average: number;
  33366. /**
  33367. * Current variance
  33368. */
  33369. variance: number;
  33370. protected _samples: Array<number>;
  33371. protected _sampleCount: number;
  33372. protected _pos: number;
  33373. protected _m2: number;
  33374. /**
  33375. * constructor
  33376. * @param length The number of samples required to saturate the sliding window
  33377. */
  33378. constructor(length: number);
  33379. /**
  33380. * Adds a sample to the sample set
  33381. * @param v The sample value
  33382. */
  33383. add(v: number): void;
  33384. /**
  33385. * Returns previously added values or null if outside of history or outside the sliding window domain
  33386. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33387. * @return Value previously recorded with add() or null if outside of range
  33388. */
  33389. history(i: number): number;
  33390. /**
  33391. * Returns true if enough samples have been taken to completely fill the sliding window
  33392. * @return true if sample-set saturated
  33393. */
  33394. isSaturated(): boolean;
  33395. /**
  33396. * Resets the rolling average (equivalent to 0 samples taken so far)
  33397. */
  33398. reset(): void;
  33399. /**
  33400. * Wraps a value around the sample range boundaries
  33401. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33402. * @return Wrapped position in sample range
  33403. */
  33404. protected _wrapPosition(i: number): number;
  33405. }
  33406. }
  33407. declare module BABYLON {
  33408. /**
  33409. * This class is used to track a performance counter which is number based.
  33410. * The user has access to many properties which give statistics of different nature.
  33411. *
  33412. * The implementer can track two kinds of Performance Counter: time and count.
  33413. * 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.
  33414. * 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.
  33415. */
  33416. export class PerfCounter {
  33417. /**
  33418. * Gets or sets a global boolean to turn on and off all the counters
  33419. */
  33420. static Enabled: boolean;
  33421. /**
  33422. * Returns the smallest value ever
  33423. */
  33424. get min(): number;
  33425. /**
  33426. * Returns the biggest value ever
  33427. */
  33428. get max(): number;
  33429. /**
  33430. * Returns the average value since the performance counter is running
  33431. */
  33432. get average(): number;
  33433. /**
  33434. * Returns the average value of the last second the counter was monitored
  33435. */
  33436. get lastSecAverage(): number;
  33437. /**
  33438. * Returns the current value
  33439. */
  33440. get current(): number;
  33441. /**
  33442. * Gets the accumulated total
  33443. */
  33444. get total(): number;
  33445. /**
  33446. * Gets the total value count
  33447. */
  33448. get count(): number;
  33449. /**
  33450. * Creates a new counter
  33451. */
  33452. constructor();
  33453. /**
  33454. * Call this method to start monitoring a new frame.
  33455. * 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.
  33456. */
  33457. fetchNewFrame(): void;
  33458. /**
  33459. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33460. * @param newCount the count value to add to the monitored count
  33461. * @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.
  33462. */
  33463. addCount(newCount: number, fetchResult: boolean): void;
  33464. /**
  33465. * Start monitoring this performance counter
  33466. */
  33467. beginMonitoring(): void;
  33468. /**
  33469. * Compute the time lapsed since the previous beginMonitoring() call.
  33470. * @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
  33471. */
  33472. endMonitoring(newFrame?: boolean): void;
  33473. private _fetchResult;
  33474. private _startMonitoringTime;
  33475. private _min;
  33476. private _max;
  33477. private _average;
  33478. private _current;
  33479. private _totalValueCount;
  33480. private _totalAccumulated;
  33481. private _lastSecAverage;
  33482. private _lastSecAccumulated;
  33483. private _lastSecTime;
  33484. private _lastSecValueCount;
  33485. }
  33486. }
  33487. declare module BABYLON {
  33488. interface ThinEngine {
  33489. /**
  33490. * Sets alpha constants used by some alpha blending modes
  33491. * @param r defines the red component
  33492. * @param g defines the green component
  33493. * @param b defines the blue component
  33494. * @param a defines the alpha component
  33495. */
  33496. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33497. /**
  33498. * Sets the current alpha mode
  33499. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33500. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33501. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33502. */
  33503. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33504. /**
  33505. * Gets the current alpha mode
  33506. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33507. * @returns the current alpha mode
  33508. */
  33509. getAlphaMode(): number;
  33510. /**
  33511. * Sets the current alpha equation
  33512. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33513. */
  33514. setAlphaEquation(equation: number): void;
  33515. /**
  33516. * Gets the current alpha equation.
  33517. * @returns the current alpha equation
  33518. */
  33519. getAlphaEquation(): number;
  33520. }
  33521. }
  33522. declare module BABYLON {
  33523. /**
  33524. * Defines the interface used by display changed events
  33525. */
  33526. export interface IDisplayChangedEventArgs {
  33527. /** Gets the vrDisplay object (if any) */
  33528. vrDisplay: Nullable<any>;
  33529. /** Gets a boolean indicating if webVR is supported */
  33530. vrSupported: boolean;
  33531. }
  33532. /**
  33533. * Defines the interface used by objects containing a viewport (like a camera)
  33534. */
  33535. interface IViewportOwnerLike {
  33536. /**
  33537. * Gets or sets the viewport
  33538. */
  33539. viewport: IViewportLike;
  33540. }
  33541. /**
  33542. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33543. */
  33544. export class Engine extends ThinEngine {
  33545. /** Defines that alpha blending is disabled */
  33546. static readonly ALPHA_DISABLE: number;
  33547. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33548. static readonly ALPHA_ADD: number;
  33549. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33550. static readonly ALPHA_COMBINE: number;
  33551. /** Defines that alpha blending to DEST - SRC * DEST */
  33552. static readonly ALPHA_SUBTRACT: number;
  33553. /** Defines that alpha blending to SRC * DEST */
  33554. static readonly ALPHA_MULTIPLY: number;
  33555. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33556. static readonly ALPHA_MAXIMIZED: number;
  33557. /** Defines that alpha blending to SRC + DEST */
  33558. static readonly ALPHA_ONEONE: number;
  33559. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33560. static readonly ALPHA_PREMULTIPLIED: number;
  33561. /**
  33562. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33563. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33564. */
  33565. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33566. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33567. static readonly ALPHA_INTERPOLATE: number;
  33568. /**
  33569. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33570. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33571. */
  33572. static readonly ALPHA_SCREENMODE: number;
  33573. /** Defines that the ressource is not delayed*/
  33574. static readonly DELAYLOADSTATE_NONE: number;
  33575. /** Defines that the ressource was successfully delay loaded */
  33576. static readonly DELAYLOADSTATE_LOADED: number;
  33577. /** Defines that the ressource is currently delay loading */
  33578. static readonly DELAYLOADSTATE_LOADING: number;
  33579. /** Defines that the ressource is delayed and has not started loading */
  33580. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33581. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33582. static readonly NEVER: number;
  33583. /** 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 */
  33584. static readonly ALWAYS: number;
  33585. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33586. static readonly LESS: number;
  33587. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33588. static readonly EQUAL: number;
  33589. /** 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 */
  33590. static readonly LEQUAL: number;
  33591. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33592. static readonly GREATER: number;
  33593. /** 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 */
  33594. static readonly GEQUAL: number;
  33595. /** 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 */
  33596. static readonly NOTEQUAL: number;
  33597. /** Passed to stencilOperation to specify that stencil value must be kept */
  33598. static readonly KEEP: number;
  33599. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33600. static readonly REPLACE: number;
  33601. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33602. static readonly INCR: number;
  33603. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33604. static readonly DECR: number;
  33605. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33606. static readonly INVERT: number;
  33607. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33608. static readonly INCR_WRAP: number;
  33609. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33610. static readonly DECR_WRAP: number;
  33611. /** Texture is not repeating outside of 0..1 UVs */
  33612. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33613. /** Texture is repeating outside of 0..1 UVs */
  33614. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33615. /** Texture is repeating and mirrored */
  33616. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33617. /** ALPHA */
  33618. static readonly TEXTUREFORMAT_ALPHA: number;
  33619. /** LUMINANCE */
  33620. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33621. /** LUMINANCE_ALPHA */
  33622. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33623. /** RGB */
  33624. static readonly TEXTUREFORMAT_RGB: number;
  33625. /** RGBA */
  33626. static readonly TEXTUREFORMAT_RGBA: number;
  33627. /** RED */
  33628. static readonly TEXTUREFORMAT_RED: number;
  33629. /** RED (2nd reference) */
  33630. static readonly TEXTUREFORMAT_R: number;
  33631. /** RG */
  33632. static readonly TEXTUREFORMAT_RG: number;
  33633. /** RED_INTEGER */
  33634. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33635. /** RED_INTEGER (2nd reference) */
  33636. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33637. /** RG_INTEGER */
  33638. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33639. /** RGB_INTEGER */
  33640. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33641. /** RGBA_INTEGER */
  33642. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33643. /** UNSIGNED_BYTE */
  33644. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33645. /** UNSIGNED_BYTE (2nd reference) */
  33646. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33647. /** FLOAT */
  33648. static readonly TEXTURETYPE_FLOAT: number;
  33649. /** HALF_FLOAT */
  33650. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33651. /** BYTE */
  33652. static readonly TEXTURETYPE_BYTE: number;
  33653. /** SHORT */
  33654. static readonly TEXTURETYPE_SHORT: number;
  33655. /** UNSIGNED_SHORT */
  33656. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33657. /** INT */
  33658. static readonly TEXTURETYPE_INT: number;
  33659. /** UNSIGNED_INT */
  33660. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33661. /** UNSIGNED_SHORT_4_4_4_4 */
  33662. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33663. /** UNSIGNED_SHORT_5_5_5_1 */
  33664. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33665. /** UNSIGNED_SHORT_5_6_5 */
  33666. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33667. /** UNSIGNED_INT_2_10_10_10_REV */
  33668. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33669. /** UNSIGNED_INT_24_8 */
  33670. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33671. /** UNSIGNED_INT_10F_11F_11F_REV */
  33672. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33673. /** UNSIGNED_INT_5_9_9_9_REV */
  33674. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33675. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33676. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33677. /** nearest is mag = nearest and min = nearest and mip = linear */
  33678. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33679. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33680. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33681. /** Trilinear is mag = linear and min = linear and mip = linear */
  33682. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33683. /** nearest is mag = nearest and min = nearest and mip = linear */
  33684. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33685. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33686. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33687. /** Trilinear is mag = linear and min = linear and mip = linear */
  33688. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33689. /** mag = nearest and min = nearest and mip = nearest */
  33690. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33691. /** mag = nearest and min = linear and mip = nearest */
  33692. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33693. /** mag = nearest and min = linear and mip = linear */
  33694. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33695. /** mag = nearest and min = linear and mip = none */
  33696. static readonly TEXTURE_NEAREST_LINEAR: number;
  33697. /** mag = nearest and min = nearest and mip = none */
  33698. static readonly TEXTURE_NEAREST_NEAREST: number;
  33699. /** mag = linear and min = nearest and mip = nearest */
  33700. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33701. /** mag = linear and min = nearest and mip = linear */
  33702. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33703. /** mag = linear and min = linear and mip = none */
  33704. static readonly TEXTURE_LINEAR_LINEAR: number;
  33705. /** mag = linear and min = nearest and mip = none */
  33706. static readonly TEXTURE_LINEAR_NEAREST: number;
  33707. /** Explicit coordinates mode */
  33708. static readonly TEXTURE_EXPLICIT_MODE: number;
  33709. /** Spherical coordinates mode */
  33710. static readonly TEXTURE_SPHERICAL_MODE: number;
  33711. /** Planar coordinates mode */
  33712. static readonly TEXTURE_PLANAR_MODE: number;
  33713. /** Cubic coordinates mode */
  33714. static readonly TEXTURE_CUBIC_MODE: number;
  33715. /** Projection coordinates mode */
  33716. static readonly TEXTURE_PROJECTION_MODE: number;
  33717. /** Skybox coordinates mode */
  33718. static readonly TEXTURE_SKYBOX_MODE: number;
  33719. /** Inverse Cubic coordinates mode */
  33720. static readonly TEXTURE_INVCUBIC_MODE: number;
  33721. /** Equirectangular coordinates mode */
  33722. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33723. /** Equirectangular Fixed coordinates mode */
  33724. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33725. /** Equirectangular Fixed Mirrored coordinates mode */
  33726. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33727. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33728. static readonly SCALEMODE_FLOOR: number;
  33729. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33730. static readonly SCALEMODE_NEAREST: number;
  33731. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33732. static readonly SCALEMODE_CEILING: number;
  33733. /**
  33734. * Returns the current npm package of the sdk
  33735. */
  33736. static get NpmPackage(): string;
  33737. /**
  33738. * Returns the current version of the framework
  33739. */
  33740. static get Version(): string;
  33741. /** Gets the list of created engines */
  33742. static get Instances(): Engine[];
  33743. /**
  33744. * Gets the latest created engine
  33745. */
  33746. static get LastCreatedEngine(): Nullable<Engine>;
  33747. /**
  33748. * Gets the latest created scene
  33749. */
  33750. static get LastCreatedScene(): Nullable<Scene>;
  33751. /**
  33752. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33753. * @param flag defines which part of the materials must be marked as dirty
  33754. * @param predicate defines a predicate used to filter which materials should be affected
  33755. */
  33756. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33757. /**
  33758. * Method called to create the default loading screen.
  33759. * This can be overriden in your own app.
  33760. * @param canvas The rendering canvas element
  33761. * @returns The loading screen
  33762. */
  33763. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33764. /**
  33765. * Method called to create the default rescale post process on each engine.
  33766. */
  33767. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33768. /**
  33769. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33770. **/
  33771. enableOfflineSupport: boolean;
  33772. /**
  33773. * 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)
  33774. **/
  33775. disableManifestCheck: boolean;
  33776. /**
  33777. * Gets the list of created scenes
  33778. */
  33779. scenes: Scene[];
  33780. /**
  33781. * Event raised when a new scene is created
  33782. */
  33783. onNewSceneAddedObservable: Observable<Scene>;
  33784. /**
  33785. * Gets the list of created postprocesses
  33786. */
  33787. postProcesses: PostProcess[];
  33788. /**
  33789. * Gets a boolean indicating if the pointer is currently locked
  33790. */
  33791. isPointerLock: boolean;
  33792. /**
  33793. * Observable event triggered each time the rendering canvas is resized
  33794. */
  33795. onResizeObservable: Observable<Engine>;
  33796. /**
  33797. * Observable event triggered each time the canvas loses focus
  33798. */
  33799. onCanvasBlurObservable: Observable<Engine>;
  33800. /**
  33801. * Observable event triggered each time the canvas gains focus
  33802. */
  33803. onCanvasFocusObservable: Observable<Engine>;
  33804. /**
  33805. * Observable event triggered each time the canvas receives pointerout event
  33806. */
  33807. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33808. /**
  33809. * Observable raised when the engine begins a new frame
  33810. */
  33811. onBeginFrameObservable: Observable<Engine>;
  33812. /**
  33813. * If set, will be used to request the next animation frame for the render loop
  33814. */
  33815. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33816. /**
  33817. * Observable raised when the engine ends the current frame
  33818. */
  33819. onEndFrameObservable: Observable<Engine>;
  33820. /**
  33821. * Observable raised when the engine is about to compile a shader
  33822. */
  33823. onBeforeShaderCompilationObservable: Observable<Engine>;
  33824. /**
  33825. * Observable raised when the engine has jsut compiled a shader
  33826. */
  33827. onAfterShaderCompilationObservable: Observable<Engine>;
  33828. /**
  33829. * Gets the audio engine
  33830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33831. * @ignorenaming
  33832. */
  33833. static audioEngine: IAudioEngine;
  33834. /**
  33835. * Default AudioEngine factory responsible of creating the Audio Engine.
  33836. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33837. */
  33838. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33839. /**
  33840. * Default offline support factory responsible of creating a tool used to store data locally.
  33841. * By default, this will create a Database object if the workload has been embedded.
  33842. */
  33843. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33844. private _loadingScreen;
  33845. private _pointerLockRequested;
  33846. private _dummyFramebuffer;
  33847. private _rescalePostProcess;
  33848. private _deterministicLockstep;
  33849. private _lockstepMaxSteps;
  33850. private _timeStep;
  33851. protected get _supportsHardwareTextureRescaling(): boolean;
  33852. private _fps;
  33853. private _deltaTime;
  33854. /** @hidden */
  33855. _drawCalls: PerfCounter;
  33856. /** 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 */
  33857. canvasTabIndex: number;
  33858. /**
  33859. * Turn this value on if you want to pause FPS computation when in background
  33860. */
  33861. disablePerformanceMonitorInBackground: boolean;
  33862. private _performanceMonitor;
  33863. /**
  33864. * Gets the performance monitor attached to this engine
  33865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33866. */
  33867. get performanceMonitor(): PerformanceMonitor;
  33868. private _onFocus;
  33869. private _onBlur;
  33870. private _onCanvasPointerOut;
  33871. private _onCanvasBlur;
  33872. private _onCanvasFocus;
  33873. private _onFullscreenChange;
  33874. private _onPointerLockChange;
  33875. /**
  33876. * Gets the HTML element used to attach event listeners
  33877. * @returns a HTML element
  33878. */
  33879. getInputElement(): Nullable<HTMLElement>;
  33880. /**
  33881. * Creates a new engine
  33882. * @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
  33883. * @param antialias defines enable antialiasing (default: false)
  33884. * @param options defines further options to be sent to the getContext() function
  33885. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33886. */
  33887. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33888. /**
  33889. * Gets current aspect ratio
  33890. * @param viewportOwner defines the camera to use to get the aspect ratio
  33891. * @param useScreen defines if screen size must be used (or the current render target if any)
  33892. * @returns a number defining the aspect ratio
  33893. */
  33894. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33895. /**
  33896. * Gets current screen aspect ratio
  33897. * @returns a number defining the aspect ratio
  33898. */
  33899. getScreenAspectRatio(): number;
  33900. /**
  33901. * Gets the client rect of the HTML canvas attached with the current webGL context
  33902. * @returns a client rectanglee
  33903. */
  33904. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33905. /**
  33906. * Gets the client rect of the HTML element used for events
  33907. * @returns a client rectanglee
  33908. */
  33909. getInputElementClientRect(): Nullable<ClientRect>;
  33910. /**
  33911. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33913. * @returns true if engine is in deterministic lock step mode
  33914. */
  33915. isDeterministicLockStep(): boolean;
  33916. /**
  33917. * Gets the max steps when engine is running in deterministic lock step
  33918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33919. * @returns the max steps
  33920. */
  33921. getLockstepMaxSteps(): number;
  33922. /**
  33923. * Returns the time in ms between steps when using deterministic lock step.
  33924. * @returns time step in (ms)
  33925. */
  33926. getTimeStep(): number;
  33927. /**
  33928. * Force the mipmap generation for the given render target texture
  33929. * @param texture defines the render target texture to use
  33930. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33931. */
  33932. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33933. /** States */
  33934. /**
  33935. * Set various states to the webGL context
  33936. * @param culling defines backface culling state
  33937. * @param zOffset defines the value to apply to zOffset (0 by default)
  33938. * @param force defines if states must be applied even if cache is up to date
  33939. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33940. */
  33941. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33942. /**
  33943. * Set the z offset to apply to current rendering
  33944. * @param value defines the offset to apply
  33945. */
  33946. setZOffset(value: number): void;
  33947. /**
  33948. * Gets the current value of the zOffset
  33949. * @returns the current zOffset state
  33950. */
  33951. getZOffset(): number;
  33952. /**
  33953. * Enable or disable depth buffering
  33954. * @param enable defines the state to set
  33955. */
  33956. setDepthBuffer(enable: boolean): void;
  33957. /**
  33958. * Gets a boolean indicating if depth writing is enabled
  33959. * @returns the current depth writing state
  33960. */
  33961. getDepthWrite(): boolean;
  33962. /**
  33963. * Enable or disable depth writing
  33964. * @param enable defines the state to set
  33965. */
  33966. setDepthWrite(enable: boolean): void;
  33967. /**
  33968. * Gets a boolean indicating if stencil buffer is enabled
  33969. * @returns the current stencil buffer state
  33970. */
  33971. getStencilBuffer(): boolean;
  33972. /**
  33973. * Enable or disable the stencil buffer
  33974. * @param enable defines if the stencil buffer must be enabled or disabled
  33975. */
  33976. setStencilBuffer(enable: boolean): void;
  33977. /**
  33978. * Gets the current stencil mask
  33979. * @returns a number defining the new stencil mask to use
  33980. */
  33981. getStencilMask(): number;
  33982. /**
  33983. * Sets the current stencil mask
  33984. * @param mask defines the new stencil mask to use
  33985. */
  33986. setStencilMask(mask: number): void;
  33987. /**
  33988. * Gets the current stencil function
  33989. * @returns a number defining the stencil function to use
  33990. */
  33991. getStencilFunction(): number;
  33992. /**
  33993. * Gets the current stencil reference value
  33994. * @returns a number defining the stencil reference value to use
  33995. */
  33996. getStencilFunctionReference(): number;
  33997. /**
  33998. * Gets the current stencil mask
  33999. * @returns a number defining the stencil mask to use
  34000. */
  34001. getStencilFunctionMask(): number;
  34002. /**
  34003. * Sets the current stencil function
  34004. * @param stencilFunc defines the new stencil function to use
  34005. */
  34006. setStencilFunction(stencilFunc: number): void;
  34007. /**
  34008. * Sets the current stencil reference
  34009. * @param reference defines the new stencil reference to use
  34010. */
  34011. setStencilFunctionReference(reference: number): void;
  34012. /**
  34013. * Sets the current stencil mask
  34014. * @param mask defines the new stencil mask to use
  34015. */
  34016. setStencilFunctionMask(mask: number): void;
  34017. /**
  34018. * Gets the current stencil operation when stencil fails
  34019. * @returns a number defining stencil operation to use when stencil fails
  34020. */
  34021. getStencilOperationFail(): number;
  34022. /**
  34023. * Gets the current stencil operation when depth fails
  34024. * @returns a number defining stencil operation to use when depth fails
  34025. */
  34026. getStencilOperationDepthFail(): number;
  34027. /**
  34028. * Gets the current stencil operation when stencil passes
  34029. * @returns a number defining stencil operation to use when stencil passes
  34030. */
  34031. getStencilOperationPass(): number;
  34032. /**
  34033. * Sets the stencil operation to use when stencil fails
  34034. * @param operation defines the stencil operation to use when stencil fails
  34035. */
  34036. setStencilOperationFail(operation: number): void;
  34037. /**
  34038. * Sets the stencil operation to use when depth fails
  34039. * @param operation defines the stencil operation to use when depth fails
  34040. */
  34041. setStencilOperationDepthFail(operation: number): void;
  34042. /**
  34043. * Sets the stencil operation to use when stencil passes
  34044. * @param operation defines the stencil operation to use when stencil passes
  34045. */
  34046. setStencilOperationPass(operation: number): void;
  34047. /**
  34048. * Sets a boolean indicating if the dithering state is enabled or disabled
  34049. * @param value defines the dithering state
  34050. */
  34051. setDitheringState(value: boolean): void;
  34052. /**
  34053. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34054. * @param value defines the rasterizer state
  34055. */
  34056. setRasterizerState(value: boolean): void;
  34057. /**
  34058. * Gets the current depth function
  34059. * @returns a number defining the depth function
  34060. */
  34061. getDepthFunction(): Nullable<number>;
  34062. /**
  34063. * Sets the current depth function
  34064. * @param depthFunc defines the function to use
  34065. */
  34066. setDepthFunction(depthFunc: number): void;
  34067. /**
  34068. * Sets the current depth function to GREATER
  34069. */
  34070. setDepthFunctionToGreater(): void;
  34071. /**
  34072. * Sets the current depth function to GEQUAL
  34073. */
  34074. setDepthFunctionToGreaterOrEqual(): void;
  34075. /**
  34076. * Sets the current depth function to LESS
  34077. */
  34078. setDepthFunctionToLess(): void;
  34079. /**
  34080. * Sets the current depth function to LEQUAL
  34081. */
  34082. setDepthFunctionToLessOrEqual(): void;
  34083. private _cachedStencilBuffer;
  34084. private _cachedStencilFunction;
  34085. private _cachedStencilMask;
  34086. private _cachedStencilOperationPass;
  34087. private _cachedStencilOperationFail;
  34088. private _cachedStencilOperationDepthFail;
  34089. private _cachedStencilReference;
  34090. /**
  34091. * Caches the the state of the stencil buffer
  34092. */
  34093. cacheStencilState(): void;
  34094. /**
  34095. * Restores the state of the stencil buffer
  34096. */
  34097. restoreStencilState(): void;
  34098. /**
  34099. * Directly set the WebGL Viewport
  34100. * @param x defines the x coordinate of the viewport (in screen space)
  34101. * @param y defines the y coordinate of the viewport (in screen space)
  34102. * @param width defines the width of the viewport (in screen space)
  34103. * @param height defines the height of the viewport (in screen space)
  34104. * @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
  34105. */
  34106. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34107. /**
  34108. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34109. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34110. * @param y defines the y-coordinate of the corner of the clear rectangle
  34111. * @param width defines the width of the clear rectangle
  34112. * @param height defines the height of the clear rectangle
  34113. * @param clearColor defines the clear color
  34114. */
  34115. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34116. /**
  34117. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34118. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34119. * @param y defines the y-coordinate of the corner of the clear rectangle
  34120. * @param width defines the width of the clear rectangle
  34121. * @param height defines the height of the clear rectangle
  34122. */
  34123. enableScissor(x: number, y: number, width: number, height: number): void;
  34124. /**
  34125. * Disable previously set scissor test rectangle
  34126. */
  34127. disableScissor(): void;
  34128. protected _reportDrawCall(): void;
  34129. /**
  34130. * Initializes a webVR display and starts listening to display change events
  34131. * The onVRDisplayChangedObservable will be notified upon these changes
  34132. * @returns The onVRDisplayChangedObservable
  34133. */
  34134. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34135. /** @hidden */
  34136. _prepareVRComponent(): void;
  34137. /** @hidden */
  34138. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34139. /** @hidden */
  34140. _submitVRFrame(): void;
  34141. /**
  34142. * Call this function to leave webVR mode
  34143. * Will do nothing if webVR is not supported or if there is no webVR device
  34144. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34145. */
  34146. disableVR(): void;
  34147. /**
  34148. * Gets a boolean indicating that the system is in VR mode and is presenting
  34149. * @returns true if VR mode is engaged
  34150. */
  34151. isVRPresenting(): boolean;
  34152. /** @hidden */
  34153. _requestVRFrame(): void;
  34154. /** @hidden */
  34155. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34156. /**
  34157. * Gets the source code of the vertex shader associated with a specific webGL program
  34158. * @param program defines the program to use
  34159. * @returns a string containing the source code of the vertex shader associated with the program
  34160. */
  34161. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34162. /**
  34163. * Gets the source code of the fragment shader associated with a specific webGL program
  34164. * @param program defines the program to use
  34165. * @returns a string containing the source code of the fragment shader associated with the program
  34166. */
  34167. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34168. /**
  34169. * Sets a depth stencil texture from a render target to the according uniform.
  34170. * @param channel The texture channel
  34171. * @param uniform The uniform to set
  34172. * @param texture The render target texture containing the depth stencil texture to apply
  34173. */
  34174. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34175. /**
  34176. * Sets a texture to the webGL context from a postprocess
  34177. * @param channel defines the channel to use
  34178. * @param postProcess defines the source postprocess
  34179. */
  34180. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34181. /**
  34182. * Binds the output of the passed in post process to the texture channel specified
  34183. * @param channel The channel the texture should be bound to
  34184. * @param postProcess The post process which's output should be bound
  34185. */
  34186. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34187. protected _rebuildBuffers(): void;
  34188. /** @hidden */
  34189. _renderFrame(): void;
  34190. _renderLoop(): void;
  34191. /** @hidden */
  34192. _renderViews(): boolean;
  34193. /**
  34194. * Toggle full screen mode
  34195. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34196. */
  34197. switchFullscreen(requestPointerLock: boolean): void;
  34198. /**
  34199. * Enters full screen mode
  34200. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34201. */
  34202. enterFullscreen(requestPointerLock: boolean): void;
  34203. /**
  34204. * Exits full screen mode
  34205. */
  34206. exitFullscreen(): void;
  34207. /**
  34208. * Enters Pointerlock mode
  34209. */
  34210. enterPointerlock(): void;
  34211. /**
  34212. * Exits Pointerlock mode
  34213. */
  34214. exitPointerlock(): void;
  34215. /**
  34216. * Begin a new frame
  34217. */
  34218. beginFrame(): void;
  34219. /**
  34220. * Enf the current frame
  34221. */
  34222. endFrame(): void;
  34223. resize(): void;
  34224. /**
  34225. * Force a specific size of the canvas
  34226. * @param width defines the new canvas' width
  34227. * @param height defines the new canvas' height
  34228. */
  34229. setSize(width: number, height: number): void;
  34230. /**
  34231. * Updates a dynamic vertex buffer.
  34232. * @param vertexBuffer the vertex buffer to update
  34233. * @param data the data used to update the vertex buffer
  34234. * @param byteOffset the byte offset of the data
  34235. * @param byteLength the byte length of the data
  34236. */
  34237. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34238. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34239. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34240. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34241. _releaseTexture(texture: InternalTexture): void;
  34242. /**
  34243. * @hidden
  34244. * Rescales a texture
  34245. * @param source input texutre
  34246. * @param destination destination texture
  34247. * @param scene scene to use to render the resize
  34248. * @param internalFormat format to use when resizing
  34249. * @param onComplete callback to be called when resize has completed
  34250. */
  34251. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34252. /**
  34253. * Gets the current framerate
  34254. * @returns a number representing the framerate
  34255. */
  34256. getFps(): number;
  34257. /**
  34258. * Gets the time spent between current and previous frame
  34259. * @returns a number representing the delta time in ms
  34260. */
  34261. getDeltaTime(): number;
  34262. private _measureFps;
  34263. /** @hidden */
  34264. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34265. /**
  34266. * Update a dynamic index buffer
  34267. * @param indexBuffer defines the target index buffer
  34268. * @param indices defines the data to update
  34269. * @param offset defines the offset in the target index buffer where update should start
  34270. */
  34271. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34272. /**
  34273. * Updates the sample count of a render target texture
  34274. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34275. * @param texture defines the texture to update
  34276. * @param samples defines the sample count to set
  34277. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34278. */
  34279. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34280. /**
  34281. * Updates a depth texture Comparison Mode and Function.
  34282. * If the comparison Function is equal to 0, the mode will be set to none.
  34283. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34284. * @param texture The texture to set the comparison function for
  34285. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34286. */
  34287. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34288. /**
  34289. * Creates a webGL buffer to use with instanciation
  34290. * @param capacity defines the size of the buffer
  34291. * @returns the webGL buffer
  34292. */
  34293. createInstancesBuffer(capacity: number): DataBuffer;
  34294. /**
  34295. * Delete a webGL buffer used with instanciation
  34296. * @param buffer defines the webGL buffer to delete
  34297. */
  34298. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34299. private _clientWaitAsync;
  34300. /** @hidden */
  34301. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34302. /** @hidden */
  34303. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34304. dispose(): void;
  34305. private _disableTouchAction;
  34306. /**
  34307. * Display the loading screen
  34308. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34309. */
  34310. displayLoadingUI(): void;
  34311. /**
  34312. * Hide the loading screen
  34313. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34314. */
  34315. hideLoadingUI(): void;
  34316. /**
  34317. * Gets the current loading screen object
  34318. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34319. */
  34320. get loadingScreen(): ILoadingScreen;
  34321. /**
  34322. * Sets the current loading screen object
  34323. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34324. */
  34325. set loadingScreen(loadingScreen: ILoadingScreen);
  34326. /**
  34327. * Sets the current loading screen text
  34328. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34329. */
  34330. set loadingUIText(text: string);
  34331. /**
  34332. * Sets the current loading screen background color
  34333. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34334. */
  34335. set loadingUIBackgroundColor(color: string);
  34336. /** Pointerlock and fullscreen */
  34337. /**
  34338. * Ask the browser to promote the current element to pointerlock mode
  34339. * @param element defines the DOM element to promote
  34340. */
  34341. static _RequestPointerlock(element: HTMLElement): void;
  34342. /**
  34343. * Asks the browser to exit pointerlock mode
  34344. */
  34345. static _ExitPointerlock(): void;
  34346. /**
  34347. * Ask the browser to promote the current element to fullscreen rendering mode
  34348. * @param element defines the DOM element to promote
  34349. */
  34350. static _RequestFullscreen(element: HTMLElement): void;
  34351. /**
  34352. * Asks the browser to exit fullscreen mode
  34353. */
  34354. static _ExitFullscreen(): void;
  34355. }
  34356. }
  34357. declare module BABYLON {
  34358. /**
  34359. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34360. * during the life time of the application.
  34361. */
  34362. export class EngineStore {
  34363. /** Gets the list of created engines */
  34364. static Instances: Engine[];
  34365. /** @hidden */
  34366. static _LastCreatedScene: Nullable<Scene>;
  34367. /**
  34368. * Gets the latest created engine
  34369. */
  34370. static get LastCreatedEngine(): Nullable<Engine>;
  34371. /**
  34372. * Gets the latest created scene
  34373. */
  34374. static get LastCreatedScene(): Nullable<Scene>;
  34375. /**
  34376. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34377. * @ignorenaming
  34378. */
  34379. static UseFallbackTexture: boolean;
  34380. /**
  34381. * Texture content used if a texture cannot loaded
  34382. * @ignorenaming
  34383. */
  34384. static FallbackTexture: string;
  34385. }
  34386. }
  34387. declare module BABYLON {
  34388. /**
  34389. * Helper class that provides a small promise polyfill
  34390. */
  34391. export class PromisePolyfill {
  34392. /**
  34393. * Static function used to check if the polyfill is required
  34394. * If this is the case then the function will inject the polyfill to window.Promise
  34395. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34396. */
  34397. static Apply(force?: boolean): void;
  34398. }
  34399. }
  34400. declare module BABYLON {
  34401. /**
  34402. * Interface for screenshot methods with describe argument called `size` as object with options
  34403. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34404. */
  34405. export interface IScreenshotSize {
  34406. /**
  34407. * number in pixels for canvas height
  34408. */
  34409. height?: number;
  34410. /**
  34411. * multiplier allowing render at a higher or lower resolution
  34412. * If value is defined then height and width will be ignored and taken from camera
  34413. */
  34414. precision?: number;
  34415. /**
  34416. * number in pixels for canvas width
  34417. */
  34418. width?: number;
  34419. }
  34420. }
  34421. declare module BABYLON {
  34422. interface IColor4Like {
  34423. r: float;
  34424. g: float;
  34425. b: float;
  34426. a: float;
  34427. }
  34428. /**
  34429. * Class containing a set of static utilities functions
  34430. */
  34431. export class Tools {
  34432. /**
  34433. * Gets or sets the base URL to use to load assets
  34434. */
  34435. static get BaseUrl(): string;
  34436. static set BaseUrl(value: string);
  34437. /**
  34438. * Enable/Disable Custom HTTP Request Headers globally.
  34439. * default = false
  34440. * @see CustomRequestHeaders
  34441. */
  34442. static UseCustomRequestHeaders: boolean;
  34443. /**
  34444. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34445. * i.e. when loading files, where the server/service expects an Authorization header
  34446. */
  34447. static CustomRequestHeaders: {
  34448. [key: string]: string;
  34449. };
  34450. /**
  34451. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34452. */
  34453. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34454. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34455. /**
  34456. * Default behaviour for cors in the application.
  34457. * It can be a string if the expected behavior is identical in the entire app.
  34458. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34459. */
  34460. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34461. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34462. /**
  34463. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34464. * @ignorenaming
  34465. */
  34466. static get UseFallbackTexture(): boolean;
  34467. static set UseFallbackTexture(value: boolean);
  34468. /**
  34469. * Use this object to register external classes like custom textures or material
  34470. * to allow the laoders to instantiate them
  34471. */
  34472. static get RegisteredExternalClasses(): {
  34473. [key: string]: Object;
  34474. };
  34475. static set RegisteredExternalClasses(classes: {
  34476. [key: string]: Object;
  34477. });
  34478. /**
  34479. * Texture content used if a texture cannot loaded
  34480. * @ignorenaming
  34481. */
  34482. static get fallbackTexture(): string;
  34483. static set fallbackTexture(value: string);
  34484. /**
  34485. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34486. * @param u defines the coordinate on X axis
  34487. * @param v defines the coordinate on Y axis
  34488. * @param width defines the width of the source data
  34489. * @param height defines the height of the source data
  34490. * @param pixels defines the source byte array
  34491. * @param color defines the output color
  34492. */
  34493. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34494. /**
  34495. * Interpolates between a and b via alpha
  34496. * @param a The lower value (returned when alpha = 0)
  34497. * @param b The upper value (returned when alpha = 1)
  34498. * @param alpha The interpolation-factor
  34499. * @return The mixed value
  34500. */
  34501. static Mix(a: number, b: number, alpha: number): number;
  34502. /**
  34503. * Tries to instantiate a new object from a given class name
  34504. * @param className defines the class name to instantiate
  34505. * @returns the new object or null if the system was not able to do the instantiation
  34506. */
  34507. static Instantiate(className: string): any;
  34508. /**
  34509. * Provides a slice function that will work even on IE
  34510. * @param data defines the array to slice
  34511. * @param start defines the start of the data (optional)
  34512. * @param end defines the end of the data (optional)
  34513. * @returns the new sliced array
  34514. */
  34515. static Slice<T>(data: T, start?: number, end?: number): T;
  34516. /**
  34517. * Polyfill for setImmediate
  34518. * @param action defines the action to execute after the current execution block
  34519. */
  34520. static SetImmediate(action: () => void): void;
  34521. /**
  34522. * Function indicating if a number is an exponent of 2
  34523. * @param value defines the value to test
  34524. * @returns true if the value is an exponent of 2
  34525. */
  34526. static IsExponentOfTwo(value: number): boolean;
  34527. private static _tmpFloatArray;
  34528. /**
  34529. * Returns the nearest 32-bit single precision float representation of a Number
  34530. * @param value A Number. If the parameter is of a different type, it will get converted
  34531. * to a number or to NaN if it cannot be converted
  34532. * @returns number
  34533. */
  34534. static FloatRound(value: number): number;
  34535. /**
  34536. * Extracts the filename from a path
  34537. * @param path defines the path to use
  34538. * @returns the filename
  34539. */
  34540. static GetFilename(path: string): string;
  34541. /**
  34542. * Extracts the "folder" part of a path (everything before the filename).
  34543. * @param uri The URI to extract the info from
  34544. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34545. * @returns The "folder" part of the path
  34546. */
  34547. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34548. /**
  34549. * Extracts text content from a DOM element hierarchy
  34550. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34551. */
  34552. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34553. /**
  34554. * Convert an angle in radians to degrees
  34555. * @param angle defines the angle to convert
  34556. * @returns the angle in degrees
  34557. */
  34558. static ToDegrees(angle: number): number;
  34559. /**
  34560. * Convert an angle in degrees to radians
  34561. * @param angle defines the angle to convert
  34562. * @returns the angle in radians
  34563. */
  34564. static ToRadians(angle: number): number;
  34565. /**
  34566. * Returns an array if obj is not an array
  34567. * @param obj defines the object to evaluate as an array
  34568. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34569. * @returns either obj directly if obj is an array or a new array containing obj
  34570. */
  34571. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34572. /**
  34573. * Gets the pointer prefix to use
  34574. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34575. */
  34576. static GetPointerPrefix(): string;
  34577. /**
  34578. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34579. * @param url define the url we are trying
  34580. * @param element define the dom element where to configure the cors policy
  34581. */
  34582. static SetCorsBehavior(url: string | string[], element: {
  34583. crossOrigin: string | null;
  34584. }): void;
  34585. /**
  34586. * Removes unwanted characters from an url
  34587. * @param url defines the url to clean
  34588. * @returns the cleaned url
  34589. */
  34590. static CleanUrl(url: string): string;
  34591. /**
  34592. * Gets or sets a function used to pre-process url before using them to load assets
  34593. */
  34594. static get PreprocessUrl(): (url: string) => string;
  34595. static set PreprocessUrl(processor: (url: string) => string);
  34596. /**
  34597. * Loads an image as an HTMLImageElement.
  34598. * @param input url string, ArrayBuffer, or Blob to load
  34599. * @param onLoad callback called when the image successfully loads
  34600. * @param onError callback called when the image fails to load
  34601. * @param offlineProvider offline provider for caching
  34602. * @param mimeType optional mime type
  34603. * @returns the HTMLImageElement of the loaded image
  34604. */
  34605. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34606. /**
  34607. * Loads a file from a url
  34608. * @param url url string, ArrayBuffer, or Blob to load
  34609. * @param onSuccess callback called when the file successfully loads
  34610. * @param onProgress callback called while file is loading (if the server supports this mode)
  34611. * @param offlineProvider defines the offline provider for caching
  34612. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34613. * @param onError callback called when the file fails to load
  34614. * @returns a file request object
  34615. */
  34616. 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;
  34617. /**
  34618. * Loads a file from a url
  34619. * @param url the file url to load
  34620. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34621. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34622. */
  34623. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34624. /**
  34625. * Load a script (identified by an url). When the url returns, the
  34626. * content of this file is added into a new script element, attached to the DOM (body element)
  34627. * @param scriptUrl defines the url of the script to laod
  34628. * @param onSuccess defines the callback called when the script is loaded
  34629. * @param onError defines the callback to call if an error occurs
  34630. * @param scriptId defines the id of the script element
  34631. */
  34632. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34633. /**
  34634. * Load an asynchronous script (identified by an url). When the url returns, the
  34635. * content of this file is added into a new script element, attached to the DOM (body element)
  34636. * @param scriptUrl defines the url of the script to laod
  34637. * @param scriptId defines the id of the script element
  34638. * @returns a promise request object
  34639. */
  34640. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34641. /**
  34642. * Loads a file from a blob
  34643. * @param fileToLoad defines the blob to use
  34644. * @param callback defines the callback to call when data is loaded
  34645. * @param progressCallback defines the callback to call during loading process
  34646. * @returns a file request object
  34647. */
  34648. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34649. /**
  34650. * Reads a file from a File object
  34651. * @param file defines the file to load
  34652. * @param onSuccess defines the callback to call when data is loaded
  34653. * @param onProgress defines the callback to call during loading process
  34654. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34655. * @param onError defines the callback to call when an error occurs
  34656. * @returns a file request object
  34657. */
  34658. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34659. /**
  34660. * Creates a data url from a given string content
  34661. * @param content defines the content to convert
  34662. * @returns the new data url link
  34663. */
  34664. static FileAsURL(content: string): string;
  34665. /**
  34666. * Format the given number to a specific decimal format
  34667. * @param value defines the number to format
  34668. * @param decimals defines the number of decimals to use
  34669. * @returns the formatted string
  34670. */
  34671. static Format(value: number, decimals?: number): string;
  34672. /**
  34673. * Tries to copy an object by duplicating every property
  34674. * @param source defines the source object
  34675. * @param destination defines the target object
  34676. * @param doNotCopyList defines a list of properties to avoid
  34677. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34678. */
  34679. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34680. /**
  34681. * Gets a boolean indicating if the given object has no own property
  34682. * @param obj defines the object to test
  34683. * @returns true if object has no own property
  34684. */
  34685. static IsEmpty(obj: any): boolean;
  34686. /**
  34687. * Function used to register events at window level
  34688. * @param windowElement defines the Window object to use
  34689. * @param events defines the events to register
  34690. */
  34691. static RegisterTopRootEvents(windowElement: Window, events: {
  34692. name: string;
  34693. handler: Nullable<(e: FocusEvent) => any>;
  34694. }[]): void;
  34695. /**
  34696. * Function used to unregister events from window level
  34697. * @param windowElement defines the Window object to use
  34698. * @param events defines the events to unregister
  34699. */
  34700. static UnregisterTopRootEvents(windowElement: Window, events: {
  34701. name: string;
  34702. handler: Nullable<(e: FocusEvent) => any>;
  34703. }[]): void;
  34704. /**
  34705. * @ignore
  34706. */
  34707. static _ScreenshotCanvas: HTMLCanvasElement;
  34708. /**
  34709. * Dumps the current bound framebuffer
  34710. * @param width defines the rendering width
  34711. * @param height defines the rendering height
  34712. * @param engine defines the hosting engine
  34713. * @param successCallback defines the callback triggered once the data are available
  34714. * @param mimeType defines the mime type of the result
  34715. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34716. */
  34717. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34718. /**
  34719. * Converts the canvas data to blob.
  34720. * This acts as a polyfill for browsers not supporting the to blob function.
  34721. * @param canvas Defines the canvas to extract the data from
  34722. * @param successCallback Defines the callback triggered once the data are available
  34723. * @param mimeType Defines the mime type of the result
  34724. */
  34725. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34726. /**
  34727. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34728. * @param successCallback defines the callback triggered once the data are available
  34729. * @param mimeType defines the mime type of the result
  34730. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34731. */
  34732. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34733. /**
  34734. * Downloads a blob in the browser
  34735. * @param blob defines the blob to download
  34736. * @param fileName defines the name of the downloaded file
  34737. */
  34738. static Download(blob: Blob, fileName: string): void;
  34739. /**
  34740. * Captures a screenshot of the current rendering
  34741. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34742. * @param engine defines the rendering engine
  34743. * @param camera defines the source camera
  34744. * @param size This parameter can be set to a single number or to an object with the
  34745. * following (optional) properties: precision, width, height. If a single number is passed,
  34746. * it will be used for both width and height. If an object is passed, the screenshot size
  34747. * will be derived from the parameters. The precision property is a multiplier allowing
  34748. * rendering at a higher or lower resolution
  34749. * @param successCallback defines the callback receives a single parameter which contains the
  34750. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34751. * src parameter of an <img> to display it
  34752. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34753. * Check your browser for supported MIME types
  34754. */
  34755. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34756. /**
  34757. * Captures a screenshot of the current rendering
  34758. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34759. * @param engine defines the rendering engine
  34760. * @param camera defines the source camera
  34761. * @param size This parameter can be set to a single number or to an object with the
  34762. * following (optional) properties: precision, width, height. If a single number is passed,
  34763. * it will be used for both width and height. If an object is passed, the screenshot size
  34764. * will be derived from the parameters. The precision property is a multiplier allowing
  34765. * rendering at a higher or lower resolution
  34766. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34767. * Check your browser for supported MIME types
  34768. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34769. * to the src parameter of an <img> to display it
  34770. */
  34771. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34772. /**
  34773. * Generates an image screenshot from the specified camera.
  34774. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34775. * @param engine The engine to use for rendering
  34776. * @param camera The camera to use for rendering
  34777. * @param size This parameter can be set to a single number or to an object with the
  34778. * following (optional) properties: precision, width, height. If a single number is passed,
  34779. * it will be used for both width and height. If an object is passed, the screenshot size
  34780. * will be derived from the parameters. The precision property is a multiplier allowing
  34781. * rendering at a higher or lower resolution
  34782. * @param successCallback The callback receives a single parameter which contains the
  34783. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34784. * src parameter of an <img> to display it
  34785. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34786. * Check your browser for supported MIME types
  34787. * @param samples Texture samples (default: 1)
  34788. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34789. * @param fileName A name for for the downloaded file.
  34790. */
  34791. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34792. /**
  34793. * Generates an image screenshot from the specified camera.
  34794. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34795. * @param engine The engine to use for rendering
  34796. * @param camera The camera to use for rendering
  34797. * @param size This parameter can be set to a single number or to an object with the
  34798. * following (optional) properties: precision, width, height. If a single number is passed,
  34799. * it will be used for both width and height. If an object is passed, the screenshot size
  34800. * will be derived from the parameters. The precision property is a multiplier allowing
  34801. * rendering at a higher or lower resolution
  34802. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34803. * Check your browser for supported MIME types
  34804. * @param samples Texture samples (default: 1)
  34805. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34806. * @param fileName A name for for the downloaded file.
  34807. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34808. * to the src parameter of an <img> to display it
  34809. */
  34810. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34811. /**
  34812. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34813. * Be aware Math.random() could cause collisions, but:
  34814. * "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"
  34815. * @returns a pseudo random id
  34816. */
  34817. static RandomId(): string;
  34818. /**
  34819. * Test if the given uri is a base64 string
  34820. * @param uri The uri to test
  34821. * @return True if the uri is a base64 string or false otherwise
  34822. */
  34823. static IsBase64(uri: string): boolean;
  34824. /**
  34825. * Decode the given base64 uri.
  34826. * @param uri The uri to decode
  34827. * @return The decoded base64 data.
  34828. */
  34829. static DecodeBase64(uri: string): ArrayBuffer;
  34830. /**
  34831. * Gets the absolute url.
  34832. * @param url the input url
  34833. * @return the absolute url
  34834. */
  34835. static GetAbsoluteUrl(url: string): string;
  34836. /**
  34837. * No log
  34838. */
  34839. static readonly NoneLogLevel: number;
  34840. /**
  34841. * Only message logs
  34842. */
  34843. static readonly MessageLogLevel: number;
  34844. /**
  34845. * Only warning logs
  34846. */
  34847. static readonly WarningLogLevel: number;
  34848. /**
  34849. * Only error logs
  34850. */
  34851. static readonly ErrorLogLevel: number;
  34852. /**
  34853. * All logs
  34854. */
  34855. static readonly AllLogLevel: number;
  34856. /**
  34857. * Gets a value indicating the number of loading errors
  34858. * @ignorenaming
  34859. */
  34860. static get errorsCount(): number;
  34861. /**
  34862. * Callback called when a new log is added
  34863. */
  34864. static OnNewCacheEntry: (entry: string) => void;
  34865. /**
  34866. * Log a message to the console
  34867. * @param message defines the message to log
  34868. */
  34869. static Log(message: string): void;
  34870. /**
  34871. * Write a warning message to the console
  34872. * @param message defines the message to log
  34873. */
  34874. static Warn(message: string): void;
  34875. /**
  34876. * Write an error message to the console
  34877. * @param message defines the message to log
  34878. */
  34879. static Error(message: string): void;
  34880. /**
  34881. * Gets current log cache (list of logs)
  34882. */
  34883. static get LogCache(): string;
  34884. /**
  34885. * Clears the log cache
  34886. */
  34887. static ClearLogCache(): void;
  34888. /**
  34889. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34890. */
  34891. static set LogLevels(level: number);
  34892. /**
  34893. * Checks if the window object exists
  34894. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34895. */
  34896. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34897. /**
  34898. * No performance log
  34899. */
  34900. static readonly PerformanceNoneLogLevel: number;
  34901. /**
  34902. * Use user marks to log performance
  34903. */
  34904. static readonly PerformanceUserMarkLogLevel: number;
  34905. /**
  34906. * Log performance to the console
  34907. */
  34908. static readonly PerformanceConsoleLogLevel: number;
  34909. private static _performance;
  34910. /**
  34911. * Sets the current performance log level
  34912. */
  34913. static set PerformanceLogLevel(level: number);
  34914. private static _StartPerformanceCounterDisabled;
  34915. private static _EndPerformanceCounterDisabled;
  34916. private static _StartUserMark;
  34917. private static _EndUserMark;
  34918. private static _StartPerformanceConsole;
  34919. private static _EndPerformanceConsole;
  34920. /**
  34921. * Starts a performance counter
  34922. */
  34923. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34924. /**
  34925. * Ends a specific performance coutner
  34926. */
  34927. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34928. /**
  34929. * Gets either window.performance.now() if supported or Date.now() else
  34930. */
  34931. static get Now(): number;
  34932. /**
  34933. * This method will return the name of the class used to create the instance of the given object.
  34934. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34935. * @param object the object to get the class name from
  34936. * @param isType defines if the object is actually a type
  34937. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34938. */
  34939. static GetClassName(object: any, isType?: boolean): string;
  34940. /**
  34941. * Gets the first element of an array satisfying a given predicate
  34942. * @param array defines the array to browse
  34943. * @param predicate defines the predicate to use
  34944. * @returns null if not found or the element
  34945. */
  34946. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34947. /**
  34948. * This method will return the name of the full name of the class, including its owning module (if any).
  34949. * 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).
  34950. * @param object the object to get the class name from
  34951. * @param isType defines if the object is actually a type
  34952. * @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.
  34953. * @ignorenaming
  34954. */
  34955. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34956. /**
  34957. * Returns a promise that resolves after the given amount of time.
  34958. * @param delay Number of milliseconds to delay
  34959. * @returns Promise that resolves after the given amount of time
  34960. */
  34961. static DelayAsync(delay: number): Promise<void>;
  34962. /**
  34963. * Utility function to detect if the current user agent is Safari
  34964. * @returns whether or not the current user agent is safari
  34965. */
  34966. static IsSafari(): boolean;
  34967. }
  34968. /**
  34969. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34970. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34971. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34972. * @param name The name of the class, case should be preserved
  34973. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34974. */
  34975. export function className(name: string, module?: string): (target: Object) => void;
  34976. /**
  34977. * An implementation of a loop for asynchronous functions.
  34978. */
  34979. export class AsyncLoop {
  34980. /**
  34981. * Defines the number of iterations for the loop
  34982. */
  34983. iterations: number;
  34984. /**
  34985. * Defines the current index of the loop.
  34986. */
  34987. index: number;
  34988. private _done;
  34989. private _fn;
  34990. private _successCallback;
  34991. /**
  34992. * Constructor.
  34993. * @param iterations the number of iterations.
  34994. * @param func the function to run each iteration
  34995. * @param successCallback the callback that will be called upon succesful execution
  34996. * @param offset starting offset.
  34997. */
  34998. constructor(
  34999. /**
  35000. * Defines the number of iterations for the loop
  35001. */
  35002. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35003. /**
  35004. * Execute the next iteration. Must be called after the last iteration was finished.
  35005. */
  35006. executeNext(): void;
  35007. /**
  35008. * Break the loop and run the success callback.
  35009. */
  35010. breakLoop(): void;
  35011. /**
  35012. * Create and run an async loop.
  35013. * @param iterations the number of iterations.
  35014. * @param fn the function to run each iteration
  35015. * @param successCallback the callback that will be called upon succesful execution
  35016. * @param offset starting offset.
  35017. * @returns the created async loop object
  35018. */
  35019. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35020. /**
  35021. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35022. * @param iterations total number of iterations
  35023. * @param syncedIterations number of synchronous iterations in each async iteration.
  35024. * @param fn the function to call each iteration.
  35025. * @param callback a success call back that will be called when iterating stops.
  35026. * @param breakFunction a break condition (optional)
  35027. * @param timeout timeout settings for the setTimeout function. default - 0.
  35028. * @returns the created async loop object
  35029. */
  35030. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35031. }
  35032. }
  35033. declare module BABYLON {
  35034. /**
  35035. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35036. * The underlying implementation relies on an associative array to ensure the best performances.
  35037. * The value can be anything including 'null' but except 'undefined'
  35038. */
  35039. export class StringDictionary<T> {
  35040. /**
  35041. * This will clear this dictionary and copy the content from the 'source' one.
  35042. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35043. * @param source the dictionary to take the content from and copy to this dictionary
  35044. */
  35045. copyFrom(source: StringDictionary<T>): void;
  35046. /**
  35047. * Get a value based from its key
  35048. * @param key the given key to get the matching value from
  35049. * @return the value if found, otherwise undefined is returned
  35050. */
  35051. get(key: string): T | undefined;
  35052. /**
  35053. * Get a value from its key or add it if it doesn't exist.
  35054. * This method will ensure you that a given key/data will be present in the dictionary.
  35055. * @param key the given key to get the matching value from
  35056. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35057. * The factory will only be invoked if there's no data for the given key.
  35058. * @return the value corresponding to the key.
  35059. */
  35060. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35061. /**
  35062. * Get a value from its key if present in the dictionary otherwise add it
  35063. * @param key the key to get the value from
  35064. * @param val if there's no such key/value pair in the dictionary add it with this value
  35065. * @return the value corresponding to the key
  35066. */
  35067. getOrAdd(key: string, val: T): T;
  35068. /**
  35069. * Check if there's a given key in the dictionary
  35070. * @param key the key to check for
  35071. * @return true if the key is present, false otherwise
  35072. */
  35073. contains(key: string): boolean;
  35074. /**
  35075. * Add a new key and its corresponding value
  35076. * @param key the key to add
  35077. * @param value the value corresponding to the key
  35078. * @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
  35079. */
  35080. add(key: string, value: T): boolean;
  35081. /**
  35082. * Update a specific value associated to a key
  35083. * @param key defines the key to use
  35084. * @param value defines the value to store
  35085. * @returns true if the value was updated (or false if the key was not found)
  35086. */
  35087. set(key: string, value: T): boolean;
  35088. /**
  35089. * Get the element of the given key and remove it from the dictionary
  35090. * @param key defines the key to search
  35091. * @returns the value associated with the key or null if not found
  35092. */
  35093. getAndRemove(key: string): Nullable<T>;
  35094. /**
  35095. * Remove a key/value from the dictionary.
  35096. * @param key the key to remove
  35097. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35098. */
  35099. remove(key: string): boolean;
  35100. /**
  35101. * Clear the whole content of the dictionary
  35102. */
  35103. clear(): void;
  35104. /**
  35105. * Gets the current count
  35106. */
  35107. get count(): number;
  35108. /**
  35109. * Execute a callback on each key/val of the dictionary.
  35110. * Note that you can remove any element in this dictionary in the callback implementation
  35111. * @param callback the callback to execute on a given key/value pair
  35112. */
  35113. forEach(callback: (key: string, val: T) => void): void;
  35114. /**
  35115. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35116. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35117. * Note that you can remove any element in this dictionary in the callback implementation
  35118. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35119. * @returns the first item
  35120. */
  35121. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35122. private _count;
  35123. private _data;
  35124. }
  35125. }
  35126. declare module BABYLON {
  35127. /** @hidden */
  35128. export interface ICollisionCoordinator {
  35129. createCollider(): Collider;
  35130. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35131. init(scene: Scene): void;
  35132. }
  35133. /** @hidden */
  35134. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35135. private _scene;
  35136. private _scaledPosition;
  35137. private _scaledVelocity;
  35138. private _finalPosition;
  35139. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35140. createCollider(): Collider;
  35141. init(scene: Scene): void;
  35142. private _collideWithWorld;
  35143. }
  35144. }
  35145. declare module BABYLON {
  35146. /**
  35147. * Class used to manage all inputs for the scene.
  35148. */
  35149. export class InputManager {
  35150. /** The distance in pixel that you have to move to prevent some events */
  35151. static DragMovementThreshold: number;
  35152. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35153. static LongPressDelay: number;
  35154. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35155. static DoubleClickDelay: number;
  35156. /** If you need to check double click without raising a single click at first click, enable this flag */
  35157. static ExclusiveDoubleClickMode: boolean;
  35158. private _wheelEventName;
  35159. private _onPointerMove;
  35160. private _onPointerDown;
  35161. private _onPointerUp;
  35162. private _initClickEvent;
  35163. private _initActionManager;
  35164. private _delayedSimpleClick;
  35165. private _delayedSimpleClickTimeout;
  35166. private _previousDelayedSimpleClickTimeout;
  35167. private _meshPickProceed;
  35168. private _previousButtonPressed;
  35169. private _currentPickResult;
  35170. private _previousPickResult;
  35171. private _totalPointersPressed;
  35172. private _doubleClickOccured;
  35173. private _pointerOverMesh;
  35174. private _pickedDownMesh;
  35175. private _pickedUpMesh;
  35176. private _pointerX;
  35177. private _pointerY;
  35178. private _unTranslatedPointerX;
  35179. private _unTranslatedPointerY;
  35180. private _startingPointerPosition;
  35181. private _previousStartingPointerPosition;
  35182. private _startingPointerTime;
  35183. private _previousStartingPointerTime;
  35184. private _pointerCaptures;
  35185. private _onKeyDown;
  35186. private _onKeyUp;
  35187. private _onCanvasFocusObserver;
  35188. private _onCanvasBlurObserver;
  35189. private _scene;
  35190. /**
  35191. * Creates a new InputManager
  35192. * @param scene defines the hosting scene
  35193. */
  35194. constructor(scene: Scene);
  35195. /**
  35196. * Gets the mesh that is currently under the pointer
  35197. */
  35198. get meshUnderPointer(): Nullable<AbstractMesh>;
  35199. /**
  35200. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35201. */
  35202. get unTranslatedPointer(): Vector2;
  35203. /**
  35204. * Gets or sets the current on-screen X position of the pointer
  35205. */
  35206. get pointerX(): number;
  35207. set pointerX(value: number);
  35208. /**
  35209. * Gets or sets the current on-screen Y position of the pointer
  35210. */
  35211. get pointerY(): number;
  35212. set pointerY(value: number);
  35213. private _updatePointerPosition;
  35214. private _processPointerMove;
  35215. private _setRayOnPointerInfo;
  35216. private _checkPrePointerObservable;
  35217. /**
  35218. * Use this method to simulate a pointer move on a mesh
  35219. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35220. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35221. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35222. */
  35223. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35224. /**
  35225. * Use this method to simulate a pointer down on a mesh
  35226. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35227. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35228. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35229. */
  35230. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35231. private _processPointerDown;
  35232. /** @hidden */
  35233. _isPointerSwiping(): boolean;
  35234. /**
  35235. * Use this method to simulate a pointer up on a mesh
  35236. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35237. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35238. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35239. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35240. */
  35241. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35242. private _processPointerUp;
  35243. /**
  35244. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35245. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35246. * @returns true if the pointer was captured
  35247. */
  35248. isPointerCaptured(pointerId?: number): boolean;
  35249. /**
  35250. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35251. * @param attachUp defines if you want to attach events to pointerup
  35252. * @param attachDown defines if you want to attach events to pointerdown
  35253. * @param attachMove defines if you want to attach events to pointermove
  35254. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35255. */
  35256. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35257. /**
  35258. * Detaches all event handlers
  35259. */
  35260. detachControl(): void;
  35261. /**
  35262. * Force the value of meshUnderPointer
  35263. * @param mesh defines the mesh to use
  35264. */
  35265. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35266. /**
  35267. * Gets the mesh under the pointer
  35268. * @returns a Mesh or null if no mesh is under the pointer
  35269. */
  35270. getPointerOverMesh(): Nullable<AbstractMesh>;
  35271. }
  35272. }
  35273. declare module BABYLON {
  35274. /**
  35275. * Helper class used to generate session unique ID
  35276. */
  35277. export class UniqueIdGenerator {
  35278. private static _UniqueIdCounter;
  35279. /**
  35280. * Gets an unique (relatively to the current scene) Id
  35281. */
  35282. static get UniqueId(): number;
  35283. }
  35284. }
  35285. declare module BABYLON {
  35286. /**
  35287. * This class defines the direct association between an animation and a target
  35288. */
  35289. export class TargetedAnimation {
  35290. /**
  35291. * Animation to perform
  35292. */
  35293. animation: Animation;
  35294. /**
  35295. * Target to animate
  35296. */
  35297. target: any;
  35298. /**
  35299. * Serialize the object
  35300. * @returns the JSON object representing the current entity
  35301. */
  35302. serialize(): any;
  35303. }
  35304. /**
  35305. * Use this class to create coordinated animations on multiple targets
  35306. */
  35307. export class AnimationGroup implements IDisposable {
  35308. /** The name of the animation group */
  35309. name: string;
  35310. private _scene;
  35311. private _targetedAnimations;
  35312. private _animatables;
  35313. private _from;
  35314. private _to;
  35315. private _isStarted;
  35316. private _isPaused;
  35317. private _speedRatio;
  35318. private _loopAnimation;
  35319. private _isAdditive;
  35320. /**
  35321. * Gets or sets the unique id of the node
  35322. */
  35323. uniqueId: number;
  35324. /**
  35325. * This observable will notify when one animation have ended
  35326. */
  35327. onAnimationEndObservable: Observable<TargetedAnimation>;
  35328. /**
  35329. * Observer raised when one animation loops
  35330. */
  35331. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35332. /**
  35333. * Observer raised when all animations have looped
  35334. */
  35335. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35336. /**
  35337. * This observable will notify when all animations have ended.
  35338. */
  35339. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35340. /**
  35341. * This observable will notify when all animations have paused.
  35342. */
  35343. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35344. /**
  35345. * This observable will notify when all animations are playing.
  35346. */
  35347. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35348. /**
  35349. * Gets the first frame
  35350. */
  35351. get from(): number;
  35352. /**
  35353. * Gets the last frame
  35354. */
  35355. get to(): number;
  35356. /**
  35357. * Define if the animations are started
  35358. */
  35359. get isStarted(): boolean;
  35360. /**
  35361. * Gets a value indicating that the current group is playing
  35362. */
  35363. get isPlaying(): boolean;
  35364. /**
  35365. * Gets or sets the speed ratio to use for all animations
  35366. */
  35367. get speedRatio(): number;
  35368. /**
  35369. * Gets or sets the speed ratio to use for all animations
  35370. */
  35371. set speedRatio(value: number);
  35372. /**
  35373. * Gets or sets if all animations should loop or not
  35374. */
  35375. get loopAnimation(): boolean;
  35376. set loopAnimation(value: boolean);
  35377. /**
  35378. * Gets or sets if all animations should be evaluated additively
  35379. */
  35380. get isAdditive(): boolean;
  35381. set isAdditive(value: boolean);
  35382. /**
  35383. * Gets the targeted animations for this animation group
  35384. */
  35385. get targetedAnimations(): Array<TargetedAnimation>;
  35386. /**
  35387. * returning the list of animatables controlled by this animation group.
  35388. */
  35389. get animatables(): Array<Animatable>;
  35390. /**
  35391. * Instantiates a new Animation Group.
  35392. * This helps managing several animations at once.
  35393. * @see http://doc.babylonjs.com/how_to/group
  35394. * @param name Defines the name of the group
  35395. * @param scene Defines the scene the group belongs to
  35396. */
  35397. constructor(
  35398. /** The name of the animation group */
  35399. name: string, scene?: Nullable<Scene>);
  35400. /**
  35401. * Add an animation (with its target) in the group
  35402. * @param animation defines the animation we want to add
  35403. * @param target defines the target of the animation
  35404. * @returns the TargetedAnimation object
  35405. */
  35406. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35407. /**
  35408. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35409. * It can add constant keys at begin or end
  35410. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35411. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35412. * @returns the animation group
  35413. */
  35414. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35415. private _animationLoopCount;
  35416. private _animationLoopFlags;
  35417. private _processLoop;
  35418. /**
  35419. * Start all animations on given targets
  35420. * @param loop defines if animations must loop
  35421. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35422. * @param from defines the from key (optional)
  35423. * @param to defines the to key (optional)
  35424. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35425. * @returns the current animation group
  35426. */
  35427. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35428. /**
  35429. * Pause all animations
  35430. * @returns the animation group
  35431. */
  35432. pause(): AnimationGroup;
  35433. /**
  35434. * Play all animations to initial state
  35435. * This function will start() the animations if they were not started or will restart() them if they were paused
  35436. * @param loop defines if animations must loop
  35437. * @returns the animation group
  35438. */
  35439. play(loop?: boolean): AnimationGroup;
  35440. /**
  35441. * Reset all animations to initial state
  35442. * @returns the animation group
  35443. */
  35444. reset(): AnimationGroup;
  35445. /**
  35446. * Restart animations from key 0
  35447. * @returns the animation group
  35448. */
  35449. restart(): AnimationGroup;
  35450. /**
  35451. * Stop all animations
  35452. * @returns the animation group
  35453. */
  35454. stop(): AnimationGroup;
  35455. /**
  35456. * Set animation weight for all animatables
  35457. * @param weight defines the weight to use
  35458. * @return the animationGroup
  35459. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35460. */
  35461. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35462. /**
  35463. * Synchronize and normalize all animatables with a source animatable
  35464. * @param root defines the root animatable to synchronize with
  35465. * @return the animationGroup
  35466. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35467. */
  35468. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35469. /**
  35470. * Goes to a specific frame in this animation group
  35471. * @param frame the frame number to go to
  35472. * @return the animationGroup
  35473. */
  35474. goToFrame(frame: number): AnimationGroup;
  35475. /**
  35476. * Dispose all associated resources
  35477. */
  35478. dispose(): void;
  35479. private _checkAnimationGroupEnded;
  35480. /**
  35481. * Clone the current animation group and returns a copy
  35482. * @param newName defines the name of the new group
  35483. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35484. * @returns the new aniamtion group
  35485. */
  35486. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35487. /**
  35488. * Serializes the animationGroup to an object
  35489. * @returns Serialized object
  35490. */
  35491. serialize(): any;
  35492. /**
  35493. * Returns a new AnimationGroup object parsed from the source provided.
  35494. * @param parsedAnimationGroup defines the source
  35495. * @param scene defines the scene that will receive the animationGroup
  35496. * @returns a new AnimationGroup
  35497. */
  35498. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35499. /**
  35500. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35501. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35502. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35503. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35504. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35505. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35506. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35507. */
  35508. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35509. /**
  35510. * Returns the string "AnimationGroup"
  35511. * @returns "AnimationGroup"
  35512. */
  35513. getClassName(): string;
  35514. /**
  35515. * Creates a detailled string about the object
  35516. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35517. * @returns a string representing the object
  35518. */
  35519. toString(fullDetails?: boolean): string;
  35520. }
  35521. }
  35522. declare module BABYLON {
  35523. /**
  35524. * Define an interface for all classes that will hold resources
  35525. */
  35526. export interface IDisposable {
  35527. /**
  35528. * Releases all held resources
  35529. */
  35530. dispose(): void;
  35531. }
  35532. /** Interface defining initialization parameters for Scene class */
  35533. export interface SceneOptions {
  35534. /**
  35535. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35536. * It will improve performance when the number of geometries becomes important.
  35537. */
  35538. useGeometryUniqueIdsMap?: boolean;
  35539. /**
  35540. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35541. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35542. */
  35543. useMaterialMeshMap?: boolean;
  35544. /**
  35545. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35546. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35547. */
  35548. useClonedMeshMap?: boolean;
  35549. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35550. virtual?: boolean;
  35551. }
  35552. /**
  35553. * Represents a scene to be rendered by the engine.
  35554. * @see http://doc.babylonjs.com/features/scene
  35555. */
  35556. export class Scene extends AbstractScene implements IAnimatable {
  35557. /** The fog is deactivated */
  35558. static readonly FOGMODE_NONE: number;
  35559. /** The fog density is following an exponential function */
  35560. static readonly FOGMODE_EXP: number;
  35561. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35562. static readonly FOGMODE_EXP2: number;
  35563. /** The fog density is following a linear function. */
  35564. static readonly FOGMODE_LINEAR: number;
  35565. /**
  35566. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35567. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35568. */
  35569. static MinDeltaTime: number;
  35570. /**
  35571. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35572. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35573. */
  35574. static MaxDeltaTime: number;
  35575. /**
  35576. * Factory used to create the default material.
  35577. * @param name The name of the material to create
  35578. * @param scene The scene to create the material for
  35579. * @returns The default material
  35580. */
  35581. static DefaultMaterialFactory(scene: Scene): Material;
  35582. /**
  35583. * Factory used to create the a collision coordinator.
  35584. * @returns The collision coordinator
  35585. */
  35586. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35587. /** @hidden */
  35588. _inputManager: InputManager;
  35589. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35590. cameraToUseForPointers: Nullable<Camera>;
  35591. /** @hidden */
  35592. readonly _isScene: boolean;
  35593. /** @hidden */
  35594. _blockEntityCollection: boolean;
  35595. /**
  35596. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35597. */
  35598. autoClear: boolean;
  35599. /**
  35600. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35601. */
  35602. autoClearDepthAndStencil: boolean;
  35603. /**
  35604. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35605. */
  35606. clearColor: Color4;
  35607. /**
  35608. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35609. */
  35610. ambientColor: Color3;
  35611. /**
  35612. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35613. * It should only be one of the following (if not the default embedded one):
  35614. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35615. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35616. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35617. * The material properties need to be setup according to the type of texture in use.
  35618. */
  35619. environmentBRDFTexture: BaseTexture;
  35620. /** @hidden */
  35621. protected _environmentTexture: Nullable<BaseTexture>;
  35622. /**
  35623. * Texture used in all pbr material as the reflection texture.
  35624. * As in the majority of the scene they are the same (exception for multi room and so on),
  35625. * this is easier to reference from here than from all the materials.
  35626. */
  35627. get environmentTexture(): Nullable<BaseTexture>;
  35628. /**
  35629. * Texture used in all pbr material as the reflection texture.
  35630. * As in the majority of the scene they are the same (exception for multi room and so on),
  35631. * this is easier to set here than in all the materials.
  35632. */
  35633. set environmentTexture(value: Nullable<BaseTexture>);
  35634. /** @hidden */
  35635. protected _environmentIntensity: number;
  35636. /**
  35637. * Intensity of the environment in all pbr material.
  35638. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35639. * As in the majority of the scene they are the same (exception for multi room and so on),
  35640. * this is easier to reference from here than from all the materials.
  35641. */
  35642. get environmentIntensity(): number;
  35643. /**
  35644. * Intensity of the environment in all pbr material.
  35645. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35646. * As in the majority of the scene they are the same (exception for multi room and so on),
  35647. * this is easier to set here than in all the materials.
  35648. */
  35649. set environmentIntensity(value: number);
  35650. /** @hidden */
  35651. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35652. /**
  35653. * Default image processing configuration used either in the rendering
  35654. * Forward main pass or through the imageProcessingPostProcess if present.
  35655. * As in the majority of the scene they are the same (exception for multi camera),
  35656. * this is easier to reference from here than from all the materials and post process.
  35657. *
  35658. * No setter as we it is a shared configuration, you can set the values instead.
  35659. */
  35660. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35661. private _forceWireframe;
  35662. /**
  35663. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35664. */
  35665. set forceWireframe(value: boolean);
  35666. get forceWireframe(): boolean;
  35667. private _skipFrustumClipping;
  35668. /**
  35669. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35670. */
  35671. set skipFrustumClipping(value: boolean);
  35672. get skipFrustumClipping(): boolean;
  35673. private _forcePointsCloud;
  35674. /**
  35675. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35676. */
  35677. set forcePointsCloud(value: boolean);
  35678. get forcePointsCloud(): boolean;
  35679. /**
  35680. * Gets or sets the active clipplane 1
  35681. */
  35682. clipPlane: Nullable<Plane>;
  35683. /**
  35684. * Gets or sets the active clipplane 2
  35685. */
  35686. clipPlane2: Nullable<Plane>;
  35687. /**
  35688. * Gets or sets the active clipplane 3
  35689. */
  35690. clipPlane3: Nullable<Plane>;
  35691. /**
  35692. * Gets or sets the active clipplane 4
  35693. */
  35694. clipPlane4: Nullable<Plane>;
  35695. /**
  35696. * Gets or sets the active clipplane 5
  35697. */
  35698. clipPlane5: Nullable<Plane>;
  35699. /**
  35700. * Gets or sets the active clipplane 6
  35701. */
  35702. clipPlane6: Nullable<Plane>;
  35703. /**
  35704. * Gets or sets a boolean indicating if animations are enabled
  35705. */
  35706. animationsEnabled: boolean;
  35707. private _animationPropertiesOverride;
  35708. /**
  35709. * Gets or sets the animation properties override
  35710. */
  35711. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35712. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35713. /**
  35714. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35715. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35716. */
  35717. useConstantAnimationDeltaTime: boolean;
  35718. /**
  35719. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35720. * Please note that it requires to run a ray cast through the scene on every frame
  35721. */
  35722. constantlyUpdateMeshUnderPointer: boolean;
  35723. /**
  35724. * Defines the HTML cursor to use when hovering over interactive elements
  35725. */
  35726. hoverCursor: string;
  35727. /**
  35728. * Defines the HTML default cursor to use (empty by default)
  35729. */
  35730. defaultCursor: string;
  35731. /**
  35732. * Defines whether cursors are handled by the scene.
  35733. */
  35734. doNotHandleCursors: boolean;
  35735. /**
  35736. * This is used to call preventDefault() on pointer down
  35737. * in order to block unwanted artifacts like system double clicks
  35738. */
  35739. preventDefaultOnPointerDown: boolean;
  35740. /**
  35741. * This is used to call preventDefault() on pointer up
  35742. * in order to block unwanted artifacts like system double clicks
  35743. */
  35744. preventDefaultOnPointerUp: boolean;
  35745. /**
  35746. * Gets or sets user defined metadata
  35747. */
  35748. metadata: any;
  35749. /**
  35750. * For internal use only. Please do not use.
  35751. */
  35752. reservedDataStore: any;
  35753. /**
  35754. * Gets the name of the plugin used to load this scene (null by default)
  35755. */
  35756. loadingPluginName: string;
  35757. /**
  35758. * Use this array to add regular expressions used to disable offline support for specific urls
  35759. */
  35760. disableOfflineSupportExceptionRules: RegExp[];
  35761. /**
  35762. * An event triggered when the scene is disposed.
  35763. */
  35764. onDisposeObservable: Observable<Scene>;
  35765. private _onDisposeObserver;
  35766. /** Sets a function to be executed when this scene is disposed. */
  35767. set onDispose(callback: () => void);
  35768. /**
  35769. * An event triggered before rendering the scene (right after animations and physics)
  35770. */
  35771. onBeforeRenderObservable: Observable<Scene>;
  35772. private _onBeforeRenderObserver;
  35773. /** Sets a function to be executed before rendering this scene */
  35774. set beforeRender(callback: Nullable<() => void>);
  35775. /**
  35776. * An event triggered after rendering the scene
  35777. */
  35778. onAfterRenderObservable: Observable<Scene>;
  35779. /**
  35780. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35781. */
  35782. onAfterRenderCameraObservable: Observable<Camera>;
  35783. private _onAfterRenderObserver;
  35784. /** Sets a function to be executed after rendering this scene */
  35785. set afterRender(callback: Nullable<() => void>);
  35786. /**
  35787. * An event triggered before animating the scene
  35788. */
  35789. onBeforeAnimationsObservable: Observable<Scene>;
  35790. /**
  35791. * An event triggered after animations processing
  35792. */
  35793. onAfterAnimationsObservable: Observable<Scene>;
  35794. /**
  35795. * An event triggered before draw calls are ready to be sent
  35796. */
  35797. onBeforeDrawPhaseObservable: Observable<Scene>;
  35798. /**
  35799. * An event triggered after draw calls have been sent
  35800. */
  35801. onAfterDrawPhaseObservable: Observable<Scene>;
  35802. /**
  35803. * An event triggered when the scene is ready
  35804. */
  35805. onReadyObservable: Observable<Scene>;
  35806. /**
  35807. * An event triggered before rendering a camera
  35808. */
  35809. onBeforeCameraRenderObservable: Observable<Camera>;
  35810. private _onBeforeCameraRenderObserver;
  35811. /** Sets a function to be executed before rendering a camera*/
  35812. set beforeCameraRender(callback: () => void);
  35813. /**
  35814. * An event triggered after rendering a camera
  35815. */
  35816. onAfterCameraRenderObservable: Observable<Camera>;
  35817. private _onAfterCameraRenderObserver;
  35818. /** Sets a function to be executed after rendering a camera*/
  35819. set afterCameraRender(callback: () => void);
  35820. /**
  35821. * An event triggered when active meshes evaluation is about to start
  35822. */
  35823. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35824. /**
  35825. * An event triggered when active meshes evaluation is done
  35826. */
  35827. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35828. /**
  35829. * An event triggered when particles rendering is about to start
  35830. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35831. */
  35832. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35833. /**
  35834. * An event triggered when particles rendering is done
  35835. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35836. */
  35837. onAfterParticlesRenderingObservable: Observable<Scene>;
  35838. /**
  35839. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35840. */
  35841. onDataLoadedObservable: Observable<Scene>;
  35842. /**
  35843. * An event triggered when a camera is created
  35844. */
  35845. onNewCameraAddedObservable: Observable<Camera>;
  35846. /**
  35847. * An event triggered when a camera is removed
  35848. */
  35849. onCameraRemovedObservable: Observable<Camera>;
  35850. /**
  35851. * An event triggered when a light is created
  35852. */
  35853. onNewLightAddedObservable: Observable<Light>;
  35854. /**
  35855. * An event triggered when a light is removed
  35856. */
  35857. onLightRemovedObservable: Observable<Light>;
  35858. /**
  35859. * An event triggered when a geometry is created
  35860. */
  35861. onNewGeometryAddedObservable: Observable<Geometry>;
  35862. /**
  35863. * An event triggered when a geometry is removed
  35864. */
  35865. onGeometryRemovedObservable: Observable<Geometry>;
  35866. /**
  35867. * An event triggered when a transform node is created
  35868. */
  35869. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35870. /**
  35871. * An event triggered when a transform node is removed
  35872. */
  35873. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35874. /**
  35875. * An event triggered when a mesh is created
  35876. */
  35877. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35878. /**
  35879. * An event triggered when a mesh is removed
  35880. */
  35881. onMeshRemovedObservable: Observable<AbstractMesh>;
  35882. /**
  35883. * An event triggered when a skeleton is created
  35884. */
  35885. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35886. /**
  35887. * An event triggered when a skeleton is removed
  35888. */
  35889. onSkeletonRemovedObservable: Observable<Skeleton>;
  35890. /**
  35891. * An event triggered when a material is created
  35892. */
  35893. onNewMaterialAddedObservable: Observable<Material>;
  35894. /**
  35895. * An event triggered when a material is removed
  35896. */
  35897. onMaterialRemovedObservable: Observable<Material>;
  35898. /**
  35899. * An event triggered when a texture is created
  35900. */
  35901. onNewTextureAddedObservable: Observable<BaseTexture>;
  35902. /**
  35903. * An event triggered when a texture is removed
  35904. */
  35905. onTextureRemovedObservable: Observable<BaseTexture>;
  35906. /**
  35907. * An event triggered when render targets are about to be rendered
  35908. * Can happen multiple times per frame.
  35909. */
  35910. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35911. /**
  35912. * An event triggered when render targets were rendered.
  35913. * Can happen multiple times per frame.
  35914. */
  35915. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35916. /**
  35917. * An event triggered before calculating deterministic simulation step
  35918. */
  35919. onBeforeStepObservable: Observable<Scene>;
  35920. /**
  35921. * An event triggered after calculating deterministic simulation step
  35922. */
  35923. onAfterStepObservable: Observable<Scene>;
  35924. /**
  35925. * An event triggered when the activeCamera property is updated
  35926. */
  35927. onActiveCameraChanged: Observable<Scene>;
  35928. /**
  35929. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35930. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35931. * 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)
  35932. */
  35933. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35934. /**
  35935. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35936. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35937. * 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)
  35938. */
  35939. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35940. /**
  35941. * This Observable will when a mesh has been imported into the scene.
  35942. */
  35943. onMeshImportedObservable: Observable<AbstractMesh>;
  35944. /**
  35945. * This Observable will when an animation file has been imported into the scene.
  35946. */
  35947. onAnimationFileImportedObservable: Observable<Scene>;
  35948. /**
  35949. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35950. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35951. */
  35952. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35953. /** @hidden */
  35954. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35955. /**
  35956. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35957. */
  35958. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35959. /**
  35960. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35961. */
  35962. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35963. /**
  35964. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35965. */
  35966. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35967. /** Callback called when a pointer move is detected */
  35968. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35969. /** Callback called when a pointer down is detected */
  35970. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35971. /** Callback called when a pointer up is detected */
  35972. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35973. /** Callback called when a pointer pick is detected */
  35974. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35975. /**
  35976. * 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).
  35977. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35978. */
  35979. onPrePointerObservable: Observable<PointerInfoPre>;
  35980. /**
  35981. * Observable event triggered each time an input event is received from the rendering canvas
  35982. */
  35983. onPointerObservable: Observable<PointerInfo>;
  35984. /**
  35985. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35986. */
  35987. get unTranslatedPointer(): Vector2;
  35988. /**
  35989. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35990. */
  35991. static get DragMovementThreshold(): number;
  35992. static set DragMovementThreshold(value: number);
  35993. /**
  35994. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35995. */
  35996. static get LongPressDelay(): number;
  35997. static set LongPressDelay(value: number);
  35998. /**
  35999. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36000. */
  36001. static get DoubleClickDelay(): number;
  36002. static set DoubleClickDelay(value: number);
  36003. /** If you need to check double click without raising a single click at first click, enable this flag */
  36004. static get ExclusiveDoubleClickMode(): boolean;
  36005. static set ExclusiveDoubleClickMode(value: boolean);
  36006. /** @hidden */
  36007. _mirroredCameraPosition: Nullable<Vector3>;
  36008. /**
  36009. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36010. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36011. */
  36012. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36013. /**
  36014. * Observable event triggered each time an keyboard event is received from the hosting window
  36015. */
  36016. onKeyboardObservable: Observable<KeyboardInfo>;
  36017. private _useRightHandedSystem;
  36018. /**
  36019. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36020. */
  36021. set useRightHandedSystem(value: boolean);
  36022. get useRightHandedSystem(): boolean;
  36023. private _timeAccumulator;
  36024. private _currentStepId;
  36025. private _currentInternalStep;
  36026. /**
  36027. * Sets the step Id used by deterministic lock step
  36028. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36029. * @param newStepId defines the step Id
  36030. */
  36031. setStepId(newStepId: number): void;
  36032. /**
  36033. * Gets the step Id used by deterministic lock step
  36034. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36035. * @returns the step Id
  36036. */
  36037. getStepId(): number;
  36038. /**
  36039. * Gets the internal step used by deterministic lock step
  36040. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36041. * @returns the internal step
  36042. */
  36043. getInternalStep(): number;
  36044. private _fogEnabled;
  36045. /**
  36046. * Gets or sets a boolean indicating if fog is enabled on this scene
  36047. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36048. * (Default is true)
  36049. */
  36050. set fogEnabled(value: boolean);
  36051. get fogEnabled(): boolean;
  36052. private _fogMode;
  36053. /**
  36054. * Gets or sets the fog mode to use
  36055. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36056. * | mode | value |
  36057. * | --- | --- |
  36058. * | FOGMODE_NONE | 0 |
  36059. * | FOGMODE_EXP | 1 |
  36060. * | FOGMODE_EXP2 | 2 |
  36061. * | FOGMODE_LINEAR | 3 |
  36062. */
  36063. set fogMode(value: number);
  36064. get fogMode(): number;
  36065. /**
  36066. * Gets or sets the fog color to use
  36067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36068. * (Default is Color3(0.2, 0.2, 0.3))
  36069. */
  36070. fogColor: Color3;
  36071. /**
  36072. * Gets or sets the fog density to use
  36073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36074. * (Default is 0.1)
  36075. */
  36076. fogDensity: number;
  36077. /**
  36078. * Gets or sets the fog start distance to use
  36079. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36080. * (Default is 0)
  36081. */
  36082. fogStart: number;
  36083. /**
  36084. * Gets or sets the fog end distance to use
  36085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36086. * (Default is 1000)
  36087. */
  36088. fogEnd: number;
  36089. private _shadowsEnabled;
  36090. /**
  36091. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36092. */
  36093. set shadowsEnabled(value: boolean);
  36094. get shadowsEnabled(): boolean;
  36095. private _lightsEnabled;
  36096. /**
  36097. * Gets or sets a boolean indicating if lights are enabled on this scene
  36098. */
  36099. set lightsEnabled(value: boolean);
  36100. get lightsEnabled(): boolean;
  36101. /** All of the active cameras added to this scene. */
  36102. activeCameras: Camera[];
  36103. /** @hidden */
  36104. _activeCamera: Nullable<Camera>;
  36105. /** Gets or sets the current active camera */
  36106. get activeCamera(): Nullable<Camera>;
  36107. set activeCamera(value: Nullable<Camera>);
  36108. private _defaultMaterial;
  36109. /** The default material used on meshes when no material is affected */
  36110. get defaultMaterial(): Material;
  36111. /** The default material used on meshes when no material is affected */
  36112. set defaultMaterial(value: Material);
  36113. private _texturesEnabled;
  36114. /**
  36115. * Gets or sets a boolean indicating if textures are enabled on this scene
  36116. */
  36117. set texturesEnabled(value: boolean);
  36118. get texturesEnabled(): boolean;
  36119. /**
  36120. * Gets or sets a boolean indicating if particles are enabled on this scene
  36121. */
  36122. particlesEnabled: boolean;
  36123. /**
  36124. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36125. */
  36126. spritesEnabled: boolean;
  36127. private _skeletonsEnabled;
  36128. /**
  36129. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36130. */
  36131. set skeletonsEnabled(value: boolean);
  36132. get skeletonsEnabled(): boolean;
  36133. /**
  36134. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36135. */
  36136. lensFlaresEnabled: boolean;
  36137. /**
  36138. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36140. */
  36141. collisionsEnabled: boolean;
  36142. private _collisionCoordinator;
  36143. /** @hidden */
  36144. get collisionCoordinator(): ICollisionCoordinator;
  36145. /**
  36146. * Defines the gravity applied to this scene (used only for collisions)
  36147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36148. */
  36149. gravity: Vector3;
  36150. /**
  36151. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36152. */
  36153. postProcessesEnabled: boolean;
  36154. /**
  36155. * The list of postprocesses added to the scene
  36156. */
  36157. postProcesses: PostProcess[];
  36158. /**
  36159. * Gets the current postprocess manager
  36160. */
  36161. postProcessManager: PostProcessManager;
  36162. /**
  36163. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36164. */
  36165. renderTargetsEnabled: boolean;
  36166. /**
  36167. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36168. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36169. */
  36170. dumpNextRenderTargets: boolean;
  36171. /**
  36172. * The list of user defined render targets added to the scene
  36173. */
  36174. customRenderTargets: RenderTargetTexture[];
  36175. /**
  36176. * Defines if texture loading must be delayed
  36177. * If true, textures will only be loaded when they need to be rendered
  36178. */
  36179. useDelayedTextureLoading: boolean;
  36180. /**
  36181. * Gets the list of meshes imported to the scene through SceneLoader
  36182. */
  36183. importedMeshesFiles: String[];
  36184. /**
  36185. * Gets or sets a boolean indicating if probes are enabled on this scene
  36186. */
  36187. probesEnabled: boolean;
  36188. /**
  36189. * Gets or sets the current offline provider to use to store scene data
  36190. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36191. */
  36192. offlineProvider: IOfflineProvider;
  36193. /**
  36194. * Gets or sets the action manager associated with the scene
  36195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36196. */
  36197. actionManager: AbstractActionManager;
  36198. private _meshesForIntersections;
  36199. /**
  36200. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36201. */
  36202. proceduralTexturesEnabled: boolean;
  36203. private _engine;
  36204. private _totalVertices;
  36205. /** @hidden */
  36206. _activeIndices: PerfCounter;
  36207. /** @hidden */
  36208. _activeParticles: PerfCounter;
  36209. /** @hidden */
  36210. _activeBones: PerfCounter;
  36211. private _animationRatio;
  36212. /** @hidden */
  36213. _animationTimeLast: number;
  36214. /** @hidden */
  36215. _animationTime: number;
  36216. /**
  36217. * Gets or sets a general scale for animation speed
  36218. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36219. */
  36220. animationTimeScale: number;
  36221. /** @hidden */
  36222. _cachedMaterial: Nullable<Material>;
  36223. /** @hidden */
  36224. _cachedEffect: Nullable<Effect>;
  36225. /** @hidden */
  36226. _cachedVisibility: Nullable<number>;
  36227. private _renderId;
  36228. private _frameId;
  36229. private _executeWhenReadyTimeoutId;
  36230. private _intermediateRendering;
  36231. private _viewUpdateFlag;
  36232. private _projectionUpdateFlag;
  36233. /** @hidden */
  36234. _toBeDisposed: Nullable<IDisposable>[];
  36235. private _activeRequests;
  36236. /** @hidden */
  36237. _pendingData: any[];
  36238. private _isDisposed;
  36239. /**
  36240. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36241. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36242. */
  36243. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36244. private _activeMeshes;
  36245. private _processedMaterials;
  36246. private _renderTargets;
  36247. /** @hidden */
  36248. _activeParticleSystems: SmartArray<IParticleSystem>;
  36249. private _activeSkeletons;
  36250. private _softwareSkinnedMeshes;
  36251. private _renderingManager;
  36252. /** @hidden */
  36253. _activeAnimatables: Animatable[];
  36254. private _transformMatrix;
  36255. private _sceneUbo;
  36256. /** @hidden */
  36257. _viewMatrix: Matrix;
  36258. private _projectionMatrix;
  36259. /** @hidden */
  36260. _forcedViewPosition: Nullable<Vector3>;
  36261. /** @hidden */
  36262. _frustumPlanes: Plane[];
  36263. /**
  36264. * Gets the list of frustum planes (built from the active camera)
  36265. */
  36266. get frustumPlanes(): Plane[];
  36267. /**
  36268. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36269. * This is useful if there are more lights that the maximum simulteanous authorized
  36270. */
  36271. requireLightSorting: boolean;
  36272. /** @hidden */
  36273. readonly useMaterialMeshMap: boolean;
  36274. /** @hidden */
  36275. readonly useClonedMeshMap: boolean;
  36276. private _externalData;
  36277. private _uid;
  36278. /**
  36279. * @hidden
  36280. * Backing store of defined scene components.
  36281. */
  36282. _components: ISceneComponent[];
  36283. /**
  36284. * @hidden
  36285. * Backing store of defined scene components.
  36286. */
  36287. _serializableComponents: ISceneSerializableComponent[];
  36288. /**
  36289. * List of components to register on the next registration step.
  36290. */
  36291. private _transientComponents;
  36292. /**
  36293. * Registers the transient components if needed.
  36294. */
  36295. private _registerTransientComponents;
  36296. /**
  36297. * @hidden
  36298. * Add a component to the scene.
  36299. * Note that the ccomponent could be registered on th next frame if this is called after
  36300. * the register component stage.
  36301. * @param component Defines the component to add to the scene
  36302. */
  36303. _addComponent(component: ISceneComponent): void;
  36304. /**
  36305. * @hidden
  36306. * Gets a component from the scene.
  36307. * @param name defines the name of the component to retrieve
  36308. * @returns the component or null if not present
  36309. */
  36310. _getComponent(name: string): Nullable<ISceneComponent>;
  36311. /**
  36312. * @hidden
  36313. * Defines the actions happening before camera updates.
  36314. */
  36315. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36316. /**
  36317. * @hidden
  36318. * Defines the actions happening before clear the canvas.
  36319. */
  36320. _beforeClearStage: Stage<SimpleStageAction>;
  36321. /**
  36322. * @hidden
  36323. * Defines the actions when collecting render targets for the frame.
  36324. */
  36325. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36326. /**
  36327. * @hidden
  36328. * Defines the actions happening for one camera in the frame.
  36329. */
  36330. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36331. /**
  36332. * @hidden
  36333. * Defines the actions happening during the per mesh ready checks.
  36334. */
  36335. _isReadyForMeshStage: Stage<MeshStageAction>;
  36336. /**
  36337. * @hidden
  36338. * Defines the actions happening before evaluate active mesh checks.
  36339. */
  36340. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36341. /**
  36342. * @hidden
  36343. * Defines the actions happening during the evaluate sub mesh checks.
  36344. */
  36345. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36346. /**
  36347. * @hidden
  36348. * Defines the actions happening during the active mesh stage.
  36349. */
  36350. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36351. /**
  36352. * @hidden
  36353. * Defines the actions happening during the per camera render target step.
  36354. */
  36355. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36356. /**
  36357. * @hidden
  36358. * Defines the actions happening just before the active camera is drawing.
  36359. */
  36360. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36361. /**
  36362. * @hidden
  36363. * Defines the actions happening just before a render target is drawing.
  36364. */
  36365. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36366. /**
  36367. * @hidden
  36368. * Defines the actions happening just before a rendering group is drawing.
  36369. */
  36370. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36371. /**
  36372. * @hidden
  36373. * Defines the actions happening just before a mesh is drawing.
  36374. */
  36375. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36376. /**
  36377. * @hidden
  36378. * Defines the actions happening just after a mesh has been drawn.
  36379. */
  36380. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36381. /**
  36382. * @hidden
  36383. * Defines the actions happening just after a rendering group has been drawn.
  36384. */
  36385. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36386. /**
  36387. * @hidden
  36388. * Defines the actions happening just after the active camera has been drawn.
  36389. */
  36390. _afterCameraDrawStage: Stage<CameraStageAction>;
  36391. /**
  36392. * @hidden
  36393. * Defines the actions happening just after a render target has been drawn.
  36394. */
  36395. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36396. /**
  36397. * @hidden
  36398. * Defines the actions happening just after rendering all cameras and computing intersections.
  36399. */
  36400. _afterRenderStage: Stage<SimpleStageAction>;
  36401. /**
  36402. * @hidden
  36403. * Defines the actions happening when a pointer move event happens.
  36404. */
  36405. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36406. /**
  36407. * @hidden
  36408. * Defines the actions happening when a pointer down event happens.
  36409. */
  36410. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36411. /**
  36412. * @hidden
  36413. * Defines the actions happening when a pointer up event happens.
  36414. */
  36415. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36416. /**
  36417. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36418. */
  36419. private geometriesByUniqueId;
  36420. /**
  36421. * Creates a new Scene
  36422. * @param engine defines the engine to use to render this scene
  36423. * @param options defines the scene options
  36424. */
  36425. constructor(engine: Engine, options?: SceneOptions);
  36426. /**
  36427. * Gets a string idenfifying the name of the class
  36428. * @returns "Scene" string
  36429. */
  36430. getClassName(): string;
  36431. private _defaultMeshCandidates;
  36432. /**
  36433. * @hidden
  36434. */
  36435. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36436. private _defaultSubMeshCandidates;
  36437. /**
  36438. * @hidden
  36439. */
  36440. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36441. /**
  36442. * Sets the default candidate providers for the scene.
  36443. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36444. * and getCollidingSubMeshCandidates to their default function
  36445. */
  36446. setDefaultCandidateProviders(): void;
  36447. /**
  36448. * Gets the mesh that is currently under the pointer
  36449. */
  36450. get meshUnderPointer(): Nullable<AbstractMesh>;
  36451. /**
  36452. * Gets or sets the current on-screen X position of the pointer
  36453. */
  36454. get pointerX(): number;
  36455. set pointerX(value: number);
  36456. /**
  36457. * Gets or sets the current on-screen Y position of the pointer
  36458. */
  36459. get pointerY(): number;
  36460. set pointerY(value: number);
  36461. /**
  36462. * Gets the cached material (ie. the latest rendered one)
  36463. * @returns the cached material
  36464. */
  36465. getCachedMaterial(): Nullable<Material>;
  36466. /**
  36467. * Gets the cached effect (ie. the latest rendered one)
  36468. * @returns the cached effect
  36469. */
  36470. getCachedEffect(): Nullable<Effect>;
  36471. /**
  36472. * Gets the cached visibility state (ie. the latest rendered one)
  36473. * @returns the cached visibility state
  36474. */
  36475. getCachedVisibility(): Nullable<number>;
  36476. /**
  36477. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36478. * @param material defines the current material
  36479. * @param effect defines the current effect
  36480. * @param visibility defines the current visibility state
  36481. * @returns true if one parameter is not cached
  36482. */
  36483. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36484. /**
  36485. * Gets the engine associated with the scene
  36486. * @returns an Engine
  36487. */
  36488. getEngine(): Engine;
  36489. /**
  36490. * Gets the total number of vertices rendered per frame
  36491. * @returns the total number of vertices rendered per frame
  36492. */
  36493. getTotalVertices(): number;
  36494. /**
  36495. * Gets the performance counter for total vertices
  36496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36497. */
  36498. get totalVerticesPerfCounter(): PerfCounter;
  36499. /**
  36500. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36501. * @returns the total number of active indices rendered per frame
  36502. */
  36503. getActiveIndices(): number;
  36504. /**
  36505. * Gets the performance counter for active indices
  36506. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36507. */
  36508. get totalActiveIndicesPerfCounter(): PerfCounter;
  36509. /**
  36510. * Gets the total number of active particles rendered per frame
  36511. * @returns the total number of active particles rendered per frame
  36512. */
  36513. getActiveParticles(): number;
  36514. /**
  36515. * Gets the performance counter for active particles
  36516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36517. */
  36518. get activeParticlesPerfCounter(): PerfCounter;
  36519. /**
  36520. * Gets the total number of active bones rendered per frame
  36521. * @returns the total number of active bones rendered per frame
  36522. */
  36523. getActiveBones(): number;
  36524. /**
  36525. * Gets the performance counter for active bones
  36526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36527. */
  36528. get activeBonesPerfCounter(): PerfCounter;
  36529. /**
  36530. * Gets the array of active meshes
  36531. * @returns an array of AbstractMesh
  36532. */
  36533. getActiveMeshes(): SmartArray<AbstractMesh>;
  36534. /**
  36535. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36536. * @returns a number
  36537. */
  36538. getAnimationRatio(): number;
  36539. /**
  36540. * Gets an unique Id for the current render phase
  36541. * @returns a number
  36542. */
  36543. getRenderId(): number;
  36544. /**
  36545. * Gets an unique Id for the current frame
  36546. * @returns a number
  36547. */
  36548. getFrameId(): number;
  36549. /** Call this function if you want to manually increment the render Id*/
  36550. incrementRenderId(): void;
  36551. private _createUbo;
  36552. /**
  36553. * Use this method to simulate a pointer move on a mesh
  36554. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36555. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36556. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36557. * @returns the current scene
  36558. */
  36559. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36560. /**
  36561. * Use this method to simulate a pointer down on a mesh
  36562. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36563. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36564. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36565. * @returns the current scene
  36566. */
  36567. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36568. /**
  36569. * Use this method to simulate a pointer up on a mesh
  36570. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36571. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36572. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36573. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36574. * @returns the current scene
  36575. */
  36576. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36577. /**
  36578. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36579. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36580. * @returns true if the pointer was captured
  36581. */
  36582. isPointerCaptured(pointerId?: number): boolean;
  36583. /**
  36584. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36585. * @param attachUp defines if you want to attach events to pointerup
  36586. * @param attachDown defines if you want to attach events to pointerdown
  36587. * @param attachMove defines if you want to attach events to pointermove
  36588. */
  36589. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36590. /** Detaches all event handlers*/
  36591. detachControl(): void;
  36592. /**
  36593. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36594. * Delay loaded resources are not taking in account
  36595. * @return true if all required resources are ready
  36596. */
  36597. isReady(): boolean;
  36598. /** Resets all cached information relative to material (including effect and visibility) */
  36599. resetCachedMaterial(): void;
  36600. /**
  36601. * Registers a function to be called before every frame render
  36602. * @param func defines the function to register
  36603. */
  36604. registerBeforeRender(func: () => void): void;
  36605. /**
  36606. * Unregisters a function called before every frame render
  36607. * @param func defines the function to unregister
  36608. */
  36609. unregisterBeforeRender(func: () => void): void;
  36610. /**
  36611. * Registers a function to be called after every frame render
  36612. * @param func defines the function to register
  36613. */
  36614. registerAfterRender(func: () => void): void;
  36615. /**
  36616. * Unregisters a function called after every frame render
  36617. * @param func defines the function to unregister
  36618. */
  36619. unregisterAfterRender(func: () => void): void;
  36620. private _executeOnceBeforeRender;
  36621. /**
  36622. * The provided function will run before render once and will be disposed afterwards.
  36623. * A timeout delay can be provided so that the function will be executed in N ms.
  36624. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36625. * @param func The function to be executed.
  36626. * @param timeout optional delay in ms
  36627. */
  36628. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36629. /** @hidden */
  36630. _addPendingData(data: any): void;
  36631. /** @hidden */
  36632. _removePendingData(data: any): void;
  36633. /**
  36634. * Returns the number of items waiting to be loaded
  36635. * @returns the number of items waiting to be loaded
  36636. */
  36637. getWaitingItemsCount(): number;
  36638. /**
  36639. * Returns a boolean indicating if the scene is still loading data
  36640. */
  36641. get isLoading(): boolean;
  36642. /**
  36643. * Registers a function to be executed when the scene is ready
  36644. * @param {Function} func - the function to be executed
  36645. */
  36646. executeWhenReady(func: () => void): void;
  36647. /**
  36648. * Returns a promise that resolves when the scene is ready
  36649. * @returns A promise that resolves when the scene is ready
  36650. */
  36651. whenReadyAsync(): Promise<void>;
  36652. /** @hidden */
  36653. _checkIsReady(): void;
  36654. /**
  36655. * Gets all animatable attached to the scene
  36656. */
  36657. get animatables(): Animatable[];
  36658. /**
  36659. * Resets the last animation time frame.
  36660. * Useful to override when animations start running when loading a scene for the first time.
  36661. */
  36662. resetLastAnimationTimeFrame(): void;
  36663. /**
  36664. * Gets the current view matrix
  36665. * @returns a Matrix
  36666. */
  36667. getViewMatrix(): Matrix;
  36668. /**
  36669. * Gets the current projection matrix
  36670. * @returns a Matrix
  36671. */
  36672. getProjectionMatrix(): Matrix;
  36673. /**
  36674. * Gets the current transform matrix
  36675. * @returns a Matrix made of View * Projection
  36676. */
  36677. getTransformMatrix(): Matrix;
  36678. /**
  36679. * Sets the current transform matrix
  36680. * @param viewL defines the View matrix to use
  36681. * @param projectionL defines the Projection matrix to use
  36682. * @param viewR defines the right View matrix to use (if provided)
  36683. * @param projectionR defines the right Projection matrix to use (if provided)
  36684. */
  36685. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36686. /**
  36687. * Gets the uniform buffer used to store scene data
  36688. * @returns a UniformBuffer
  36689. */
  36690. getSceneUniformBuffer(): UniformBuffer;
  36691. /**
  36692. * Gets an unique (relatively to the current scene) Id
  36693. * @returns an unique number for the scene
  36694. */
  36695. getUniqueId(): number;
  36696. /**
  36697. * Add a mesh to the list of scene's meshes
  36698. * @param newMesh defines the mesh to add
  36699. * @param recursive if all child meshes should also be added to the scene
  36700. */
  36701. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36702. /**
  36703. * Remove a mesh for the list of scene's meshes
  36704. * @param toRemove defines the mesh to remove
  36705. * @param recursive if all child meshes should also be removed from the scene
  36706. * @returns the index where the mesh was in the mesh list
  36707. */
  36708. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36709. /**
  36710. * Add a transform node to the list of scene's transform nodes
  36711. * @param newTransformNode defines the transform node to add
  36712. */
  36713. addTransformNode(newTransformNode: TransformNode): void;
  36714. /**
  36715. * Remove a transform node for the list of scene's transform nodes
  36716. * @param toRemove defines the transform node to remove
  36717. * @returns the index where the transform node was in the transform node list
  36718. */
  36719. removeTransformNode(toRemove: TransformNode): number;
  36720. /**
  36721. * Remove a skeleton for the list of scene's skeletons
  36722. * @param toRemove defines the skeleton to remove
  36723. * @returns the index where the skeleton was in the skeleton list
  36724. */
  36725. removeSkeleton(toRemove: Skeleton): number;
  36726. /**
  36727. * Remove a morph target for the list of scene's morph targets
  36728. * @param toRemove defines the morph target to remove
  36729. * @returns the index where the morph target was in the morph target list
  36730. */
  36731. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36732. /**
  36733. * Remove a light for the list of scene's lights
  36734. * @param toRemove defines the light to remove
  36735. * @returns the index where the light was in the light list
  36736. */
  36737. removeLight(toRemove: Light): number;
  36738. /**
  36739. * Remove a camera for the list of scene's cameras
  36740. * @param toRemove defines the camera to remove
  36741. * @returns the index where the camera was in the camera list
  36742. */
  36743. removeCamera(toRemove: Camera): number;
  36744. /**
  36745. * Remove a particle system for the list of scene's particle systems
  36746. * @param toRemove defines the particle system to remove
  36747. * @returns the index where the particle system was in the particle system list
  36748. */
  36749. removeParticleSystem(toRemove: IParticleSystem): number;
  36750. /**
  36751. * Remove a animation for the list of scene's animations
  36752. * @param toRemove defines the animation to remove
  36753. * @returns the index where the animation was in the animation list
  36754. */
  36755. removeAnimation(toRemove: Animation): number;
  36756. /**
  36757. * Will stop the animation of the given target
  36758. * @param target - the target
  36759. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36760. * @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)
  36761. */
  36762. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36763. /**
  36764. * Removes the given animation group from this scene.
  36765. * @param toRemove The animation group to remove
  36766. * @returns The index of the removed animation group
  36767. */
  36768. removeAnimationGroup(toRemove: AnimationGroup): number;
  36769. /**
  36770. * Removes the given multi-material from this scene.
  36771. * @param toRemove The multi-material to remove
  36772. * @returns The index of the removed multi-material
  36773. */
  36774. removeMultiMaterial(toRemove: MultiMaterial): number;
  36775. /**
  36776. * Removes the given material from this scene.
  36777. * @param toRemove The material to remove
  36778. * @returns The index of the removed material
  36779. */
  36780. removeMaterial(toRemove: Material): number;
  36781. /**
  36782. * Removes the given action manager from this scene.
  36783. * @param toRemove The action manager to remove
  36784. * @returns The index of the removed action manager
  36785. */
  36786. removeActionManager(toRemove: AbstractActionManager): number;
  36787. /**
  36788. * Removes the given texture from this scene.
  36789. * @param toRemove The texture to remove
  36790. * @returns The index of the removed texture
  36791. */
  36792. removeTexture(toRemove: BaseTexture): number;
  36793. /**
  36794. * Adds the given light to this scene
  36795. * @param newLight The light to add
  36796. */
  36797. addLight(newLight: Light): void;
  36798. /**
  36799. * Sorts the list list based on light priorities
  36800. */
  36801. sortLightsByPriority(): void;
  36802. /**
  36803. * Adds the given camera to this scene
  36804. * @param newCamera The camera to add
  36805. */
  36806. addCamera(newCamera: Camera): void;
  36807. /**
  36808. * Adds the given skeleton to this scene
  36809. * @param newSkeleton The skeleton to add
  36810. */
  36811. addSkeleton(newSkeleton: Skeleton): void;
  36812. /**
  36813. * Adds the given particle system to this scene
  36814. * @param newParticleSystem The particle system to add
  36815. */
  36816. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36817. /**
  36818. * Adds the given animation to this scene
  36819. * @param newAnimation The animation to add
  36820. */
  36821. addAnimation(newAnimation: Animation): void;
  36822. /**
  36823. * Adds the given animation group to this scene.
  36824. * @param newAnimationGroup The animation group to add
  36825. */
  36826. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36827. /**
  36828. * Adds the given multi-material to this scene
  36829. * @param newMultiMaterial The multi-material to add
  36830. */
  36831. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36832. /**
  36833. * Adds the given material to this scene
  36834. * @param newMaterial The material to add
  36835. */
  36836. addMaterial(newMaterial: Material): void;
  36837. /**
  36838. * Adds the given morph target to this scene
  36839. * @param newMorphTargetManager The morph target to add
  36840. */
  36841. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36842. /**
  36843. * Adds the given geometry to this scene
  36844. * @param newGeometry The geometry to add
  36845. */
  36846. addGeometry(newGeometry: Geometry): void;
  36847. /**
  36848. * Adds the given action manager to this scene
  36849. * @param newActionManager The action manager to add
  36850. */
  36851. addActionManager(newActionManager: AbstractActionManager): void;
  36852. /**
  36853. * Adds the given texture to this scene.
  36854. * @param newTexture The texture to add
  36855. */
  36856. addTexture(newTexture: BaseTexture): void;
  36857. /**
  36858. * Switch active camera
  36859. * @param newCamera defines the new active camera
  36860. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36861. */
  36862. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36863. /**
  36864. * sets the active camera of the scene using its ID
  36865. * @param id defines the camera's ID
  36866. * @return the new active camera or null if none found.
  36867. */
  36868. setActiveCameraByID(id: string): Nullable<Camera>;
  36869. /**
  36870. * sets the active camera of the scene using its name
  36871. * @param name defines the camera's name
  36872. * @returns the new active camera or null if none found.
  36873. */
  36874. setActiveCameraByName(name: string): Nullable<Camera>;
  36875. /**
  36876. * get an animation group using its name
  36877. * @param name defines the material's name
  36878. * @return the animation group or null if none found.
  36879. */
  36880. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36881. /**
  36882. * Get a material using its unique id
  36883. * @param uniqueId defines the material's unique id
  36884. * @return the material or null if none found.
  36885. */
  36886. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36887. /**
  36888. * get a material using its id
  36889. * @param id defines the material's ID
  36890. * @return the material or null if none found.
  36891. */
  36892. getMaterialByID(id: string): Nullable<Material>;
  36893. /**
  36894. * Gets a the last added material using a given id
  36895. * @param id defines the material's ID
  36896. * @return the last material with the given id or null if none found.
  36897. */
  36898. getLastMaterialByID(id: string): Nullable<Material>;
  36899. /**
  36900. * Gets a material using its name
  36901. * @param name defines the material's name
  36902. * @return the material or null if none found.
  36903. */
  36904. getMaterialByName(name: string): Nullable<Material>;
  36905. /**
  36906. * Get a texture using its unique id
  36907. * @param uniqueId defines the texture's unique id
  36908. * @return the texture or null if none found.
  36909. */
  36910. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36911. /**
  36912. * Gets a camera using its id
  36913. * @param id defines the id to look for
  36914. * @returns the camera or null if not found
  36915. */
  36916. getCameraByID(id: string): Nullable<Camera>;
  36917. /**
  36918. * Gets a camera using its unique id
  36919. * @param uniqueId defines the unique id to look for
  36920. * @returns the camera or null if not found
  36921. */
  36922. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36923. /**
  36924. * Gets a camera using its name
  36925. * @param name defines the camera's name
  36926. * @return the camera or null if none found.
  36927. */
  36928. getCameraByName(name: string): Nullable<Camera>;
  36929. /**
  36930. * Gets a bone using its id
  36931. * @param id defines the bone's id
  36932. * @return the bone or null if not found
  36933. */
  36934. getBoneByID(id: string): Nullable<Bone>;
  36935. /**
  36936. * Gets a bone using its id
  36937. * @param name defines the bone's name
  36938. * @return the bone or null if not found
  36939. */
  36940. getBoneByName(name: string): Nullable<Bone>;
  36941. /**
  36942. * Gets a light node using its name
  36943. * @param name defines the the light's name
  36944. * @return the light or null if none found.
  36945. */
  36946. getLightByName(name: string): Nullable<Light>;
  36947. /**
  36948. * Gets a light node using its id
  36949. * @param id defines the light's id
  36950. * @return the light or null if none found.
  36951. */
  36952. getLightByID(id: string): Nullable<Light>;
  36953. /**
  36954. * Gets a light node using its scene-generated unique ID
  36955. * @param uniqueId defines the light's unique id
  36956. * @return the light or null if none found.
  36957. */
  36958. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36959. /**
  36960. * Gets a particle system by id
  36961. * @param id defines the particle system id
  36962. * @return the corresponding system or null if none found
  36963. */
  36964. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36965. /**
  36966. * Gets a geometry using its ID
  36967. * @param id defines the geometry's id
  36968. * @return the geometry or null if none found.
  36969. */
  36970. getGeometryByID(id: string): Nullable<Geometry>;
  36971. private _getGeometryByUniqueID;
  36972. /**
  36973. * Add a new geometry to this scene
  36974. * @param geometry defines the geometry to be added to the scene.
  36975. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36976. * @return a boolean defining if the geometry was added or not
  36977. */
  36978. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36979. /**
  36980. * Removes an existing geometry
  36981. * @param geometry defines the geometry to be removed from the scene
  36982. * @return a boolean defining if the geometry was removed or not
  36983. */
  36984. removeGeometry(geometry: Geometry): boolean;
  36985. /**
  36986. * Gets the list of geometries attached to the scene
  36987. * @returns an array of Geometry
  36988. */
  36989. getGeometries(): Geometry[];
  36990. /**
  36991. * Gets the first added mesh found of a given ID
  36992. * @param id defines the id to search for
  36993. * @return the mesh found or null if not found at all
  36994. */
  36995. getMeshByID(id: string): Nullable<AbstractMesh>;
  36996. /**
  36997. * Gets a list of meshes using their id
  36998. * @param id defines the id to search for
  36999. * @returns a list of meshes
  37000. */
  37001. getMeshesByID(id: string): Array<AbstractMesh>;
  37002. /**
  37003. * Gets the first added transform node found of a given ID
  37004. * @param id defines the id to search for
  37005. * @return the found transform node or null if not found at all.
  37006. */
  37007. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37008. /**
  37009. * Gets a transform node with its auto-generated unique id
  37010. * @param uniqueId efines the unique id to search for
  37011. * @return the found transform node or null if not found at all.
  37012. */
  37013. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37014. /**
  37015. * Gets a list of transform nodes using their id
  37016. * @param id defines the id to search for
  37017. * @returns a list of transform nodes
  37018. */
  37019. getTransformNodesByID(id: string): Array<TransformNode>;
  37020. /**
  37021. * Gets a mesh with its auto-generated unique id
  37022. * @param uniqueId defines the unique id to search for
  37023. * @return the found mesh or null if not found at all.
  37024. */
  37025. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37026. /**
  37027. * Gets a the last added mesh using a given id
  37028. * @param id defines the id to search for
  37029. * @return the found mesh or null if not found at all.
  37030. */
  37031. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37032. /**
  37033. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37034. * @param id defines the id to search for
  37035. * @return the found node or null if not found at all
  37036. */
  37037. getLastEntryByID(id: string): Nullable<Node>;
  37038. /**
  37039. * Gets a node (Mesh, Camera, Light) using a given id
  37040. * @param id defines the id to search for
  37041. * @return the found node or null if not found at all
  37042. */
  37043. getNodeByID(id: string): Nullable<Node>;
  37044. /**
  37045. * Gets a node (Mesh, Camera, Light) using a given name
  37046. * @param name defines the name to search for
  37047. * @return the found node or null if not found at all.
  37048. */
  37049. getNodeByName(name: string): Nullable<Node>;
  37050. /**
  37051. * Gets a mesh using a given name
  37052. * @param name defines the name to search for
  37053. * @return the found mesh or null if not found at all.
  37054. */
  37055. getMeshByName(name: string): Nullable<AbstractMesh>;
  37056. /**
  37057. * Gets a transform node using a given name
  37058. * @param name defines the name to search for
  37059. * @return the found transform node or null if not found at all.
  37060. */
  37061. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37062. /**
  37063. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37064. * @param id defines the id to search for
  37065. * @return the found skeleton or null if not found at all.
  37066. */
  37067. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37068. /**
  37069. * Gets a skeleton using a given auto generated unique id
  37070. * @param uniqueId defines the unique id to search for
  37071. * @return the found skeleton or null if not found at all.
  37072. */
  37073. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37074. /**
  37075. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37076. * @param id defines the id to search for
  37077. * @return the found skeleton or null if not found at all.
  37078. */
  37079. getSkeletonById(id: string): Nullable<Skeleton>;
  37080. /**
  37081. * Gets a skeleton using a given name
  37082. * @param name defines the name to search for
  37083. * @return the found skeleton or null if not found at all.
  37084. */
  37085. getSkeletonByName(name: string): Nullable<Skeleton>;
  37086. /**
  37087. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37088. * @param id defines the id to search for
  37089. * @return the found morph target manager or null if not found at all.
  37090. */
  37091. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37092. /**
  37093. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37094. * @param id defines the id to search for
  37095. * @return the found morph target or null if not found at all.
  37096. */
  37097. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37098. /**
  37099. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37100. * @param name defines the name to search for
  37101. * @return the found morph target or null if not found at all.
  37102. */
  37103. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37104. /**
  37105. * Gets a boolean indicating if the given mesh is active
  37106. * @param mesh defines the mesh to look for
  37107. * @returns true if the mesh is in the active list
  37108. */
  37109. isActiveMesh(mesh: AbstractMesh): boolean;
  37110. /**
  37111. * Return a unique id as a string which can serve as an identifier for the scene
  37112. */
  37113. get uid(): string;
  37114. /**
  37115. * Add an externaly attached data from its key.
  37116. * This method call will fail and return false, if such key already exists.
  37117. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37118. * @param key the unique key that identifies the data
  37119. * @param data the data object to associate to the key for this Engine instance
  37120. * @return true if no such key were already present and the data was added successfully, false otherwise
  37121. */
  37122. addExternalData<T>(key: string, data: T): boolean;
  37123. /**
  37124. * Get an externaly attached data from its key
  37125. * @param key the unique key that identifies the data
  37126. * @return the associated data, if present (can be null), or undefined if not present
  37127. */
  37128. getExternalData<T>(key: string): Nullable<T>;
  37129. /**
  37130. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37131. * @param key the unique key that identifies the data
  37132. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37133. * @return the associated data, can be null if the factory returned null.
  37134. */
  37135. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37136. /**
  37137. * Remove an externaly attached data from the Engine instance
  37138. * @param key the unique key that identifies the data
  37139. * @return true if the data was successfully removed, false if it doesn't exist
  37140. */
  37141. removeExternalData(key: string): boolean;
  37142. private _evaluateSubMesh;
  37143. /**
  37144. * Clear the processed materials smart array preventing retention point in material dispose.
  37145. */
  37146. freeProcessedMaterials(): void;
  37147. private _preventFreeActiveMeshesAndRenderingGroups;
  37148. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37149. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37150. * when disposing several meshes in a row or a hierarchy of meshes.
  37151. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37152. */
  37153. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37154. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37155. /**
  37156. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37157. */
  37158. freeActiveMeshes(): void;
  37159. /**
  37160. * Clear the info related to rendering groups preventing retention points during dispose.
  37161. */
  37162. freeRenderingGroups(): void;
  37163. /** @hidden */
  37164. _isInIntermediateRendering(): boolean;
  37165. /**
  37166. * Lambda returning the list of potentially active meshes.
  37167. */
  37168. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37169. /**
  37170. * Lambda returning the list of potentially active sub meshes.
  37171. */
  37172. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37173. /**
  37174. * Lambda returning the list of potentially intersecting sub meshes.
  37175. */
  37176. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37177. /**
  37178. * Lambda returning the list of potentially colliding sub meshes.
  37179. */
  37180. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37181. private _activeMeshesFrozen;
  37182. private _skipEvaluateActiveMeshesCompletely;
  37183. /**
  37184. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37185. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37186. * @returns the current scene
  37187. */
  37188. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37189. /**
  37190. * Use this function to restart evaluating active meshes on every frame
  37191. * @returns the current scene
  37192. */
  37193. unfreezeActiveMeshes(): Scene;
  37194. private _evaluateActiveMeshes;
  37195. private _activeMesh;
  37196. /**
  37197. * Update the transform matrix to update from the current active camera
  37198. * @param force defines a boolean used to force the update even if cache is up to date
  37199. */
  37200. updateTransformMatrix(force?: boolean): void;
  37201. private _bindFrameBuffer;
  37202. /** @hidden */
  37203. _allowPostProcessClearColor: boolean;
  37204. /** @hidden */
  37205. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37206. private _processSubCameras;
  37207. private _checkIntersections;
  37208. /** @hidden */
  37209. _advancePhysicsEngineStep(step: number): void;
  37210. /**
  37211. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37212. */
  37213. getDeterministicFrameTime: () => number;
  37214. /** @hidden */
  37215. _animate(): void;
  37216. /** Execute all animations (for a frame) */
  37217. animate(): void;
  37218. /**
  37219. * Render the scene
  37220. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37221. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37222. */
  37223. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37224. /**
  37225. * Freeze all materials
  37226. * A frozen material will not be updatable but should be faster to render
  37227. */
  37228. freezeMaterials(): void;
  37229. /**
  37230. * Unfreeze all materials
  37231. * A frozen material will not be updatable but should be faster to render
  37232. */
  37233. unfreezeMaterials(): void;
  37234. /**
  37235. * Releases all held ressources
  37236. */
  37237. dispose(): void;
  37238. /**
  37239. * Gets if the scene is already disposed
  37240. */
  37241. get isDisposed(): boolean;
  37242. /**
  37243. * Call this function to reduce memory footprint of the scene.
  37244. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37245. */
  37246. clearCachedVertexData(): void;
  37247. /**
  37248. * This function will remove the local cached buffer data from texture.
  37249. * It will save memory but will prevent the texture from being rebuilt
  37250. */
  37251. cleanCachedTextureBuffer(): void;
  37252. /**
  37253. * Get the world extend vectors with an optional filter
  37254. *
  37255. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37256. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37257. */
  37258. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37259. min: Vector3;
  37260. max: Vector3;
  37261. };
  37262. /**
  37263. * Creates a ray that can be used to pick in the scene
  37264. * @param x defines the x coordinate of the origin (on-screen)
  37265. * @param y defines the y coordinate of the origin (on-screen)
  37266. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37267. * @param camera defines the camera to use for the picking
  37268. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37269. * @returns a Ray
  37270. */
  37271. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37272. /**
  37273. * Creates a ray that can be used to pick in the scene
  37274. * @param x defines the x coordinate of the origin (on-screen)
  37275. * @param y defines the y coordinate of the origin (on-screen)
  37276. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37277. * @param result defines the ray where to store the picking ray
  37278. * @param camera defines the camera to use for the picking
  37279. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37280. * @returns the current scene
  37281. */
  37282. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37283. /**
  37284. * Creates a ray that can be used to pick in the scene
  37285. * @param x defines the x coordinate of the origin (on-screen)
  37286. * @param y defines the y coordinate of the origin (on-screen)
  37287. * @param camera defines the camera to use for the picking
  37288. * @returns a Ray
  37289. */
  37290. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37291. /**
  37292. * Creates a ray that can be used to pick in the scene
  37293. * @param x defines the x coordinate of the origin (on-screen)
  37294. * @param y defines the y coordinate of the origin (on-screen)
  37295. * @param result defines the ray where to store the picking ray
  37296. * @param camera defines the camera to use for the picking
  37297. * @returns the current scene
  37298. */
  37299. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37300. /** Launch a ray to try to pick a mesh in the scene
  37301. * @param x position on screen
  37302. * @param y position on screen
  37303. * @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
  37304. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37305. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37306. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37307. * @returns a PickingInfo
  37308. */
  37309. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37310. /** Use the given ray to pick a mesh in the scene
  37311. * @param ray The ray to use to pick meshes
  37312. * @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
  37313. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37314. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37315. * @returns a PickingInfo
  37316. */
  37317. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37318. /**
  37319. * Launch a ray to try to pick a mesh in the scene
  37320. * @param x X position on screen
  37321. * @param y Y position on screen
  37322. * @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
  37323. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37324. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37325. * @returns an array of PickingInfo
  37326. */
  37327. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37328. /**
  37329. * Launch a ray to try to pick a mesh in the scene
  37330. * @param ray Ray to use
  37331. * @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
  37332. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37333. * @returns an array of PickingInfo
  37334. */
  37335. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37336. /**
  37337. * Force the value of meshUnderPointer
  37338. * @param mesh defines the mesh to use
  37339. */
  37340. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37341. /**
  37342. * Gets the mesh under the pointer
  37343. * @returns a Mesh or null if no mesh is under the pointer
  37344. */
  37345. getPointerOverMesh(): Nullable<AbstractMesh>;
  37346. /** @hidden */
  37347. _rebuildGeometries(): void;
  37348. /** @hidden */
  37349. _rebuildTextures(): void;
  37350. private _getByTags;
  37351. /**
  37352. * Get a list of meshes by tags
  37353. * @param tagsQuery defines the tags query to use
  37354. * @param forEach defines a predicate used to filter results
  37355. * @returns an array of Mesh
  37356. */
  37357. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37358. /**
  37359. * Get a list of cameras by tags
  37360. * @param tagsQuery defines the tags query to use
  37361. * @param forEach defines a predicate used to filter results
  37362. * @returns an array of Camera
  37363. */
  37364. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37365. /**
  37366. * Get a list of lights by tags
  37367. * @param tagsQuery defines the tags query to use
  37368. * @param forEach defines a predicate used to filter results
  37369. * @returns an array of Light
  37370. */
  37371. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37372. /**
  37373. * Get a list of materials by tags
  37374. * @param tagsQuery defines the tags query to use
  37375. * @param forEach defines a predicate used to filter results
  37376. * @returns an array of Material
  37377. */
  37378. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37379. /**
  37380. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37381. * This allowed control for front to back rendering or reversly depending of the special needs.
  37382. *
  37383. * @param renderingGroupId The rendering group id corresponding to its index
  37384. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37385. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37386. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37387. */
  37388. 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;
  37389. /**
  37390. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37391. *
  37392. * @param renderingGroupId The rendering group id corresponding to its index
  37393. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37394. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37395. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37396. */
  37397. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37398. /**
  37399. * Gets the current auto clear configuration for one rendering group of the rendering
  37400. * manager.
  37401. * @param index the rendering group index to get the information for
  37402. * @returns The auto clear setup for the requested rendering group
  37403. */
  37404. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37405. private _blockMaterialDirtyMechanism;
  37406. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37407. get blockMaterialDirtyMechanism(): boolean;
  37408. set blockMaterialDirtyMechanism(value: boolean);
  37409. /**
  37410. * Will flag all materials as dirty to trigger new shader compilation
  37411. * @param flag defines the flag used to specify which material part must be marked as dirty
  37412. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37413. */
  37414. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37415. /** @hidden */
  37416. _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;
  37417. /** @hidden */
  37418. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37419. /** @hidden */
  37420. _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;
  37421. /** @hidden */
  37422. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37423. /** @hidden */
  37424. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37425. /** @hidden */
  37426. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37427. }
  37428. }
  37429. declare module BABYLON {
  37430. /**
  37431. * Set of assets to keep when moving a scene into an asset container.
  37432. */
  37433. export class KeepAssets extends AbstractScene {
  37434. }
  37435. /**
  37436. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37437. */
  37438. export class InstantiatedEntries {
  37439. /**
  37440. * List of new root nodes (eg. nodes with no parent)
  37441. */
  37442. rootNodes: TransformNode[];
  37443. /**
  37444. * List of new skeletons
  37445. */
  37446. skeletons: Skeleton[];
  37447. /**
  37448. * List of new animation groups
  37449. */
  37450. animationGroups: AnimationGroup[];
  37451. }
  37452. /**
  37453. * Container with a set of assets that can be added or removed from a scene.
  37454. */
  37455. export class AssetContainer extends AbstractScene {
  37456. private _wasAddedToScene;
  37457. /**
  37458. * The scene the AssetContainer belongs to.
  37459. */
  37460. scene: Scene;
  37461. /**
  37462. * Instantiates an AssetContainer.
  37463. * @param scene The scene the AssetContainer belongs to.
  37464. */
  37465. constructor(scene: Scene);
  37466. /**
  37467. * Instantiate or clone all meshes and add the new ones to the scene.
  37468. * Skeletons and animation groups will all be cloned
  37469. * @param nameFunction defines an optional function used to get new names for clones
  37470. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37471. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37472. */
  37473. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37474. /**
  37475. * Adds all the assets from the container to the scene.
  37476. */
  37477. addAllToScene(): void;
  37478. /**
  37479. * Removes all the assets in the container from the scene
  37480. */
  37481. removeAllFromScene(): void;
  37482. /**
  37483. * Disposes all the assets in the container
  37484. */
  37485. dispose(): void;
  37486. private _moveAssets;
  37487. /**
  37488. * Removes all the assets contained in the scene and adds them to the container.
  37489. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37490. */
  37491. moveAllFromScene(keepAssets?: KeepAssets): void;
  37492. /**
  37493. * 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.
  37494. * @returns the root mesh
  37495. */
  37496. createRootMesh(): Mesh;
  37497. /**
  37498. * Merge animations from this asset container into a scene
  37499. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37500. * @param animatables set of animatables to retarget to a node from the scene
  37501. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37502. */
  37503. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37504. }
  37505. }
  37506. declare module BABYLON {
  37507. /**
  37508. * Defines how the parser contract is defined.
  37509. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37510. */
  37511. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37512. /**
  37513. * Defines how the individual parser contract is defined.
  37514. * These parser can parse an individual asset
  37515. */
  37516. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37517. /**
  37518. * Base class of the scene acting as a container for the different elements composing a scene.
  37519. * This class is dynamically extended by the different components of the scene increasing
  37520. * flexibility and reducing coupling
  37521. */
  37522. export abstract class AbstractScene {
  37523. /**
  37524. * Stores the list of available parsers in the application.
  37525. */
  37526. private static _BabylonFileParsers;
  37527. /**
  37528. * Stores the list of available individual parsers in the application.
  37529. */
  37530. private static _IndividualBabylonFileParsers;
  37531. /**
  37532. * Adds a parser in the list of available ones
  37533. * @param name Defines the name of the parser
  37534. * @param parser Defines the parser to add
  37535. */
  37536. static AddParser(name: string, parser: BabylonFileParser): void;
  37537. /**
  37538. * Gets a general parser from the list of avaialble ones
  37539. * @param name Defines the name of the parser
  37540. * @returns the requested parser or null
  37541. */
  37542. static GetParser(name: string): Nullable<BabylonFileParser>;
  37543. /**
  37544. * Adds n individual parser in the list of available ones
  37545. * @param name Defines the name of the parser
  37546. * @param parser Defines the parser to add
  37547. */
  37548. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37549. /**
  37550. * Gets an individual parser from the list of avaialble ones
  37551. * @param name Defines the name of the parser
  37552. * @returns the requested parser or null
  37553. */
  37554. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37555. /**
  37556. * Parser json data and populate both a scene and its associated container object
  37557. * @param jsonData Defines the data to parse
  37558. * @param scene Defines the scene to parse the data for
  37559. * @param container Defines the container attached to the parsing sequence
  37560. * @param rootUrl Defines the root url of the data
  37561. */
  37562. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37563. /**
  37564. * Gets the list of root nodes (ie. nodes with no parent)
  37565. */
  37566. rootNodes: Node[];
  37567. /** All of the cameras added to this scene
  37568. * @see http://doc.babylonjs.com/babylon101/cameras
  37569. */
  37570. cameras: Camera[];
  37571. /**
  37572. * All of the lights added to this scene
  37573. * @see http://doc.babylonjs.com/babylon101/lights
  37574. */
  37575. lights: Light[];
  37576. /**
  37577. * All of the (abstract) meshes added to this scene
  37578. */
  37579. meshes: AbstractMesh[];
  37580. /**
  37581. * The list of skeletons added to the scene
  37582. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37583. */
  37584. skeletons: Skeleton[];
  37585. /**
  37586. * All of the particle systems added to this scene
  37587. * @see http://doc.babylonjs.com/babylon101/particles
  37588. */
  37589. particleSystems: IParticleSystem[];
  37590. /**
  37591. * Gets a list of Animations associated with the scene
  37592. */
  37593. animations: Animation[];
  37594. /**
  37595. * All of the animation groups added to this scene
  37596. * @see http://doc.babylonjs.com/how_to/group
  37597. */
  37598. animationGroups: AnimationGroup[];
  37599. /**
  37600. * All of the multi-materials added to this scene
  37601. * @see http://doc.babylonjs.com/how_to/multi_materials
  37602. */
  37603. multiMaterials: MultiMaterial[];
  37604. /**
  37605. * All of the materials added to this scene
  37606. * In the context of a Scene, it is not supposed to be modified manually.
  37607. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37608. * Note also that the order of the Material within the array is not significant and might change.
  37609. * @see http://doc.babylonjs.com/babylon101/materials
  37610. */
  37611. materials: Material[];
  37612. /**
  37613. * The list of morph target managers added to the scene
  37614. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37615. */
  37616. morphTargetManagers: MorphTargetManager[];
  37617. /**
  37618. * The list of geometries used in the scene.
  37619. */
  37620. geometries: Geometry[];
  37621. /**
  37622. * All of the tranform nodes added to this scene
  37623. * In the context of a Scene, it is not supposed to be modified manually.
  37624. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37625. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37626. * @see http://doc.babylonjs.com/how_to/transformnode
  37627. */
  37628. transformNodes: TransformNode[];
  37629. /**
  37630. * ActionManagers available on the scene.
  37631. */
  37632. actionManagers: AbstractActionManager[];
  37633. /**
  37634. * Textures to keep.
  37635. */
  37636. textures: BaseTexture[];
  37637. /**
  37638. * Environment texture for the scene
  37639. */
  37640. environmentTexture: Nullable<BaseTexture>;
  37641. /**
  37642. * @returns all meshes, lights, cameras, transformNodes and bones
  37643. */
  37644. getNodes(): Array<Node>;
  37645. }
  37646. }
  37647. declare module BABYLON {
  37648. /**
  37649. * Interface used to define options for Sound class
  37650. */
  37651. export interface ISoundOptions {
  37652. /**
  37653. * Does the sound autoplay once loaded.
  37654. */
  37655. autoplay?: boolean;
  37656. /**
  37657. * Does the sound loop after it finishes playing once.
  37658. */
  37659. loop?: boolean;
  37660. /**
  37661. * Sound's volume
  37662. */
  37663. volume?: number;
  37664. /**
  37665. * Is it a spatial sound?
  37666. */
  37667. spatialSound?: boolean;
  37668. /**
  37669. * Maximum distance to hear that sound
  37670. */
  37671. maxDistance?: number;
  37672. /**
  37673. * Uses user defined attenuation function
  37674. */
  37675. useCustomAttenuation?: boolean;
  37676. /**
  37677. * Define the roll off factor of spatial sounds.
  37678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37679. */
  37680. rolloffFactor?: number;
  37681. /**
  37682. * Define the reference distance the sound should be heard perfectly.
  37683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37684. */
  37685. refDistance?: number;
  37686. /**
  37687. * Define the distance attenuation model the sound will follow.
  37688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37689. */
  37690. distanceModel?: string;
  37691. /**
  37692. * Defines the playback speed (1 by default)
  37693. */
  37694. playbackRate?: number;
  37695. /**
  37696. * Defines if the sound is from a streaming source
  37697. */
  37698. streaming?: boolean;
  37699. /**
  37700. * Defines an optional length (in seconds) inside the sound file
  37701. */
  37702. length?: number;
  37703. /**
  37704. * Defines an optional offset (in seconds) inside the sound file
  37705. */
  37706. offset?: number;
  37707. /**
  37708. * If true, URLs will not be required to state the audio file codec to use.
  37709. */
  37710. skipCodecCheck?: boolean;
  37711. }
  37712. /**
  37713. * Defines a sound that can be played in the application.
  37714. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37716. */
  37717. export class Sound {
  37718. /**
  37719. * The name of the sound in the scene.
  37720. */
  37721. name: string;
  37722. /**
  37723. * Does the sound autoplay once loaded.
  37724. */
  37725. autoplay: boolean;
  37726. /**
  37727. * Does the sound loop after it finishes playing once.
  37728. */
  37729. loop: boolean;
  37730. /**
  37731. * Does the sound use a custom attenuation curve to simulate the falloff
  37732. * happening when the source gets further away from the camera.
  37733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37734. */
  37735. useCustomAttenuation: boolean;
  37736. /**
  37737. * The sound track id this sound belongs to.
  37738. */
  37739. soundTrackId: number;
  37740. /**
  37741. * Is this sound currently played.
  37742. */
  37743. isPlaying: boolean;
  37744. /**
  37745. * Is this sound currently paused.
  37746. */
  37747. isPaused: boolean;
  37748. /**
  37749. * Does this sound enables spatial sound.
  37750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37751. */
  37752. spatialSound: boolean;
  37753. /**
  37754. * Define the reference distance the sound should be heard perfectly.
  37755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37756. */
  37757. refDistance: number;
  37758. /**
  37759. * Define the roll off factor of spatial sounds.
  37760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37761. */
  37762. rolloffFactor: number;
  37763. /**
  37764. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37766. */
  37767. maxDistance: number;
  37768. /**
  37769. * Define the distance attenuation model the sound will follow.
  37770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37771. */
  37772. distanceModel: string;
  37773. /**
  37774. * @hidden
  37775. * Back Compat
  37776. **/
  37777. onended: () => any;
  37778. /**
  37779. * Observable event when the current playing sound finishes.
  37780. */
  37781. onEndedObservable: Observable<Sound>;
  37782. private _panningModel;
  37783. private _playbackRate;
  37784. private _streaming;
  37785. private _startTime;
  37786. private _startOffset;
  37787. private _position;
  37788. /** @hidden */
  37789. _positionInEmitterSpace: boolean;
  37790. private _localDirection;
  37791. private _volume;
  37792. private _isReadyToPlay;
  37793. private _isDirectional;
  37794. private _readyToPlayCallback;
  37795. private _audioBuffer;
  37796. private _soundSource;
  37797. private _streamingSource;
  37798. private _soundPanner;
  37799. private _soundGain;
  37800. private _inputAudioNode;
  37801. private _outputAudioNode;
  37802. private _coneInnerAngle;
  37803. private _coneOuterAngle;
  37804. private _coneOuterGain;
  37805. private _scene;
  37806. private _connectedTransformNode;
  37807. private _customAttenuationFunction;
  37808. private _registerFunc;
  37809. private _isOutputConnected;
  37810. private _htmlAudioElement;
  37811. private _urlType;
  37812. private _length?;
  37813. private _offset?;
  37814. /** @hidden */
  37815. static _SceneComponentInitialization: (scene: Scene) => void;
  37816. /**
  37817. * Create a sound and attach it to a scene
  37818. * @param name Name of your sound
  37819. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37820. * @param scene defines the scene the sound belongs to
  37821. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37822. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37823. */
  37824. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37825. /**
  37826. * Release the sound and its associated resources
  37827. */
  37828. dispose(): void;
  37829. /**
  37830. * Gets if the sounds is ready to be played or not.
  37831. * @returns true if ready, otherwise false
  37832. */
  37833. isReady(): boolean;
  37834. private _soundLoaded;
  37835. /**
  37836. * Sets the data of the sound from an audiobuffer
  37837. * @param audioBuffer The audioBuffer containing the data
  37838. */
  37839. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37840. /**
  37841. * Updates the current sounds options such as maxdistance, loop...
  37842. * @param options A JSON object containing values named as the object properties
  37843. */
  37844. updateOptions(options: ISoundOptions): void;
  37845. private _createSpatialParameters;
  37846. private _updateSpatialParameters;
  37847. /**
  37848. * Switch the panning model to HRTF:
  37849. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37851. */
  37852. switchPanningModelToHRTF(): void;
  37853. /**
  37854. * Switch the panning model to Equal Power:
  37855. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37857. */
  37858. switchPanningModelToEqualPower(): void;
  37859. private _switchPanningModel;
  37860. /**
  37861. * Connect this sound to a sound track audio node like gain...
  37862. * @param soundTrackAudioNode the sound track audio node to connect to
  37863. */
  37864. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37865. /**
  37866. * Transform this sound into a directional source
  37867. * @param coneInnerAngle Size of the inner cone in degree
  37868. * @param coneOuterAngle Size of the outer cone in degree
  37869. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37870. */
  37871. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37872. /**
  37873. * Gets or sets the inner angle for the directional cone.
  37874. */
  37875. get directionalConeInnerAngle(): number;
  37876. /**
  37877. * Gets or sets the inner angle for the directional cone.
  37878. */
  37879. set directionalConeInnerAngle(value: number);
  37880. /**
  37881. * Gets or sets the outer angle for the directional cone.
  37882. */
  37883. get directionalConeOuterAngle(): number;
  37884. /**
  37885. * Gets or sets the outer angle for the directional cone.
  37886. */
  37887. set directionalConeOuterAngle(value: number);
  37888. /**
  37889. * Sets the position of the emitter if spatial sound is enabled
  37890. * @param newPosition Defines the new posisiton
  37891. */
  37892. setPosition(newPosition: Vector3): void;
  37893. /**
  37894. * Sets the local direction of the emitter if spatial sound is enabled
  37895. * @param newLocalDirection Defines the new local direction
  37896. */
  37897. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37898. private _updateDirection;
  37899. /** @hidden */
  37900. updateDistanceFromListener(): void;
  37901. /**
  37902. * Sets a new custom attenuation function for the sound.
  37903. * @param callback Defines the function used for the attenuation
  37904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37905. */
  37906. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37907. /**
  37908. * Play the sound
  37909. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37910. * @param offset (optional) Start the sound at a specific time in seconds
  37911. * @param length (optional) Sound duration (in seconds)
  37912. */
  37913. play(time?: number, offset?: number, length?: number): void;
  37914. private _onended;
  37915. /**
  37916. * Stop the sound
  37917. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37918. */
  37919. stop(time?: number): void;
  37920. /**
  37921. * Put the sound in pause
  37922. */
  37923. pause(): void;
  37924. /**
  37925. * Sets a dedicated volume for this sounds
  37926. * @param newVolume Define the new volume of the sound
  37927. * @param time Define time for gradual change to new volume
  37928. */
  37929. setVolume(newVolume: number, time?: number): void;
  37930. /**
  37931. * Set the sound play back rate
  37932. * @param newPlaybackRate Define the playback rate the sound should be played at
  37933. */
  37934. setPlaybackRate(newPlaybackRate: number): void;
  37935. /**
  37936. * Gets the volume of the sound.
  37937. * @returns the volume of the sound
  37938. */
  37939. getVolume(): number;
  37940. /**
  37941. * Attach the sound to a dedicated mesh
  37942. * @param transformNode The transform node to connect the sound with
  37943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37944. */
  37945. attachToMesh(transformNode: TransformNode): void;
  37946. /**
  37947. * Detach the sound from the previously attached mesh
  37948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37949. */
  37950. detachFromMesh(): void;
  37951. private _onRegisterAfterWorldMatrixUpdate;
  37952. /**
  37953. * Clone the current sound in the scene.
  37954. * @returns the new sound clone
  37955. */
  37956. clone(): Nullable<Sound>;
  37957. /**
  37958. * Gets the current underlying audio buffer containing the data
  37959. * @returns the audio buffer
  37960. */
  37961. getAudioBuffer(): Nullable<AudioBuffer>;
  37962. /**
  37963. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37964. * @returns the source node
  37965. */
  37966. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37967. /**
  37968. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37969. * @returns the gain node
  37970. */
  37971. getSoundGain(): Nullable<GainNode>;
  37972. /**
  37973. * Serializes the Sound in a JSON representation
  37974. * @returns the JSON representation of the sound
  37975. */
  37976. serialize(): any;
  37977. /**
  37978. * Parse a JSON representation of a sound to innstantiate in a given scene
  37979. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37980. * @param scene Define the scene the new parsed sound should be created in
  37981. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37982. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37983. * @returns the newly parsed sound
  37984. */
  37985. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37986. }
  37987. }
  37988. declare module BABYLON {
  37989. /**
  37990. * This defines an action helpful to play a defined sound on a triggered action.
  37991. */
  37992. export class PlaySoundAction extends Action {
  37993. private _sound;
  37994. /**
  37995. * Instantiate the action
  37996. * @param triggerOptions defines the trigger options
  37997. * @param sound defines the sound to play
  37998. * @param condition defines the trigger related conditions
  37999. */
  38000. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38001. /** @hidden */
  38002. _prepare(): void;
  38003. /**
  38004. * Execute the action and play the sound.
  38005. */
  38006. execute(): void;
  38007. /**
  38008. * Serializes the actions and its related information.
  38009. * @param parent defines the object to serialize in
  38010. * @returns the serialized object
  38011. */
  38012. serialize(parent: any): any;
  38013. }
  38014. /**
  38015. * This defines an action helpful to stop a defined sound on a triggered action.
  38016. */
  38017. export class StopSoundAction extends Action {
  38018. private _sound;
  38019. /**
  38020. * Instantiate the action
  38021. * @param triggerOptions defines the trigger options
  38022. * @param sound defines the sound to stop
  38023. * @param condition defines the trigger related conditions
  38024. */
  38025. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38026. /** @hidden */
  38027. _prepare(): void;
  38028. /**
  38029. * Execute the action and stop the sound.
  38030. */
  38031. execute(): void;
  38032. /**
  38033. * Serializes the actions and its related information.
  38034. * @param parent defines the object to serialize in
  38035. * @returns the serialized object
  38036. */
  38037. serialize(parent: any): any;
  38038. }
  38039. }
  38040. declare module BABYLON {
  38041. /**
  38042. * This defines an action responsible to change the value of a property
  38043. * by interpolating between its current value and the newly set one once triggered.
  38044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38045. */
  38046. export class InterpolateValueAction extends Action {
  38047. /**
  38048. * Defines the path of the property where the value should be interpolated
  38049. */
  38050. propertyPath: string;
  38051. /**
  38052. * Defines the target value at the end of the interpolation.
  38053. */
  38054. value: any;
  38055. /**
  38056. * Defines the time it will take for the property to interpolate to the value.
  38057. */
  38058. duration: number;
  38059. /**
  38060. * Defines if the other scene animations should be stopped when the action has been triggered
  38061. */
  38062. stopOtherAnimations?: boolean;
  38063. /**
  38064. * Defines a callback raised once the interpolation animation has been done.
  38065. */
  38066. onInterpolationDone?: () => void;
  38067. /**
  38068. * Observable triggered once the interpolation animation has been done.
  38069. */
  38070. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38071. private _target;
  38072. private _effectiveTarget;
  38073. private _property;
  38074. /**
  38075. * Instantiate the action
  38076. * @param triggerOptions defines the trigger options
  38077. * @param target defines the object containing the value to interpolate
  38078. * @param propertyPath defines the path to the property in the target object
  38079. * @param value defines the target value at the end of the interpolation
  38080. * @param duration deines the time it will take for the property to interpolate to the value.
  38081. * @param condition defines the trigger related conditions
  38082. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38083. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38084. */
  38085. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38086. /** @hidden */
  38087. _prepare(): void;
  38088. /**
  38089. * Execute the action starts the value interpolation.
  38090. */
  38091. execute(): void;
  38092. /**
  38093. * Serializes the actions and its related information.
  38094. * @param parent defines the object to serialize in
  38095. * @returns the serialized object
  38096. */
  38097. serialize(parent: any): any;
  38098. }
  38099. }
  38100. declare module BABYLON {
  38101. /**
  38102. * Options allowed during the creation of a sound track.
  38103. */
  38104. export interface ISoundTrackOptions {
  38105. /**
  38106. * The volume the sound track should take during creation
  38107. */
  38108. volume?: number;
  38109. /**
  38110. * Define if the sound track is the main sound track of the scene
  38111. */
  38112. mainTrack?: boolean;
  38113. }
  38114. /**
  38115. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38116. * It will be also used in a future release to apply effects on a specific track.
  38117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38118. */
  38119. export class SoundTrack {
  38120. /**
  38121. * The unique identifier of the sound track in the scene.
  38122. */
  38123. id: number;
  38124. /**
  38125. * The list of sounds included in the sound track.
  38126. */
  38127. soundCollection: Array<Sound>;
  38128. private _outputAudioNode;
  38129. private _scene;
  38130. private _connectedAnalyser;
  38131. private _options;
  38132. private _isInitialized;
  38133. /**
  38134. * Creates a new sound track.
  38135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38136. * @param scene Define the scene the sound track belongs to
  38137. * @param options
  38138. */
  38139. constructor(scene: Scene, options?: ISoundTrackOptions);
  38140. private _initializeSoundTrackAudioGraph;
  38141. /**
  38142. * Release the sound track and its associated resources
  38143. */
  38144. dispose(): void;
  38145. /**
  38146. * Adds a sound to this sound track
  38147. * @param sound define the cound to add
  38148. * @ignoreNaming
  38149. */
  38150. AddSound(sound: Sound): void;
  38151. /**
  38152. * Removes a sound to this sound track
  38153. * @param sound define the cound to remove
  38154. * @ignoreNaming
  38155. */
  38156. RemoveSound(sound: Sound): void;
  38157. /**
  38158. * Set a global volume for the full sound track.
  38159. * @param newVolume Define the new volume of the sound track
  38160. */
  38161. setVolume(newVolume: number): void;
  38162. /**
  38163. * Switch the panning model to HRTF:
  38164. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38166. */
  38167. switchPanningModelToHRTF(): void;
  38168. /**
  38169. * Switch the panning model to Equal Power:
  38170. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38172. */
  38173. switchPanningModelToEqualPower(): void;
  38174. /**
  38175. * Connect the sound track to an audio analyser allowing some amazing
  38176. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38178. * @param analyser The analyser to connect to the engine
  38179. */
  38180. connectToAnalyser(analyser: Analyser): void;
  38181. }
  38182. }
  38183. declare module BABYLON {
  38184. interface AbstractScene {
  38185. /**
  38186. * The list of sounds used in the scene.
  38187. */
  38188. sounds: Nullable<Array<Sound>>;
  38189. }
  38190. interface Scene {
  38191. /**
  38192. * @hidden
  38193. * Backing field
  38194. */
  38195. _mainSoundTrack: SoundTrack;
  38196. /**
  38197. * The main sound track played by the scene.
  38198. * It cotains your primary collection of sounds.
  38199. */
  38200. mainSoundTrack: SoundTrack;
  38201. /**
  38202. * The list of sound tracks added to the scene
  38203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38204. */
  38205. soundTracks: Nullable<Array<SoundTrack>>;
  38206. /**
  38207. * Gets a sound using a given name
  38208. * @param name defines the name to search for
  38209. * @return the found sound or null if not found at all.
  38210. */
  38211. getSoundByName(name: string): Nullable<Sound>;
  38212. /**
  38213. * Gets or sets if audio support is enabled
  38214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38215. */
  38216. audioEnabled: boolean;
  38217. /**
  38218. * Gets or sets if audio will be output to headphones
  38219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38220. */
  38221. headphone: boolean;
  38222. /**
  38223. * Gets or sets custom audio listener position provider
  38224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38225. */
  38226. audioListenerPositionProvider: Nullable<() => Vector3>;
  38227. /**
  38228. * Gets or sets a refresh rate when using 3D audio positioning
  38229. */
  38230. audioPositioningRefreshRate: number;
  38231. }
  38232. /**
  38233. * Defines the sound scene component responsible to manage any sounds
  38234. * in a given scene.
  38235. */
  38236. export class AudioSceneComponent implements ISceneSerializableComponent {
  38237. /**
  38238. * The component name helpfull to identify the component in the list of scene components.
  38239. */
  38240. readonly name: string;
  38241. /**
  38242. * The scene the component belongs to.
  38243. */
  38244. scene: Scene;
  38245. private _audioEnabled;
  38246. /**
  38247. * Gets whether audio is enabled or not.
  38248. * Please use related enable/disable method to switch state.
  38249. */
  38250. get audioEnabled(): boolean;
  38251. private _headphone;
  38252. /**
  38253. * Gets whether audio is outputing to headphone or not.
  38254. * Please use the according Switch methods to change output.
  38255. */
  38256. get headphone(): boolean;
  38257. /**
  38258. * Gets or sets a refresh rate when using 3D audio positioning
  38259. */
  38260. audioPositioningRefreshRate: number;
  38261. private _audioListenerPositionProvider;
  38262. /**
  38263. * Gets the current audio listener position provider
  38264. */
  38265. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38266. /**
  38267. * Sets a custom listener position for all sounds in the scene
  38268. * By default, this is the position of the first active camera
  38269. */
  38270. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38271. /**
  38272. * Creates a new instance of the component for the given scene
  38273. * @param scene Defines the scene to register the component in
  38274. */
  38275. constructor(scene: Scene);
  38276. /**
  38277. * Registers the component in a given scene
  38278. */
  38279. register(): void;
  38280. /**
  38281. * Rebuilds the elements related to this component in case of
  38282. * context lost for instance.
  38283. */
  38284. rebuild(): void;
  38285. /**
  38286. * Serializes the component data to the specified json object
  38287. * @param serializationObject The object to serialize to
  38288. */
  38289. serialize(serializationObject: any): void;
  38290. /**
  38291. * Adds all the elements from the container to the scene
  38292. * @param container the container holding the elements
  38293. */
  38294. addFromContainer(container: AbstractScene): void;
  38295. /**
  38296. * Removes all the elements in the container from the scene
  38297. * @param container contains the elements to remove
  38298. * @param dispose if the removed element should be disposed (default: false)
  38299. */
  38300. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38301. /**
  38302. * Disposes the component and the associated ressources.
  38303. */
  38304. dispose(): void;
  38305. /**
  38306. * Disables audio in the associated scene.
  38307. */
  38308. disableAudio(): void;
  38309. /**
  38310. * Enables audio in the associated scene.
  38311. */
  38312. enableAudio(): void;
  38313. /**
  38314. * Switch audio to headphone output.
  38315. */
  38316. switchAudioModeForHeadphones(): void;
  38317. /**
  38318. * Switch audio to normal speakers.
  38319. */
  38320. switchAudioModeForNormalSpeakers(): void;
  38321. private _cachedCameraDirection;
  38322. private _cachedCameraPosition;
  38323. private _lastCheck;
  38324. private _afterRender;
  38325. }
  38326. }
  38327. declare module BABYLON {
  38328. /**
  38329. * Wraps one or more Sound objects and selects one with random weight for playback.
  38330. */
  38331. export class WeightedSound {
  38332. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38333. loop: boolean;
  38334. private _coneInnerAngle;
  38335. private _coneOuterAngle;
  38336. private _volume;
  38337. /** A Sound is currently playing. */
  38338. isPlaying: boolean;
  38339. /** A Sound is currently paused. */
  38340. isPaused: boolean;
  38341. private _sounds;
  38342. private _weights;
  38343. private _currentIndex?;
  38344. /**
  38345. * Creates a new WeightedSound from the list of sounds given.
  38346. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38347. * @param sounds Array of Sounds that will be selected from.
  38348. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38349. */
  38350. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38351. /**
  38352. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38353. */
  38354. get directionalConeInnerAngle(): number;
  38355. /**
  38356. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38357. */
  38358. set directionalConeInnerAngle(value: number);
  38359. /**
  38360. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38361. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38362. */
  38363. get directionalConeOuterAngle(): number;
  38364. /**
  38365. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38366. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38367. */
  38368. set directionalConeOuterAngle(value: number);
  38369. /**
  38370. * Playback volume.
  38371. */
  38372. get volume(): number;
  38373. /**
  38374. * Playback volume.
  38375. */
  38376. set volume(value: number);
  38377. private _onended;
  38378. /**
  38379. * Suspend playback
  38380. */
  38381. pause(): void;
  38382. /**
  38383. * Stop playback
  38384. */
  38385. stop(): void;
  38386. /**
  38387. * Start playback.
  38388. * @param startOffset Position the clip head at a specific time in seconds.
  38389. */
  38390. play(startOffset?: number): void;
  38391. }
  38392. }
  38393. declare module BABYLON {
  38394. /**
  38395. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38397. */
  38398. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38399. /**
  38400. * Gets the name of the behavior.
  38401. */
  38402. get name(): string;
  38403. /**
  38404. * The easing function used by animations
  38405. */
  38406. static EasingFunction: BackEase;
  38407. /**
  38408. * The easing mode used by animations
  38409. */
  38410. static EasingMode: number;
  38411. /**
  38412. * The duration of the animation, in milliseconds
  38413. */
  38414. transitionDuration: number;
  38415. /**
  38416. * Length of the distance animated by the transition when lower radius is reached
  38417. */
  38418. lowerRadiusTransitionRange: number;
  38419. /**
  38420. * Length of the distance animated by the transition when upper radius is reached
  38421. */
  38422. upperRadiusTransitionRange: number;
  38423. private _autoTransitionRange;
  38424. /**
  38425. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38426. */
  38427. get autoTransitionRange(): boolean;
  38428. /**
  38429. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38430. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38431. */
  38432. set autoTransitionRange(value: boolean);
  38433. private _attachedCamera;
  38434. private _onAfterCheckInputsObserver;
  38435. private _onMeshTargetChangedObserver;
  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 _radiusIsAnimating;
  38450. private _radiusBounceTransition;
  38451. private _animatables;
  38452. private _cachedWheelPrecision;
  38453. /**
  38454. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38455. * @param radiusLimit The limit to check against.
  38456. * @return Bool to indicate if at limit.
  38457. */
  38458. private _isRadiusAtLimit;
  38459. /**
  38460. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38461. * @param radiusDelta The delta by which to animate to. Can be negative.
  38462. */
  38463. private _applyBoundRadiusAnimation;
  38464. /**
  38465. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38466. */
  38467. protected _clearAnimationLocks(): void;
  38468. /**
  38469. * Stops and removes all animations that have been applied to the camera
  38470. */
  38471. stopAllAnimations(): void;
  38472. }
  38473. }
  38474. declare module BABYLON {
  38475. /**
  38476. * 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.
  38477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38478. */
  38479. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38480. /**
  38481. * Gets the name of the behavior.
  38482. */
  38483. get name(): string;
  38484. private _mode;
  38485. private _radiusScale;
  38486. private _positionScale;
  38487. private _defaultElevation;
  38488. private _elevationReturnTime;
  38489. private _elevationReturnWaitTime;
  38490. private _zoomStopsAnimation;
  38491. private _framingTime;
  38492. /**
  38493. * The easing function used by animations
  38494. */
  38495. static EasingFunction: ExponentialEase;
  38496. /**
  38497. * The easing mode used by animations
  38498. */
  38499. static EasingMode: number;
  38500. /**
  38501. * Sets the current mode used by the behavior
  38502. */
  38503. set mode(mode: number);
  38504. /**
  38505. * Gets current mode used by the behavior.
  38506. */
  38507. get mode(): number;
  38508. /**
  38509. * Sets the scale applied to the radius (1 by default)
  38510. */
  38511. set radiusScale(radius: number);
  38512. /**
  38513. * Gets the scale applied to the radius
  38514. */
  38515. get radiusScale(): number;
  38516. /**
  38517. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38518. */
  38519. set positionScale(scale: number);
  38520. /**
  38521. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38522. */
  38523. get positionScale(): number;
  38524. /**
  38525. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38526. * behaviour is triggered, in radians.
  38527. */
  38528. set defaultElevation(elevation: number);
  38529. /**
  38530. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38531. * behaviour is triggered, in radians.
  38532. */
  38533. get defaultElevation(): number;
  38534. /**
  38535. * Sets the time (in milliseconds) taken to return to the default beta position.
  38536. * Negative value indicates camera should not return to default.
  38537. */
  38538. set elevationReturnTime(speed: number);
  38539. /**
  38540. * Gets the time (in milliseconds) taken to return to the default beta position.
  38541. * Negative value indicates camera should not return to default.
  38542. */
  38543. get elevationReturnTime(): number;
  38544. /**
  38545. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38546. */
  38547. set elevationReturnWaitTime(time: number);
  38548. /**
  38549. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38550. */
  38551. get elevationReturnWaitTime(): number;
  38552. /**
  38553. * Sets the flag that indicates if user zooming should stop animation.
  38554. */
  38555. set zoomStopsAnimation(flag: boolean);
  38556. /**
  38557. * Gets the flag that indicates if user zooming should stop animation.
  38558. */
  38559. get zoomStopsAnimation(): boolean;
  38560. /**
  38561. * Sets the transition time when framing the mesh, in milliseconds
  38562. */
  38563. set framingTime(time: number);
  38564. /**
  38565. * Gets the transition time when framing the mesh, in milliseconds
  38566. */
  38567. get framingTime(): number;
  38568. /**
  38569. * Define if the behavior should automatically change the configured
  38570. * camera limits and sensibilities.
  38571. */
  38572. autoCorrectCameraLimitsAndSensibility: boolean;
  38573. private _onPrePointerObservableObserver;
  38574. private _onAfterCheckInputsObserver;
  38575. private _onMeshTargetChangedObserver;
  38576. private _attachedCamera;
  38577. private _isPointerDown;
  38578. private _lastInteractionTime;
  38579. /**
  38580. * Initializes the behavior.
  38581. */
  38582. init(): void;
  38583. /**
  38584. * Attaches the behavior to its arc rotate camera.
  38585. * @param camera Defines the camera to attach the behavior to
  38586. */
  38587. attach(camera: ArcRotateCamera): void;
  38588. /**
  38589. * Detaches the behavior from its current arc rotate camera.
  38590. */
  38591. detach(): void;
  38592. private _animatables;
  38593. private _betaIsAnimating;
  38594. private _betaTransition;
  38595. private _radiusTransition;
  38596. private _vectorTransition;
  38597. /**
  38598. * Targets the given mesh and updates zoom level accordingly.
  38599. * @param mesh The mesh to target.
  38600. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38601. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38602. */
  38603. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38604. /**
  38605. * Targets the given mesh with its children and updates zoom level accordingly.
  38606. * @param mesh The mesh to target.
  38607. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38608. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38609. */
  38610. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38611. /**
  38612. * Targets the given meshes with their children and updates zoom level accordingly.
  38613. * @param meshes The mesh to target.
  38614. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38615. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38616. */
  38617. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38618. /**
  38619. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38620. * @param minimumWorld Determines the smaller position of the bounding box extend
  38621. * @param maximumWorld Determines the bigger position of the bounding box extend
  38622. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38623. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38624. */
  38625. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38626. /**
  38627. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38628. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38629. * frustum width.
  38630. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38631. * to fully enclose the mesh in the viewing frustum.
  38632. */
  38633. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38634. /**
  38635. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38636. * is automatically returned to its default position (expected to be above ground plane).
  38637. */
  38638. private _maintainCameraAboveGround;
  38639. /**
  38640. * Returns the frustum slope based on the canvas ratio and camera FOV
  38641. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38642. */
  38643. private _getFrustumSlope;
  38644. /**
  38645. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38646. */
  38647. private _clearAnimationLocks;
  38648. /**
  38649. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38650. */
  38651. private _applyUserInteraction;
  38652. /**
  38653. * Stops and removes all animations that have been applied to the camera
  38654. */
  38655. stopAllAnimations(): void;
  38656. /**
  38657. * Gets a value indicating if the user is moving the camera
  38658. */
  38659. get isUserIsMoving(): boolean;
  38660. /**
  38661. * The camera can move all the way towards the mesh.
  38662. */
  38663. static IgnoreBoundsSizeMode: number;
  38664. /**
  38665. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38666. */
  38667. static FitFrustumSidesMode: number;
  38668. }
  38669. }
  38670. declare module BABYLON {
  38671. /**
  38672. * Base class for Camera Pointer Inputs.
  38673. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38674. * for example usage.
  38675. */
  38676. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38677. /**
  38678. * Defines the camera the input is attached to.
  38679. */
  38680. abstract camera: Camera;
  38681. /**
  38682. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38683. */
  38684. protected _altKey: boolean;
  38685. protected _ctrlKey: boolean;
  38686. protected _metaKey: boolean;
  38687. protected _shiftKey: boolean;
  38688. /**
  38689. * Which mouse buttons were pressed at time of last mouse event.
  38690. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38691. */
  38692. protected _buttonsPressed: number;
  38693. /**
  38694. * Defines the buttons associated with the input to handle camera move.
  38695. */
  38696. buttons: number[];
  38697. /**
  38698. * Attach the input controls to a specific dom element to get the input from.
  38699. * @param element Defines the element the controls should be listened from
  38700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38701. */
  38702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38703. /**
  38704. * Detach the current controls from the specified dom element.
  38705. * @param element Defines the element to stop listening the inputs from
  38706. */
  38707. detachControl(element: Nullable<HTMLElement>): void;
  38708. /**
  38709. * Gets the class name of the current input.
  38710. * @returns the class name
  38711. */
  38712. getClassName(): string;
  38713. /**
  38714. * Get the friendly name associated with the input class.
  38715. * @returns the input friendly name
  38716. */
  38717. getSimpleName(): string;
  38718. /**
  38719. * Called on pointer POINTERDOUBLETAP event.
  38720. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38721. */
  38722. protected onDoubleTap(type: string): void;
  38723. /**
  38724. * Called on pointer POINTERMOVE event if only a single touch is active.
  38725. * Override this method to provide functionality.
  38726. */
  38727. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38728. /**
  38729. * Called on pointer POINTERMOVE event if multiple touches are active.
  38730. * Override this method to provide functionality.
  38731. */
  38732. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38733. /**
  38734. * Called on JS contextmenu event.
  38735. * Override this method to provide functionality.
  38736. */
  38737. protected onContextMenu(evt: PointerEvent): void;
  38738. /**
  38739. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38740. * press.
  38741. * Override this method to provide functionality.
  38742. */
  38743. protected onButtonDown(evt: PointerEvent): void;
  38744. /**
  38745. * Called each time a new POINTERUP event occurs. Ie, for each button
  38746. * release.
  38747. * Override this method to provide functionality.
  38748. */
  38749. protected onButtonUp(evt: PointerEvent): void;
  38750. /**
  38751. * Called when window becomes inactive.
  38752. * Override this method to provide functionality.
  38753. */
  38754. protected onLostFocus(): void;
  38755. private _pointerInput;
  38756. private _observer;
  38757. private _onLostFocus;
  38758. private pointA;
  38759. private pointB;
  38760. }
  38761. }
  38762. declare module BABYLON {
  38763. /**
  38764. * Manage the pointers inputs to control an arc rotate camera.
  38765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38766. */
  38767. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38768. /**
  38769. * Defines the camera the input is attached to.
  38770. */
  38771. camera: ArcRotateCamera;
  38772. /**
  38773. * Gets the class name of the current input.
  38774. * @returns the class name
  38775. */
  38776. getClassName(): string;
  38777. /**
  38778. * Defines the buttons associated with the input to handle camera move.
  38779. */
  38780. buttons: number[];
  38781. /**
  38782. * Defines the pointer angular sensibility along the X axis or how fast is
  38783. * the camera rotating.
  38784. */
  38785. angularSensibilityX: number;
  38786. /**
  38787. * Defines the pointer angular sensibility along the Y axis or how fast is
  38788. * the camera rotating.
  38789. */
  38790. angularSensibilityY: number;
  38791. /**
  38792. * Defines the pointer pinch precision or how fast is the camera zooming.
  38793. */
  38794. pinchPrecision: number;
  38795. /**
  38796. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38797. * from 0.
  38798. * It defines the percentage of current camera.radius to use as delta when
  38799. * pinch zoom is used.
  38800. */
  38801. pinchDeltaPercentage: number;
  38802. /**
  38803. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38804. * that any object in the plane at the camera's target point will scale
  38805. * perfectly with finger motion.
  38806. * Overrides pinchDeltaPercentage and pinchPrecision.
  38807. */
  38808. useNaturalPinchZoom: boolean;
  38809. /**
  38810. * Defines the pointer panning sensibility or how fast is the camera moving.
  38811. */
  38812. panningSensibility: number;
  38813. /**
  38814. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38815. */
  38816. multiTouchPanning: boolean;
  38817. /**
  38818. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38819. * zoom (pinch) through multitouch.
  38820. */
  38821. multiTouchPanAndZoom: boolean;
  38822. /**
  38823. * Revers pinch action direction.
  38824. */
  38825. pinchInwards: boolean;
  38826. private _isPanClick;
  38827. private _twoFingerActivityCount;
  38828. private _isPinching;
  38829. /**
  38830. * Called on pointer POINTERMOVE event if only a single touch is active.
  38831. */
  38832. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38833. /**
  38834. * Called on pointer POINTERDOUBLETAP event.
  38835. */
  38836. protected onDoubleTap(type: string): void;
  38837. /**
  38838. * Called on pointer POINTERMOVE event if multiple touches are active.
  38839. */
  38840. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38841. /**
  38842. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38843. * press.
  38844. */
  38845. protected onButtonDown(evt: PointerEvent): void;
  38846. /**
  38847. * Called each time a new POINTERUP event occurs. Ie, for each button
  38848. * release.
  38849. */
  38850. protected onButtonUp(evt: PointerEvent): void;
  38851. /**
  38852. * Called when window becomes inactive.
  38853. */
  38854. protected onLostFocus(): void;
  38855. }
  38856. }
  38857. declare module BABYLON {
  38858. /**
  38859. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38861. */
  38862. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38863. /**
  38864. * Defines the camera the input is attached to.
  38865. */
  38866. camera: ArcRotateCamera;
  38867. /**
  38868. * Defines the list of key codes associated with the up action (increase alpha)
  38869. */
  38870. keysUp: number[];
  38871. /**
  38872. * Defines the list of key codes associated with the down action (decrease alpha)
  38873. */
  38874. keysDown: number[];
  38875. /**
  38876. * Defines the list of key codes associated with the left action (increase beta)
  38877. */
  38878. keysLeft: number[];
  38879. /**
  38880. * Defines the list of key codes associated with the right action (decrease beta)
  38881. */
  38882. keysRight: number[];
  38883. /**
  38884. * Defines the list of key codes associated with the reset action.
  38885. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38886. */
  38887. keysReset: number[];
  38888. /**
  38889. * Defines the panning sensibility of the inputs.
  38890. * (How fast is the camera panning)
  38891. */
  38892. panningSensibility: number;
  38893. /**
  38894. * Defines the zooming sensibility of the inputs.
  38895. * (How fast is the camera zooming)
  38896. */
  38897. zoomingSensibility: number;
  38898. /**
  38899. * Defines whether maintaining the alt key down switch the movement mode from
  38900. * orientation to zoom.
  38901. */
  38902. useAltToZoom: boolean;
  38903. /**
  38904. * Rotation speed of the camera
  38905. */
  38906. angularSpeed: number;
  38907. private _keys;
  38908. private _ctrlPressed;
  38909. private _altPressed;
  38910. private _onCanvasBlurObserver;
  38911. private _onKeyboardObserver;
  38912. private _engine;
  38913. private _scene;
  38914. /**
  38915. * Attach the input controls to a specific dom element to get the input from.
  38916. * @param element Defines the element the controls should be listened from
  38917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38918. */
  38919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38920. /**
  38921. * Detach the current controls from the specified dom element.
  38922. * @param element Defines the element to stop listening the inputs from
  38923. */
  38924. detachControl(element: Nullable<HTMLElement>): void;
  38925. /**
  38926. * Update the current camera state depending on the inputs that have been used this frame.
  38927. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38928. */
  38929. checkInputs(): void;
  38930. /**
  38931. * Gets the class name of the current intput.
  38932. * @returns the class name
  38933. */
  38934. getClassName(): string;
  38935. /**
  38936. * Get the friendly name associated with the input class.
  38937. * @returns the input friendly name
  38938. */
  38939. getSimpleName(): string;
  38940. }
  38941. }
  38942. declare module BABYLON {
  38943. /**
  38944. * Manage the mouse wheel inputs to control an arc rotate camera.
  38945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38946. */
  38947. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38948. /**
  38949. * Defines the camera the input is attached to.
  38950. */
  38951. camera: ArcRotateCamera;
  38952. /**
  38953. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38954. */
  38955. wheelPrecision: number;
  38956. /**
  38957. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38958. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38959. */
  38960. wheelDeltaPercentage: number;
  38961. private _wheel;
  38962. private _observer;
  38963. private computeDeltaFromMouseWheelLegacyEvent;
  38964. /**
  38965. * Attach the input controls to a specific dom element to get the input from.
  38966. * @param element Defines the element the controls should be listened from
  38967. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38968. */
  38969. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38970. /**
  38971. * Detach the current controls from the specified dom element.
  38972. * @param element Defines the element to stop listening the inputs from
  38973. */
  38974. detachControl(element: Nullable<HTMLElement>): void;
  38975. /**
  38976. * Gets the class name of the current intput.
  38977. * @returns the class name
  38978. */
  38979. getClassName(): string;
  38980. /**
  38981. * Get the friendly name associated with the input class.
  38982. * @returns the input friendly name
  38983. */
  38984. getSimpleName(): string;
  38985. }
  38986. }
  38987. declare module BABYLON {
  38988. /**
  38989. * Default Inputs manager for the ArcRotateCamera.
  38990. * It groups all the default supported inputs for ease of use.
  38991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38992. */
  38993. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38994. /**
  38995. * Instantiates a new ArcRotateCameraInputsManager.
  38996. * @param camera Defines the camera the inputs belong to
  38997. */
  38998. constructor(camera: ArcRotateCamera);
  38999. /**
  39000. * Add mouse wheel input support to the input manager.
  39001. * @returns the current input manager
  39002. */
  39003. addMouseWheel(): ArcRotateCameraInputsManager;
  39004. /**
  39005. * Add pointers input support to the input manager.
  39006. * @returns the current input manager
  39007. */
  39008. addPointers(): ArcRotateCameraInputsManager;
  39009. /**
  39010. * Add keyboard input support to the input manager.
  39011. * @returns the current input manager
  39012. */
  39013. addKeyboard(): ArcRotateCameraInputsManager;
  39014. }
  39015. }
  39016. declare module BABYLON {
  39017. /**
  39018. * This represents an orbital type of camera.
  39019. *
  39020. * 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.
  39021. * 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.
  39022. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39023. */
  39024. export class ArcRotateCamera extends TargetCamera {
  39025. /**
  39026. * Defines the rotation angle of the camera along the longitudinal axis.
  39027. */
  39028. alpha: number;
  39029. /**
  39030. * Defines the rotation angle of the camera along the latitudinal axis.
  39031. */
  39032. beta: number;
  39033. /**
  39034. * Defines the radius of the camera from it s target point.
  39035. */
  39036. radius: number;
  39037. protected _target: Vector3;
  39038. protected _targetHost: Nullable<AbstractMesh>;
  39039. /**
  39040. * Defines the target point of the camera.
  39041. * The camera looks towards it form the radius distance.
  39042. */
  39043. get target(): Vector3;
  39044. set target(value: Vector3);
  39045. /**
  39046. * Define the current local position of the camera in the scene
  39047. */
  39048. get position(): Vector3;
  39049. set position(newPosition: Vector3);
  39050. protected _upVector: Vector3;
  39051. protected _upToYMatrix: Matrix;
  39052. protected _YToUpMatrix: Matrix;
  39053. /**
  39054. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39055. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39056. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39057. */
  39058. set upVector(vec: Vector3);
  39059. get upVector(): Vector3;
  39060. /**
  39061. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39062. */
  39063. setMatUp(): void;
  39064. /**
  39065. * Current inertia value on the longitudinal axis.
  39066. * The bigger this number the longer it will take for the camera to stop.
  39067. */
  39068. inertialAlphaOffset: number;
  39069. /**
  39070. * Current inertia value on the latitudinal axis.
  39071. * The bigger this number the longer it will take for the camera to stop.
  39072. */
  39073. inertialBetaOffset: number;
  39074. /**
  39075. * Current inertia value on the radius axis.
  39076. * The bigger this number the longer it will take for the camera to stop.
  39077. */
  39078. inertialRadiusOffset: number;
  39079. /**
  39080. * Minimum allowed angle on the longitudinal axis.
  39081. * This can help limiting how the Camera is able to move in the scene.
  39082. */
  39083. lowerAlphaLimit: Nullable<number>;
  39084. /**
  39085. * Maximum allowed angle on the longitudinal axis.
  39086. * This can help limiting how the Camera is able to move in the scene.
  39087. */
  39088. upperAlphaLimit: Nullable<number>;
  39089. /**
  39090. * Minimum allowed angle on the latitudinal axis.
  39091. * This can help limiting how the Camera is able to move in the scene.
  39092. */
  39093. lowerBetaLimit: number;
  39094. /**
  39095. * Maximum allowed angle on the latitudinal axis.
  39096. * This can help limiting how the Camera is able to move in the scene.
  39097. */
  39098. upperBetaLimit: number;
  39099. /**
  39100. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39101. * This can help limiting how the Camera is able to move in the scene.
  39102. */
  39103. lowerRadiusLimit: Nullable<number>;
  39104. /**
  39105. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39106. * This can help limiting how the Camera is able to move in the scene.
  39107. */
  39108. upperRadiusLimit: Nullable<number>;
  39109. /**
  39110. * Defines the current inertia value used during panning of the camera along the X axis.
  39111. */
  39112. inertialPanningX: number;
  39113. /**
  39114. * Defines the current inertia value used during panning of the camera along the Y axis.
  39115. */
  39116. inertialPanningY: number;
  39117. /**
  39118. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39119. * Basically if your fingers moves away from more than this distance you will be considered
  39120. * in pinch mode.
  39121. */
  39122. pinchToPanMaxDistance: number;
  39123. /**
  39124. * Defines the maximum distance the camera can pan.
  39125. * This could help keeping the cammera always in your scene.
  39126. */
  39127. panningDistanceLimit: Nullable<number>;
  39128. /**
  39129. * Defines the target of the camera before paning.
  39130. */
  39131. panningOriginTarget: Vector3;
  39132. /**
  39133. * Defines the value of the inertia used during panning.
  39134. * 0 would mean stop inertia and one would mean no decelleration at all.
  39135. */
  39136. panningInertia: number;
  39137. /**
  39138. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39139. */
  39140. get angularSensibilityX(): number;
  39141. set angularSensibilityX(value: number);
  39142. /**
  39143. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39144. */
  39145. get angularSensibilityY(): number;
  39146. set angularSensibilityY(value: number);
  39147. /**
  39148. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39149. */
  39150. get pinchPrecision(): number;
  39151. set pinchPrecision(value: number);
  39152. /**
  39153. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39154. * It will be used instead of pinchDeltaPrecision if different from 0.
  39155. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39156. */
  39157. get pinchDeltaPercentage(): number;
  39158. set pinchDeltaPercentage(value: number);
  39159. /**
  39160. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39161. * and pinch delta percentage.
  39162. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39163. * that any object in the plane at the camera's target point will scale
  39164. * perfectly with finger motion.
  39165. */
  39166. get useNaturalPinchZoom(): boolean;
  39167. set useNaturalPinchZoom(value: boolean);
  39168. /**
  39169. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39170. */
  39171. get panningSensibility(): number;
  39172. set panningSensibility(value: number);
  39173. /**
  39174. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39175. */
  39176. get keysUp(): number[];
  39177. set keysUp(value: number[]);
  39178. /**
  39179. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39180. */
  39181. get keysDown(): number[];
  39182. set keysDown(value: number[]);
  39183. /**
  39184. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39185. */
  39186. get keysLeft(): number[];
  39187. set keysLeft(value: number[]);
  39188. /**
  39189. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39190. */
  39191. get keysRight(): number[];
  39192. set keysRight(value: number[]);
  39193. /**
  39194. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39195. */
  39196. get wheelPrecision(): number;
  39197. set wheelPrecision(value: number);
  39198. /**
  39199. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39200. * It will be used instead of pinchDeltaPrecision if different from 0.
  39201. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39202. */
  39203. get wheelDeltaPercentage(): number;
  39204. set wheelDeltaPercentage(value: number);
  39205. /**
  39206. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39207. */
  39208. zoomOnFactor: number;
  39209. /**
  39210. * Defines a screen offset for the camera position.
  39211. */
  39212. targetScreenOffset: Vector2;
  39213. /**
  39214. * Allows the camera to be completely reversed.
  39215. * If false the camera can not arrive upside down.
  39216. */
  39217. allowUpsideDown: boolean;
  39218. /**
  39219. * Define if double tap/click is used to restore the previously saved state of the camera.
  39220. */
  39221. useInputToRestoreState: boolean;
  39222. /** @hidden */
  39223. _viewMatrix: Matrix;
  39224. /** @hidden */
  39225. _useCtrlForPanning: boolean;
  39226. /** @hidden */
  39227. _panningMouseButton: number;
  39228. /**
  39229. * Defines the input associated to the camera.
  39230. */
  39231. inputs: ArcRotateCameraInputsManager;
  39232. /** @hidden */
  39233. _reset: () => void;
  39234. /**
  39235. * Defines the allowed panning axis.
  39236. */
  39237. panningAxis: Vector3;
  39238. protected _localDirection: Vector3;
  39239. protected _transformedDirection: Vector3;
  39240. private _bouncingBehavior;
  39241. /**
  39242. * Gets the bouncing behavior of the camera if it has been enabled.
  39243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39244. */
  39245. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39246. /**
  39247. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39248. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39249. */
  39250. get useBouncingBehavior(): boolean;
  39251. set useBouncingBehavior(value: boolean);
  39252. private _framingBehavior;
  39253. /**
  39254. * Gets the framing behavior of the camera if it has been enabled.
  39255. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39256. */
  39257. get framingBehavior(): Nullable<FramingBehavior>;
  39258. /**
  39259. * Defines if the framing behavior of the camera is enabled on the camera.
  39260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39261. */
  39262. get useFramingBehavior(): boolean;
  39263. set useFramingBehavior(value: boolean);
  39264. private _autoRotationBehavior;
  39265. /**
  39266. * Gets the auto rotation behavior of the camera if it has been enabled.
  39267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39268. */
  39269. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39270. /**
  39271. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39273. */
  39274. get useAutoRotationBehavior(): boolean;
  39275. set useAutoRotationBehavior(value: boolean);
  39276. /**
  39277. * Observable triggered when the mesh target has been changed on the camera.
  39278. */
  39279. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39280. /**
  39281. * Event raised when the camera is colliding with a mesh.
  39282. */
  39283. onCollide: (collidedMesh: AbstractMesh) => void;
  39284. /**
  39285. * Defines whether the camera should check collision with the objects oh the scene.
  39286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39287. */
  39288. checkCollisions: boolean;
  39289. /**
  39290. * Defines the collision radius of the camera.
  39291. * This simulates a sphere around the camera.
  39292. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39293. */
  39294. collisionRadius: Vector3;
  39295. protected _collider: Collider;
  39296. protected _previousPosition: Vector3;
  39297. protected _collisionVelocity: Vector3;
  39298. protected _newPosition: Vector3;
  39299. protected _previousAlpha: number;
  39300. protected _previousBeta: number;
  39301. protected _previousRadius: number;
  39302. protected _collisionTriggered: boolean;
  39303. protected _targetBoundingCenter: Nullable<Vector3>;
  39304. private _computationVector;
  39305. /**
  39306. * Instantiates a new ArcRotateCamera in a given scene
  39307. * @param name Defines the name of the camera
  39308. * @param alpha Defines the camera rotation along the logitudinal axis
  39309. * @param beta Defines the camera rotation along the latitudinal axis
  39310. * @param radius Defines the camera distance from its target
  39311. * @param target Defines the camera target
  39312. * @param scene Defines the scene the camera belongs to
  39313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39314. */
  39315. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39316. /** @hidden */
  39317. _initCache(): void;
  39318. /** @hidden */
  39319. _updateCache(ignoreParentClass?: boolean): void;
  39320. protected _getTargetPosition(): Vector3;
  39321. private _storedAlpha;
  39322. private _storedBeta;
  39323. private _storedRadius;
  39324. private _storedTarget;
  39325. private _storedTargetScreenOffset;
  39326. /**
  39327. * Stores the current state of the camera (alpha, beta, radius and target)
  39328. * @returns the camera itself
  39329. */
  39330. storeState(): Camera;
  39331. /**
  39332. * @hidden
  39333. * Restored camera state. You must call storeState() first
  39334. */
  39335. _restoreStateValues(): boolean;
  39336. /** @hidden */
  39337. _isSynchronizedViewMatrix(): boolean;
  39338. /**
  39339. * Attached controls to the current camera.
  39340. * @param element Defines the element the controls should be listened from
  39341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39342. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39343. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39344. */
  39345. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39346. /**
  39347. * Detach the current controls from the camera.
  39348. * The camera will stop reacting to inputs.
  39349. * @param element Defines the element to stop listening the inputs from
  39350. */
  39351. detachControl(element: HTMLElement): void;
  39352. /** @hidden */
  39353. _checkInputs(): void;
  39354. protected _checkLimits(): void;
  39355. /**
  39356. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39357. */
  39358. rebuildAnglesAndRadius(): void;
  39359. /**
  39360. * Use a position to define the current camera related information like alpha, beta and radius
  39361. * @param position Defines the position to set the camera at
  39362. */
  39363. setPosition(position: Vector3): void;
  39364. /**
  39365. * Defines the target the camera should look at.
  39366. * This will automatically adapt alpha beta and radius to fit within the new target.
  39367. * @param target Defines the new target as a Vector or a mesh
  39368. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39369. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39370. */
  39371. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39372. /** @hidden */
  39373. _getViewMatrix(): Matrix;
  39374. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39375. /**
  39376. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39377. * @param meshes Defines the mesh to zoom on
  39378. * @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)
  39379. */
  39380. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39381. /**
  39382. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39383. * The target will be changed but the radius
  39384. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39385. * @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)
  39386. */
  39387. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39388. min: Vector3;
  39389. max: Vector3;
  39390. distance: number;
  39391. }, doNotUpdateMaxZ?: boolean): void;
  39392. /**
  39393. * @override
  39394. * Override Camera.createRigCamera
  39395. */
  39396. createRigCamera(name: string, cameraIndex: number): Camera;
  39397. /**
  39398. * @hidden
  39399. * @override
  39400. * Override Camera._updateRigCameras
  39401. */
  39402. _updateRigCameras(): void;
  39403. /**
  39404. * Destroy the camera and release the current resources hold by it.
  39405. */
  39406. dispose(): void;
  39407. /**
  39408. * Gets the current object class name.
  39409. * @return the class name
  39410. */
  39411. getClassName(): string;
  39412. }
  39413. }
  39414. declare module BABYLON {
  39415. /**
  39416. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39417. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39418. */
  39419. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39420. /**
  39421. * Gets the name of the behavior.
  39422. */
  39423. get name(): string;
  39424. private _zoomStopsAnimation;
  39425. private _idleRotationSpeed;
  39426. private _idleRotationWaitTime;
  39427. private _idleRotationSpinupTime;
  39428. /**
  39429. * Sets the flag that indicates if user zooming should stop animation.
  39430. */
  39431. set zoomStopsAnimation(flag: boolean);
  39432. /**
  39433. * Gets the flag that indicates if user zooming should stop animation.
  39434. */
  39435. get zoomStopsAnimation(): boolean;
  39436. /**
  39437. * Sets the default speed at which the camera rotates around the model.
  39438. */
  39439. set idleRotationSpeed(speed: number);
  39440. /**
  39441. * Gets the default speed at which the camera rotates around the model.
  39442. */
  39443. get idleRotationSpeed(): number;
  39444. /**
  39445. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39446. */
  39447. set idleRotationWaitTime(time: number);
  39448. /**
  39449. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39450. */
  39451. get idleRotationWaitTime(): number;
  39452. /**
  39453. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39454. */
  39455. set idleRotationSpinupTime(time: number);
  39456. /**
  39457. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39458. */
  39459. get idleRotationSpinupTime(): number;
  39460. /**
  39461. * Gets a value indicating if the camera is currently rotating because of this behavior
  39462. */
  39463. get rotationInProgress(): boolean;
  39464. private _onPrePointerObservableObserver;
  39465. private _onAfterCheckInputsObserver;
  39466. private _attachedCamera;
  39467. private _isPointerDown;
  39468. private _lastFrameTime;
  39469. private _lastInteractionTime;
  39470. private _cameraRotationSpeed;
  39471. /**
  39472. * Initializes the behavior.
  39473. */
  39474. init(): void;
  39475. /**
  39476. * Attaches the behavior to its arc rotate camera.
  39477. * @param camera Defines the camera to attach the behavior to
  39478. */
  39479. attach(camera: ArcRotateCamera): void;
  39480. /**
  39481. * Detaches the behavior from its current arc rotate camera.
  39482. */
  39483. detach(): void;
  39484. /**
  39485. * Returns true if user is scrolling.
  39486. * @return true if user is scrolling.
  39487. */
  39488. private _userIsZooming;
  39489. private _lastFrameRadius;
  39490. private _shouldAnimationStopForInteraction;
  39491. /**
  39492. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39493. */
  39494. private _applyUserInteraction;
  39495. private _userIsMoving;
  39496. }
  39497. }
  39498. declare module BABYLON {
  39499. /**
  39500. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39501. */
  39502. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39503. private ui;
  39504. /**
  39505. * The name of the behavior
  39506. */
  39507. name: string;
  39508. /**
  39509. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39510. */
  39511. distanceAwayFromFace: number;
  39512. /**
  39513. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39514. */
  39515. distanceAwayFromBottomOfFace: number;
  39516. private _faceVectors;
  39517. private _target;
  39518. private _scene;
  39519. private _onRenderObserver;
  39520. private _tmpMatrix;
  39521. private _tmpVector;
  39522. /**
  39523. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39524. * @param ui The transform node that should be attched to the mesh
  39525. */
  39526. constructor(ui: TransformNode);
  39527. /**
  39528. * Initializes the behavior
  39529. */
  39530. init(): void;
  39531. private _closestFace;
  39532. private _zeroVector;
  39533. private _lookAtTmpMatrix;
  39534. private _lookAtToRef;
  39535. /**
  39536. * Attaches the AttachToBoxBehavior to the passed in mesh
  39537. * @param target The mesh that the specified node will be attached to
  39538. */
  39539. attach(target: Mesh): void;
  39540. /**
  39541. * Detaches the behavior from the mesh
  39542. */
  39543. detach(): void;
  39544. }
  39545. }
  39546. declare module BABYLON {
  39547. /**
  39548. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39549. */
  39550. export class FadeInOutBehavior implements Behavior<Mesh> {
  39551. /**
  39552. * Time in milliseconds to delay before fading in (Default: 0)
  39553. */
  39554. delay: number;
  39555. /**
  39556. * Time in milliseconds for the mesh to fade in (Default: 300)
  39557. */
  39558. fadeInTime: number;
  39559. private _millisecondsPerFrame;
  39560. private _hovered;
  39561. private _hoverValue;
  39562. private _ownerNode;
  39563. /**
  39564. * Instatiates the FadeInOutBehavior
  39565. */
  39566. constructor();
  39567. /**
  39568. * The name of the behavior
  39569. */
  39570. get name(): string;
  39571. /**
  39572. * Initializes the behavior
  39573. */
  39574. init(): void;
  39575. /**
  39576. * Attaches the fade behavior on the passed in mesh
  39577. * @param ownerNode The mesh that will be faded in/out once attached
  39578. */
  39579. attach(ownerNode: Mesh): void;
  39580. /**
  39581. * Detaches the behavior from the mesh
  39582. */
  39583. detach(): void;
  39584. /**
  39585. * Triggers the mesh to begin fading in or out
  39586. * @param value if the object should fade in or out (true to fade in)
  39587. */
  39588. fadeIn(value: boolean): void;
  39589. private _update;
  39590. private _setAllVisibility;
  39591. }
  39592. }
  39593. declare module BABYLON {
  39594. /**
  39595. * Class containing a set of static utilities functions for managing Pivots
  39596. * @hidden
  39597. */
  39598. export class PivotTools {
  39599. private static _PivotCached;
  39600. private static _OldPivotPoint;
  39601. private static _PivotTranslation;
  39602. private static _PivotTmpVector;
  39603. /** @hidden */
  39604. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39605. /** @hidden */
  39606. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39607. }
  39608. }
  39609. declare module BABYLON {
  39610. /**
  39611. * Class containing static functions to help procedurally build meshes
  39612. */
  39613. export class PlaneBuilder {
  39614. /**
  39615. * Creates a plane mesh
  39616. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39617. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39618. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39620. * * 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
  39621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39622. * @param name defines the name of the mesh
  39623. * @param options defines the options used to create the mesh
  39624. * @param scene defines the hosting scene
  39625. * @returns the plane mesh
  39626. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39627. */
  39628. static CreatePlane(name: string, options: {
  39629. size?: number;
  39630. width?: number;
  39631. height?: number;
  39632. sideOrientation?: number;
  39633. frontUVs?: Vector4;
  39634. backUVs?: Vector4;
  39635. updatable?: boolean;
  39636. sourcePlane?: Plane;
  39637. }, scene?: Nullable<Scene>): Mesh;
  39638. }
  39639. }
  39640. declare module BABYLON {
  39641. /**
  39642. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39643. */
  39644. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39645. private static _AnyMouseID;
  39646. /**
  39647. * Abstract mesh the behavior is set on
  39648. */
  39649. attachedNode: AbstractMesh;
  39650. private _dragPlane;
  39651. private _scene;
  39652. private _pointerObserver;
  39653. private _beforeRenderObserver;
  39654. private static _planeScene;
  39655. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39656. /**
  39657. * 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)
  39658. */
  39659. maxDragAngle: number;
  39660. /**
  39661. * @hidden
  39662. */
  39663. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39664. /**
  39665. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39666. */
  39667. currentDraggingPointerID: number;
  39668. /**
  39669. * The last position where the pointer hit the drag plane in world space
  39670. */
  39671. lastDragPosition: Vector3;
  39672. /**
  39673. * If the behavior is currently in a dragging state
  39674. */
  39675. dragging: boolean;
  39676. /**
  39677. * 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)
  39678. */
  39679. dragDeltaRatio: number;
  39680. /**
  39681. * If the drag plane orientation should be updated during the dragging (Default: true)
  39682. */
  39683. updateDragPlane: boolean;
  39684. private _debugMode;
  39685. private _moving;
  39686. /**
  39687. * Fires each time the attached mesh is dragged with the pointer
  39688. * * delta between last drag position and current drag position in world space
  39689. * * dragDistance along the drag axis
  39690. * * dragPlaneNormal normal of the current drag plane used during the drag
  39691. * * dragPlanePoint in world space where the drag intersects the drag plane
  39692. */
  39693. onDragObservable: Observable<{
  39694. delta: Vector3;
  39695. dragPlanePoint: Vector3;
  39696. dragPlaneNormal: Vector3;
  39697. dragDistance: number;
  39698. pointerId: number;
  39699. }>;
  39700. /**
  39701. * Fires each time a drag begins (eg. mouse down on mesh)
  39702. */
  39703. onDragStartObservable: Observable<{
  39704. dragPlanePoint: Vector3;
  39705. pointerId: number;
  39706. }>;
  39707. /**
  39708. * Fires each time a drag ends (eg. mouse release after drag)
  39709. */
  39710. onDragEndObservable: Observable<{
  39711. dragPlanePoint: Vector3;
  39712. pointerId: number;
  39713. }>;
  39714. /**
  39715. * If the attached mesh should be moved when dragged
  39716. */
  39717. moveAttached: boolean;
  39718. /**
  39719. * If the drag behavior will react to drag events (Default: true)
  39720. */
  39721. enabled: boolean;
  39722. /**
  39723. * If pointer events should start and release the drag (Default: true)
  39724. */
  39725. startAndReleaseDragOnPointerEvents: boolean;
  39726. /**
  39727. * If camera controls should be detached during the drag
  39728. */
  39729. detachCameraControls: boolean;
  39730. /**
  39731. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39732. */
  39733. useObjectOrientationForDragging: boolean;
  39734. private _options;
  39735. /**
  39736. * Gets the options used by the behavior
  39737. */
  39738. get options(): {
  39739. dragAxis?: Vector3;
  39740. dragPlaneNormal?: Vector3;
  39741. };
  39742. /**
  39743. * Sets the options used by the behavior
  39744. */
  39745. set options(options: {
  39746. dragAxis?: Vector3;
  39747. dragPlaneNormal?: Vector3;
  39748. });
  39749. /**
  39750. * Creates a pointer drag behavior that can be attached to a mesh
  39751. * @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)
  39752. */
  39753. constructor(options?: {
  39754. dragAxis?: Vector3;
  39755. dragPlaneNormal?: Vector3;
  39756. });
  39757. /**
  39758. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39759. */
  39760. validateDrag: (targetPosition: Vector3) => boolean;
  39761. /**
  39762. * The name of the behavior
  39763. */
  39764. get name(): string;
  39765. /**
  39766. * Initializes the behavior
  39767. */
  39768. init(): void;
  39769. private _tmpVector;
  39770. private _alternatePickedPoint;
  39771. private _worldDragAxis;
  39772. private _targetPosition;
  39773. private _attachedElement;
  39774. /**
  39775. * Attaches the drag behavior the passed in mesh
  39776. * @param ownerNode The mesh that will be dragged around once attached
  39777. * @param predicate Predicate to use for pick filtering
  39778. */
  39779. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39780. /**
  39781. * Force relase the drag action by code.
  39782. */
  39783. releaseDrag(): void;
  39784. private _startDragRay;
  39785. private _lastPointerRay;
  39786. /**
  39787. * Simulates the start of a pointer drag event on the behavior
  39788. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39789. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39790. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39791. */
  39792. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39793. private _startDrag;
  39794. private _dragDelta;
  39795. private _moveDrag;
  39796. private _pickWithRayOnDragPlane;
  39797. private _pointA;
  39798. private _pointB;
  39799. private _pointC;
  39800. private _lineA;
  39801. private _lineB;
  39802. private _localAxis;
  39803. private _lookAt;
  39804. private _updateDragPlanePosition;
  39805. /**
  39806. * Detaches the behavior from the mesh
  39807. */
  39808. detach(): void;
  39809. }
  39810. }
  39811. declare module BABYLON {
  39812. /**
  39813. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39814. */
  39815. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39816. private _dragBehaviorA;
  39817. private _dragBehaviorB;
  39818. private _startDistance;
  39819. private _initialScale;
  39820. private _targetScale;
  39821. private _ownerNode;
  39822. private _sceneRenderObserver;
  39823. /**
  39824. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39825. */
  39826. constructor();
  39827. /**
  39828. * The name of the behavior
  39829. */
  39830. get name(): string;
  39831. /**
  39832. * Initializes the behavior
  39833. */
  39834. init(): void;
  39835. private _getCurrentDistance;
  39836. /**
  39837. * Attaches the scale behavior the passed in mesh
  39838. * @param ownerNode The mesh that will be scaled around once attached
  39839. */
  39840. attach(ownerNode: Mesh): void;
  39841. /**
  39842. * Detaches the behavior from the mesh
  39843. */
  39844. detach(): void;
  39845. }
  39846. }
  39847. declare module BABYLON {
  39848. /**
  39849. * 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
  39850. */
  39851. export class SixDofDragBehavior implements Behavior<Mesh> {
  39852. private static _virtualScene;
  39853. private _ownerNode;
  39854. private _sceneRenderObserver;
  39855. private _scene;
  39856. private _targetPosition;
  39857. private _virtualOriginMesh;
  39858. private _virtualDragMesh;
  39859. private _pointerObserver;
  39860. private _moving;
  39861. private _startingOrientation;
  39862. private _attachedElement;
  39863. /**
  39864. * 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)
  39865. */
  39866. private zDragFactor;
  39867. /**
  39868. * If the object should rotate to face the drag origin
  39869. */
  39870. rotateDraggedObject: boolean;
  39871. /**
  39872. * If the behavior is currently in a dragging state
  39873. */
  39874. dragging: boolean;
  39875. /**
  39876. * 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)
  39877. */
  39878. dragDeltaRatio: number;
  39879. /**
  39880. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39881. */
  39882. currentDraggingPointerID: number;
  39883. /**
  39884. * If camera controls should be detached during the drag
  39885. */
  39886. detachCameraControls: boolean;
  39887. /**
  39888. * Fires each time a drag starts
  39889. */
  39890. onDragStartObservable: Observable<{}>;
  39891. /**
  39892. * Fires each time a drag ends (eg. mouse release after drag)
  39893. */
  39894. onDragEndObservable: Observable<{}>;
  39895. /**
  39896. * 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
  39897. */
  39898. constructor();
  39899. /**
  39900. * The name of the behavior
  39901. */
  39902. get name(): string;
  39903. /**
  39904. * Initializes the behavior
  39905. */
  39906. init(): void;
  39907. /**
  39908. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39909. */
  39910. private get _pointerCamera();
  39911. /**
  39912. * Attaches the scale behavior the passed in mesh
  39913. * @param ownerNode The mesh that will be scaled around once attached
  39914. */
  39915. attach(ownerNode: Mesh): void;
  39916. /**
  39917. * Detaches the behavior from the mesh
  39918. */
  39919. detach(): void;
  39920. }
  39921. }
  39922. declare module BABYLON {
  39923. /**
  39924. * Class used to apply inverse kinematics to bones
  39925. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39926. */
  39927. export class BoneIKController {
  39928. private static _tmpVecs;
  39929. private static _tmpQuat;
  39930. private static _tmpMats;
  39931. /**
  39932. * Gets or sets the target mesh
  39933. */
  39934. targetMesh: AbstractMesh;
  39935. /** Gets or sets the mesh used as pole */
  39936. poleTargetMesh: AbstractMesh;
  39937. /**
  39938. * Gets or sets the bone used as pole
  39939. */
  39940. poleTargetBone: Nullable<Bone>;
  39941. /**
  39942. * Gets or sets the target position
  39943. */
  39944. targetPosition: Vector3;
  39945. /**
  39946. * Gets or sets the pole target position
  39947. */
  39948. poleTargetPosition: Vector3;
  39949. /**
  39950. * Gets or sets the pole target local offset
  39951. */
  39952. poleTargetLocalOffset: Vector3;
  39953. /**
  39954. * Gets or sets the pole angle
  39955. */
  39956. poleAngle: number;
  39957. /**
  39958. * Gets or sets the mesh associated with the controller
  39959. */
  39960. mesh: AbstractMesh;
  39961. /**
  39962. * 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)
  39963. */
  39964. slerpAmount: number;
  39965. private _bone1Quat;
  39966. private _bone1Mat;
  39967. private _bone2Ang;
  39968. private _bone1;
  39969. private _bone2;
  39970. private _bone1Length;
  39971. private _bone2Length;
  39972. private _maxAngle;
  39973. private _maxReach;
  39974. private _rightHandedSystem;
  39975. private _bendAxis;
  39976. private _slerping;
  39977. private _adjustRoll;
  39978. /**
  39979. * Gets or sets maximum allowed angle
  39980. */
  39981. get maxAngle(): number;
  39982. set maxAngle(value: number);
  39983. /**
  39984. * Creates a new BoneIKController
  39985. * @param mesh defines the mesh to control
  39986. * @param bone defines the bone to control
  39987. * @param options defines options to set up the controller
  39988. */
  39989. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39990. targetMesh?: AbstractMesh;
  39991. poleTargetMesh?: AbstractMesh;
  39992. poleTargetBone?: Bone;
  39993. poleTargetLocalOffset?: Vector3;
  39994. poleAngle?: number;
  39995. bendAxis?: Vector3;
  39996. maxAngle?: number;
  39997. slerpAmount?: number;
  39998. });
  39999. private _setMaxAngle;
  40000. /**
  40001. * Force the controller to update the bones
  40002. */
  40003. update(): void;
  40004. }
  40005. }
  40006. declare module BABYLON {
  40007. /**
  40008. * Class used to make a bone look toward a point in space
  40009. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40010. */
  40011. export class BoneLookController {
  40012. private static _tmpVecs;
  40013. private static _tmpQuat;
  40014. private static _tmpMats;
  40015. /**
  40016. * The target Vector3 that the bone will look at
  40017. */
  40018. target: Vector3;
  40019. /**
  40020. * The mesh that the bone is attached to
  40021. */
  40022. mesh: AbstractMesh;
  40023. /**
  40024. * The bone that will be looking to the target
  40025. */
  40026. bone: Bone;
  40027. /**
  40028. * The up axis of the coordinate system that is used when the bone is rotated
  40029. */
  40030. upAxis: Vector3;
  40031. /**
  40032. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40033. */
  40034. upAxisSpace: Space;
  40035. /**
  40036. * Used to make an adjustment to the yaw of the bone
  40037. */
  40038. adjustYaw: number;
  40039. /**
  40040. * Used to make an adjustment to the pitch of the bone
  40041. */
  40042. adjustPitch: number;
  40043. /**
  40044. * Used to make an adjustment to the roll of the bone
  40045. */
  40046. adjustRoll: number;
  40047. /**
  40048. * 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)
  40049. */
  40050. slerpAmount: number;
  40051. private _minYaw;
  40052. private _maxYaw;
  40053. private _minPitch;
  40054. private _maxPitch;
  40055. private _minYawSin;
  40056. private _minYawCos;
  40057. private _maxYawSin;
  40058. private _maxYawCos;
  40059. private _midYawConstraint;
  40060. private _minPitchTan;
  40061. private _maxPitchTan;
  40062. private _boneQuat;
  40063. private _slerping;
  40064. private _transformYawPitch;
  40065. private _transformYawPitchInv;
  40066. private _firstFrameSkipped;
  40067. private _yawRange;
  40068. private _fowardAxis;
  40069. /**
  40070. * Gets or sets the minimum yaw angle that the bone can look to
  40071. */
  40072. get minYaw(): number;
  40073. set minYaw(value: number);
  40074. /**
  40075. * Gets or sets the maximum yaw angle that the bone can look to
  40076. */
  40077. get maxYaw(): number;
  40078. set maxYaw(value: number);
  40079. /**
  40080. * Gets or sets the minimum pitch angle that the bone can look to
  40081. */
  40082. get minPitch(): number;
  40083. set minPitch(value: number);
  40084. /**
  40085. * Gets or sets the maximum pitch angle that the bone can look to
  40086. */
  40087. get maxPitch(): number;
  40088. set maxPitch(value: number);
  40089. /**
  40090. * Create a BoneLookController
  40091. * @param mesh the mesh that the bone belongs to
  40092. * @param bone the bone that will be looking to the target
  40093. * @param target the target Vector3 to look at
  40094. * @param options optional settings:
  40095. * * maxYaw: the maximum angle the bone will yaw to
  40096. * * minYaw: the minimum angle the bone will yaw to
  40097. * * maxPitch: the maximum angle the bone will pitch to
  40098. * * minPitch: the minimum angle the bone will yaw to
  40099. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40100. * * upAxis: the up axis of the coordinate system
  40101. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40102. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40103. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40104. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40105. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40106. * * adjustRoll: used to make an adjustment to the roll of the bone
  40107. **/
  40108. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40109. maxYaw?: number;
  40110. minYaw?: number;
  40111. maxPitch?: number;
  40112. minPitch?: number;
  40113. slerpAmount?: number;
  40114. upAxis?: Vector3;
  40115. upAxisSpace?: Space;
  40116. yawAxis?: Vector3;
  40117. pitchAxis?: Vector3;
  40118. adjustYaw?: number;
  40119. adjustPitch?: number;
  40120. adjustRoll?: number;
  40121. });
  40122. /**
  40123. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40124. */
  40125. update(): void;
  40126. private _getAngleDiff;
  40127. private _getAngleBetween;
  40128. private _isAngleBetween;
  40129. }
  40130. }
  40131. declare module BABYLON {
  40132. /**
  40133. * Manage the gamepad inputs to control an arc rotate camera.
  40134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40135. */
  40136. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40137. /**
  40138. * Defines the camera the input is attached to.
  40139. */
  40140. camera: ArcRotateCamera;
  40141. /**
  40142. * Defines the gamepad the input is gathering event from.
  40143. */
  40144. gamepad: Nullable<Gamepad>;
  40145. /**
  40146. * Defines the gamepad rotation sensiblity.
  40147. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40148. */
  40149. gamepadRotationSensibility: number;
  40150. /**
  40151. * Defines the gamepad move sensiblity.
  40152. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40153. */
  40154. gamepadMoveSensibility: number;
  40155. private _yAxisScale;
  40156. /**
  40157. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40158. */
  40159. get invertYAxis(): boolean;
  40160. set invertYAxis(value: boolean);
  40161. private _onGamepadConnectedObserver;
  40162. private _onGamepadDisconnectedObserver;
  40163. /**
  40164. * Attach the input controls to a specific dom element to get the input from.
  40165. * @param element Defines the element the controls should be listened from
  40166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40167. */
  40168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40169. /**
  40170. * Detach the current controls from the specified dom element.
  40171. * @param element Defines the element to stop listening the inputs from
  40172. */
  40173. detachControl(element: Nullable<HTMLElement>): void;
  40174. /**
  40175. * Update the current camera state depending on the inputs that have been used this frame.
  40176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40177. */
  40178. checkInputs(): void;
  40179. /**
  40180. * Gets the class name of the current intput.
  40181. * @returns the class name
  40182. */
  40183. getClassName(): string;
  40184. /**
  40185. * Get the friendly name associated with the input class.
  40186. * @returns the input friendly name
  40187. */
  40188. getSimpleName(): string;
  40189. }
  40190. }
  40191. declare module BABYLON {
  40192. interface ArcRotateCameraInputsManager {
  40193. /**
  40194. * Add orientation input support to the input manager.
  40195. * @returns the current input manager
  40196. */
  40197. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40198. }
  40199. /**
  40200. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40202. */
  40203. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40204. /**
  40205. * Defines the camera the input is attached to.
  40206. */
  40207. camera: ArcRotateCamera;
  40208. /**
  40209. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40210. */
  40211. alphaCorrection: number;
  40212. /**
  40213. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40214. */
  40215. gammaCorrection: number;
  40216. private _alpha;
  40217. private _gamma;
  40218. private _dirty;
  40219. private _deviceOrientationHandler;
  40220. /**
  40221. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40222. */
  40223. constructor();
  40224. /**
  40225. * Attach the input controls to a specific dom element to get the input from.
  40226. * @param element Defines the element the controls should be listened from
  40227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40228. */
  40229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40230. /** @hidden */
  40231. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40232. /**
  40233. * Update the current camera state depending on the inputs that have been used this frame.
  40234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40235. */
  40236. checkInputs(): void;
  40237. /**
  40238. * Detach the current controls from the specified dom element.
  40239. * @param element Defines the element to stop listening the inputs from
  40240. */
  40241. detachControl(element: Nullable<HTMLElement>): void;
  40242. /**
  40243. * Gets the class name of the current intput.
  40244. * @returns the class name
  40245. */
  40246. getClassName(): string;
  40247. /**
  40248. * Get the friendly name associated with the input class.
  40249. * @returns the input friendly name
  40250. */
  40251. getSimpleName(): string;
  40252. }
  40253. }
  40254. declare module BABYLON {
  40255. /**
  40256. * Listen to mouse events to control the camera.
  40257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40258. */
  40259. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40260. /**
  40261. * Defines the camera the input is attached to.
  40262. */
  40263. camera: FlyCamera;
  40264. /**
  40265. * Defines if touch is enabled. (Default is true.)
  40266. */
  40267. touchEnabled: boolean;
  40268. /**
  40269. * Defines the buttons associated with the input to handle camera rotation.
  40270. */
  40271. buttons: number[];
  40272. /**
  40273. * Assign buttons for Yaw control.
  40274. */
  40275. buttonsYaw: number[];
  40276. /**
  40277. * Assign buttons for Pitch control.
  40278. */
  40279. buttonsPitch: number[];
  40280. /**
  40281. * Assign buttons for Roll control.
  40282. */
  40283. buttonsRoll: number[];
  40284. /**
  40285. * Detect if any button is being pressed while mouse is moved.
  40286. * -1 = Mouse locked.
  40287. * 0 = Left button.
  40288. * 1 = Middle Button.
  40289. * 2 = Right Button.
  40290. */
  40291. activeButton: number;
  40292. /**
  40293. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40294. * Higher values reduce its sensitivity.
  40295. */
  40296. angularSensibility: number;
  40297. private _mousemoveCallback;
  40298. private _observer;
  40299. private _rollObserver;
  40300. private previousPosition;
  40301. private noPreventDefault;
  40302. private element;
  40303. /**
  40304. * Listen to mouse events to control the camera.
  40305. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40307. */
  40308. constructor(touchEnabled?: boolean);
  40309. /**
  40310. * Attach the mouse control to the HTML DOM element.
  40311. * @param element Defines the element that listens to the input events.
  40312. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40313. */
  40314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40315. /**
  40316. * Detach the current controls from the specified dom element.
  40317. * @param element Defines the element to stop listening the inputs from
  40318. */
  40319. detachControl(element: Nullable<HTMLElement>): void;
  40320. /**
  40321. * Gets the class name of the current input.
  40322. * @returns the class name.
  40323. */
  40324. getClassName(): string;
  40325. /**
  40326. * Get the friendly name associated with the input class.
  40327. * @returns the input's friendly name.
  40328. */
  40329. getSimpleName(): string;
  40330. private _pointerInput;
  40331. private _onMouseMove;
  40332. /**
  40333. * Rotate camera by mouse offset.
  40334. */
  40335. private rotateCamera;
  40336. }
  40337. }
  40338. declare module BABYLON {
  40339. /**
  40340. * Default Inputs manager for the FlyCamera.
  40341. * It groups all the default supported inputs for ease of use.
  40342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40343. */
  40344. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40345. /**
  40346. * Instantiates a new FlyCameraInputsManager.
  40347. * @param camera Defines the camera the inputs belong to.
  40348. */
  40349. constructor(camera: FlyCamera);
  40350. /**
  40351. * Add keyboard input support to the input manager.
  40352. * @returns the new FlyCameraKeyboardMoveInput().
  40353. */
  40354. addKeyboard(): FlyCameraInputsManager;
  40355. /**
  40356. * Add mouse input support to the input manager.
  40357. * @param touchEnabled Enable touch screen support.
  40358. * @returns the new FlyCameraMouseInput().
  40359. */
  40360. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40361. }
  40362. }
  40363. declare module BABYLON {
  40364. /**
  40365. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40366. * such as in a 3D Space Shooter or a Flight Simulator.
  40367. */
  40368. export class FlyCamera extends TargetCamera {
  40369. /**
  40370. * Define the collision ellipsoid of the camera.
  40371. * This is helpful for simulating a camera body, like a player's body.
  40372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40373. */
  40374. ellipsoid: Vector3;
  40375. /**
  40376. * Define an offset for the position of the ellipsoid around the camera.
  40377. * This can be helpful if the camera is attached away from the player's body center,
  40378. * such as at its head.
  40379. */
  40380. ellipsoidOffset: Vector3;
  40381. /**
  40382. * Enable or disable collisions of the camera with the rest of the scene objects.
  40383. */
  40384. checkCollisions: boolean;
  40385. /**
  40386. * Enable or disable gravity on the camera.
  40387. */
  40388. applyGravity: boolean;
  40389. /**
  40390. * Define the current direction the camera is moving to.
  40391. */
  40392. cameraDirection: Vector3;
  40393. /**
  40394. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40395. * This overrides and empties cameraRotation.
  40396. */
  40397. rotationQuaternion: Quaternion;
  40398. /**
  40399. * Track Roll to maintain the wanted Rolling when looking around.
  40400. */
  40401. _trackRoll: number;
  40402. /**
  40403. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40404. */
  40405. rollCorrect: number;
  40406. /**
  40407. * Mimic a banked turn, Rolling the camera when Yawing.
  40408. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40409. */
  40410. bankedTurn: boolean;
  40411. /**
  40412. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40413. */
  40414. bankedTurnLimit: number;
  40415. /**
  40416. * Value of 0 disables the banked Roll.
  40417. * Value of 1 is equal to the Yaw angle in radians.
  40418. */
  40419. bankedTurnMultiplier: number;
  40420. /**
  40421. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40422. */
  40423. inputs: FlyCameraInputsManager;
  40424. /**
  40425. * Gets the input sensibility for mouse input.
  40426. * Higher values reduce sensitivity.
  40427. */
  40428. get angularSensibility(): number;
  40429. /**
  40430. * Sets the input sensibility for a mouse input.
  40431. * Higher values reduce sensitivity.
  40432. */
  40433. set angularSensibility(value: number);
  40434. /**
  40435. * Get the keys for camera movement forward.
  40436. */
  40437. get keysForward(): number[];
  40438. /**
  40439. * Set the keys for camera movement forward.
  40440. */
  40441. set keysForward(value: number[]);
  40442. /**
  40443. * Get the keys for camera movement backward.
  40444. */
  40445. get keysBackward(): number[];
  40446. set keysBackward(value: number[]);
  40447. /**
  40448. * Get the keys for camera movement up.
  40449. */
  40450. get keysUp(): number[];
  40451. /**
  40452. * Set the keys for camera movement up.
  40453. */
  40454. set keysUp(value: number[]);
  40455. /**
  40456. * Get the keys for camera movement down.
  40457. */
  40458. get keysDown(): number[];
  40459. /**
  40460. * Set the keys for camera movement down.
  40461. */
  40462. set keysDown(value: number[]);
  40463. /**
  40464. * Get the keys for camera movement left.
  40465. */
  40466. get keysLeft(): number[];
  40467. /**
  40468. * Set the keys for camera movement left.
  40469. */
  40470. set keysLeft(value: number[]);
  40471. /**
  40472. * Set the keys for camera movement right.
  40473. */
  40474. get keysRight(): number[];
  40475. /**
  40476. * Set the keys for camera movement right.
  40477. */
  40478. set keysRight(value: number[]);
  40479. /**
  40480. * Event raised when the camera collides with a mesh in the scene.
  40481. */
  40482. onCollide: (collidedMesh: AbstractMesh) => void;
  40483. private _collider;
  40484. private _needMoveForGravity;
  40485. private _oldPosition;
  40486. private _diffPosition;
  40487. private _newPosition;
  40488. /** @hidden */
  40489. _localDirection: Vector3;
  40490. /** @hidden */
  40491. _transformedDirection: Vector3;
  40492. /**
  40493. * Instantiates a FlyCamera.
  40494. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40495. * such as in a 3D Space Shooter or a Flight Simulator.
  40496. * @param name Define the name of the camera in the scene.
  40497. * @param position Define the starting position of the camera in the scene.
  40498. * @param scene Define the scene the camera belongs to.
  40499. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40500. */
  40501. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40502. /**
  40503. * Attach a control to the HTML DOM element.
  40504. * @param element Defines the element that listens to the input events.
  40505. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40506. */
  40507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40508. /**
  40509. * Detach a control from the HTML DOM element.
  40510. * The camera will stop reacting to that input.
  40511. * @param element Defines the element that listens to the input events.
  40512. */
  40513. detachControl(element: HTMLElement): void;
  40514. private _collisionMask;
  40515. /**
  40516. * Get the mask that the camera ignores in collision events.
  40517. */
  40518. get collisionMask(): number;
  40519. /**
  40520. * Set the mask that the camera ignores in collision events.
  40521. */
  40522. set collisionMask(mask: number);
  40523. /** @hidden */
  40524. _collideWithWorld(displacement: Vector3): void;
  40525. /** @hidden */
  40526. private _onCollisionPositionChange;
  40527. /** @hidden */
  40528. _checkInputs(): void;
  40529. /** @hidden */
  40530. _decideIfNeedsToMove(): boolean;
  40531. /** @hidden */
  40532. _updatePosition(): void;
  40533. /**
  40534. * Restore the Roll to its target value at the rate specified.
  40535. * @param rate - Higher means slower restoring.
  40536. * @hidden
  40537. */
  40538. restoreRoll(rate: number): void;
  40539. /**
  40540. * Destroy the camera and release the current resources held by it.
  40541. */
  40542. dispose(): void;
  40543. /**
  40544. * Get the current object class name.
  40545. * @returns the class name.
  40546. */
  40547. getClassName(): string;
  40548. }
  40549. }
  40550. declare module BABYLON {
  40551. /**
  40552. * Listen to keyboard events to control the camera.
  40553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40554. */
  40555. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40556. /**
  40557. * Defines the camera the input is attached to.
  40558. */
  40559. camera: FlyCamera;
  40560. /**
  40561. * The list of keyboard keys used to control the forward move of the camera.
  40562. */
  40563. keysForward: number[];
  40564. /**
  40565. * The list of keyboard keys used to control the backward move of the camera.
  40566. */
  40567. keysBackward: number[];
  40568. /**
  40569. * The list of keyboard keys used to control the forward move of the camera.
  40570. */
  40571. keysUp: number[];
  40572. /**
  40573. * The list of keyboard keys used to control the backward move of the camera.
  40574. */
  40575. keysDown: number[];
  40576. /**
  40577. * The list of keyboard keys used to control the right strafe move of the camera.
  40578. */
  40579. keysRight: number[];
  40580. /**
  40581. * The list of keyboard keys used to control the left strafe move of the camera.
  40582. */
  40583. keysLeft: number[];
  40584. private _keys;
  40585. private _onCanvasBlurObserver;
  40586. private _onKeyboardObserver;
  40587. private _engine;
  40588. private _scene;
  40589. /**
  40590. * Attach the input controls to a specific dom element to get the input from.
  40591. * @param element Defines the element the controls should be listened from
  40592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40593. */
  40594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40595. /**
  40596. * Detach the current controls from the specified dom element.
  40597. * @param element Defines the element to stop listening the inputs from
  40598. */
  40599. detachControl(element: Nullable<HTMLElement>): void;
  40600. /**
  40601. * Gets the class name of the current intput.
  40602. * @returns the class name
  40603. */
  40604. getClassName(): string;
  40605. /** @hidden */
  40606. _onLostFocus(e: FocusEvent): void;
  40607. /**
  40608. * Get the friendly name associated with the input class.
  40609. * @returns the input friendly name
  40610. */
  40611. getSimpleName(): string;
  40612. /**
  40613. * Update the current camera state depending on the inputs that have been used this frame.
  40614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40615. */
  40616. checkInputs(): void;
  40617. }
  40618. }
  40619. declare module BABYLON {
  40620. /**
  40621. * Manage the mouse wheel inputs to control a follow camera.
  40622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40623. */
  40624. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40625. /**
  40626. * Defines the camera the input is attached to.
  40627. */
  40628. camera: FollowCamera;
  40629. /**
  40630. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40631. */
  40632. axisControlRadius: boolean;
  40633. /**
  40634. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40635. */
  40636. axisControlHeight: boolean;
  40637. /**
  40638. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40639. */
  40640. axisControlRotation: boolean;
  40641. /**
  40642. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40643. * relation to mouseWheel events.
  40644. */
  40645. wheelPrecision: number;
  40646. /**
  40647. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40648. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40649. */
  40650. wheelDeltaPercentage: number;
  40651. private _wheel;
  40652. private _observer;
  40653. /**
  40654. * Attach the input controls to a specific dom element to get the input from.
  40655. * @param element Defines the element the controls should be listened from
  40656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40657. */
  40658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40659. /**
  40660. * Detach the current controls from the specified dom element.
  40661. * @param element Defines the element to stop listening the inputs from
  40662. */
  40663. detachControl(element: Nullable<HTMLElement>): void;
  40664. /**
  40665. * Gets the class name of the current intput.
  40666. * @returns the class name
  40667. */
  40668. getClassName(): string;
  40669. /**
  40670. * Get the friendly name associated with the input class.
  40671. * @returns the input friendly name
  40672. */
  40673. getSimpleName(): string;
  40674. }
  40675. }
  40676. declare module BABYLON {
  40677. /**
  40678. * Manage the pointers inputs to control an follow camera.
  40679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40680. */
  40681. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40682. /**
  40683. * Defines the camera the input is attached to.
  40684. */
  40685. camera: FollowCamera;
  40686. /**
  40687. * Gets the class name of the current input.
  40688. * @returns the class name
  40689. */
  40690. getClassName(): string;
  40691. /**
  40692. * Defines the pointer angular sensibility along the X axis or how fast is
  40693. * the camera rotating.
  40694. * A negative number will reverse the axis direction.
  40695. */
  40696. angularSensibilityX: number;
  40697. /**
  40698. * Defines the pointer angular sensibility along the Y axis or how fast is
  40699. * the camera rotating.
  40700. * A negative number will reverse the axis direction.
  40701. */
  40702. angularSensibilityY: number;
  40703. /**
  40704. * Defines the pointer pinch precision or how fast is the camera zooming.
  40705. * A negative number will reverse the axis direction.
  40706. */
  40707. pinchPrecision: number;
  40708. /**
  40709. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40710. * from 0.
  40711. * It defines the percentage of current camera.radius to use as delta when
  40712. * pinch zoom is used.
  40713. */
  40714. pinchDeltaPercentage: number;
  40715. /**
  40716. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40717. */
  40718. axisXControlRadius: boolean;
  40719. /**
  40720. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40721. */
  40722. axisXControlHeight: boolean;
  40723. /**
  40724. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40725. */
  40726. axisXControlRotation: boolean;
  40727. /**
  40728. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40729. */
  40730. axisYControlRadius: boolean;
  40731. /**
  40732. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40733. */
  40734. axisYControlHeight: boolean;
  40735. /**
  40736. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40737. */
  40738. axisYControlRotation: boolean;
  40739. /**
  40740. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40741. */
  40742. axisPinchControlRadius: boolean;
  40743. /**
  40744. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40745. */
  40746. axisPinchControlHeight: boolean;
  40747. /**
  40748. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40749. */
  40750. axisPinchControlRotation: boolean;
  40751. /**
  40752. * Log error messages if basic misconfiguration has occurred.
  40753. */
  40754. warningEnable: boolean;
  40755. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40756. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40757. private _warningCounter;
  40758. private _warning;
  40759. }
  40760. }
  40761. declare module BABYLON {
  40762. /**
  40763. * Default Inputs manager for the FollowCamera.
  40764. * It groups all the default supported inputs for ease of use.
  40765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40766. */
  40767. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40768. /**
  40769. * Instantiates a new FollowCameraInputsManager.
  40770. * @param camera Defines the camera the inputs belong to
  40771. */
  40772. constructor(camera: FollowCamera);
  40773. /**
  40774. * Add keyboard input support to the input manager.
  40775. * @returns the current input manager
  40776. */
  40777. addKeyboard(): FollowCameraInputsManager;
  40778. /**
  40779. * Add mouse wheel input support to the input manager.
  40780. * @returns the current input manager
  40781. */
  40782. addMouseWheel(): FollowCameraInputsManager;
  40783. /**
  40784. * Add pointers input support to the input manager.
  40785. * @returns the current input manager
  40786. */
  40787. addPointers(): FollowCameraInputsManager;
  40788. /**
  40789. * Add orientation input support to the input manager.
  40790. * @returns the current input manager
  40791. */
  40792. addVRDeviceOrientation(): FollowCameraInputsManager;
  40793. }
  40794. }
  40795. declare module BABYLON {
  40796. /**
  40797. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40798. * an arc rotate version arcFollowCamera are available.
  40799. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40800. */
  40801. export class FollowCamera extends TargetCamera {
  40802. /**
  40803. * Distance the follow camera should follow an object at
  40804. */
  40805. radius: number;
  40806. /**
  40807. * Minimum allowed distance of the camera to the axis of rotation
  40808. * (The camera can not get closer).
  40809. * This can help limiting how the Camera is able to move in the scene.
  40810. */
  40811. lowerRadiusLimit: Nullable<number>;
  40812. /**
  40813. * Maximum allowed distance of the camera to the axis of rotation
  40814. * (The camera can not get further).
  40815. * This can help limiting how the Camera is able to move in the scene.
  40816. */
  40817. upperRadiusLimit: Nullable<number>;
  40818. /**
  40819. * Define a rotation offset between the camera and the object it follows
  40820. */
  40821. rotationOffset: number;
  40822. /**
  40823. * Minimum allowed angle to camera position relative to target object.
  40824. * This can help limiting how the Camera is able to move in the scene.
  40825. */
  40826. lowerRotationOffsetLimit: Nullable<number>;
  40827. /**
  40828. * Maximum allowed angle to camera position relative to target object.
  40829. * This can help limiting how the Camera is able to move in the scene.
  40830. */
  40831. upperRotationOffsetLimit: Nullable<number>;
  40832. /**
  40833. * Define a height offset between the camera and the object it follows.
  40834. * It can help following an object from the top (like a car chaing a plane)
  40835. */
  40836. heightOffset: number;
  40837. /**
  40838. * Minimum allowed height of camera position relative to target object.
  40839. * This can help limiting how the Camera is able to move in the scene.
  40840. */
  40841. lowerHeightOffsetLimit: Nullable<number>;
  40842. /**
  40843. * Maximum allowed height of camera position relative to target object.
  40844. * This can help limiting how the Camera is able to move in the scene.
  40845. */
  40846. upperHeightOffsetLimit: Nullable<number>;
  40847. /**
  40848. * Define how fast the camera can accelerate to follow it s target.
  40849. */
  40850. cameraAcceleration: number;
  40851. /**
  40852. * Define the speed limit of the camera following an object.
  40853. */
  40854. maxCameraSpeed: number;
  40855. /**
  40856. * Define the target of the camera.
  40857. */
  40858. lockedTarget: Nullable<AbstractMesh>;
  40859. /**
  40860. * Defines the input associated with the camera.
  40861. */
  40862. inputs: FollowCameraInputsManager;
  40863. /**
  40864. * Instantiates the follow camera.
  40865. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40866. * @param name Define the name of the camera in the scene
  40867. * @param position Define the position of the camera
  40868. * @param scene Define the scene the camera belong to
  40869. * @param lockedTarget Define the target of the camera
  40870. */
  40871. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40872. private _follow;
  40873. /**
  40874. * Attached controls to the current camera.
  40875. * @param element Defines the element the controls should be listened from
  40876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40877. */
  40878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40879. /**
  40880. * Detach the current controls from the camera.
  40881. * The camera will stop reacting to inputs.
  40882. * @param element Defines the element to stop listening the inputs from
  40883. */
  40884. detachControl(element: HTMLElement): void;
  40885. /** @hidden */
  40886. _checkInputs(): void;
  40887. private _checkLimits;
  40888. /**
  40889. * Gets the camera class name.
  40890. * @returns the class name
  40891. */
  40892. getClassName(): string;
  40893. }
  40894. /**
  40895. * Arc Rotate version of the follow camera.
  40896. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40897. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40898. */
  40899. export class ArcFollowCamera extends TargetCamera {
  40900. /** The longitudinal angle of the camera */
  40901. alpha: number;
  40902. /** The latitudinal angle of the camera */
  40903. beta: number;
  40904. /** The radius of the camera from its target */
  40905. radius: number;
  40906. /** Define the camera target (the messh it should follow) */
  40907. target: Nullable<AbstractMesh>;
  40908. private _cartesianCoordinates;
  40909. /**
  40910. * Instantiates a new ArcFollowCamera
  40911. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40912. * @param name Define the name of the camera
  40913. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40914. * @param beta Define the rotation angle of the camera around the elevation axis
  40915. * @param radius Define the radius of the camera from its target point
  40916. * @param target Define the target of the camera
  40917. * @param scene Define the scene the camera belongs to
  40918. */
  40919. constructor(name: string,
  40920. /** The longitudinal angle of the camera */
  40921. alpha: number,
  40922. /** The latitudinal angle of the camera */
  40923. beta: number,
  40924. /** The radius of the camera from its target */
  40925. radius: number,
  40926. /** Define the camera target (the messh it should follow) */
  40927. target: Nullable<AbstractMesh>, scene: Scene);
  40928. private _follow;
  40929. /** @hidden */
  40930. _checkInputs(): void;
  40931. /**
  40932. * Returns the class name of the object.
  40933. * It is mostly used internally for serialization purposes.
  40934. */
  40935. getClassName(): string;
  40936. }
  40937. }
  40938. declare module BABYLON {
  40939. /**
  40940. * Manage the keyboard inputs to control the movement of a follow camera.
  40941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40942. */
  40943. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40944. /**
  40945. * Defines the camera the input is attached to.
  40946. */
  40947. camera: FollowCamera;
  40948. /**
  40949. * Defines the list of key codes associated with the up action (increase heightOffset)
  40950. */
  40951. keysHeightOffsetIncr: number[];
  40952. /**
  40953. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40954. */
  40955. keysHeightOffsetDecr: number[];
  40956. /**
  40957. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40958. */
  40959. keysHeightOffsetModifierAlt: boolean;
  40960. /**
  40961. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40962. */
  40963. keysHeightOffsetModifierCtrl: boolean;
  40964. /**
  40965. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40966. */
  40967. keysHeightOffsetModifierShift: boolean;
  40968. /**
  40969. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40970. */
  40971. keysRotationOffsetIncr: number[];
  40972. /**
  40973. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40974. */
  40975. keysRotationOffsetDecr: number[];
  40976. /**
  40977. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40978. */
  40979. keysRotationOffsetModifierAlt: boolean;
  40980. /**
  40981. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40982. */
  40983. keysRotationOffsetModifierCtrl: boolean;
  40984. /**
  40985. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40986. */
  40987. keysRotationOffsetModifierShift: boolean;
  40988. /**
  40989. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40990. */
  40991. keysRadiusIncr: number[];
  40992. /**
  40993. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40994. */
  40995. keysRadiusDecr: number[];
  40996. /**
  40997. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40998. */
  40999. keysRadiusModifierAlt: boolean;
  41000. /**
  41001. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41002. */
  41003. keysRadiusModifierCtrl: boolean;
  41004. /**
  41005. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41006. */
  41007. keysRadiusModifierShift: boolean;
  41008. /**
  41009. * Defines the rate of change of heightOffset.
  41010. */
  41011. heightSensibility: number;
  41012. /**
  41013. * Defines the rate of change of rotationOffset.
  41014. */
  41015. rotationSensibility: number;
  41016. /**
  41017. * Defines the rate of change of radius.
  41018. */
  41019. radiusSensibility: number;
  41020. private _keys;
  41021. private _ctrlPressed;
  41022. private _altPressed;
  41023. private _shiftPressed;
  41024. private _onCanvasBlurObserver;
  41025. private _onKeyboardObserver;
  41026. private _engine;
  41027. private _scene;
  41028. /**
  41029. * Attach the input controls to a specific dom element to get the input from.
  41030. * @param element Defines the element the controls should be listened from
  41031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41032. */
  41033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41034. /**
  41035. * Detach the current controls from the specified dom element.
  41036. * @param element Defines the element to stop listening the inputs from
  41037. */
  41038. detachControl(element: Nullable<HTMLElement>): void;
  41039. /**
  41040. * Update the current camera state depending on the inputs that have been used this frame.
  41041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41042. */
  41043. checkInputs(): void;
  41044. /**
  41045. * Gets the class name of the current input.
  41046. * @returns the class name
  41047. */
  41048. getClassName(): string;
  41049. /**
  41050. * Get the friendly name associated with the input class.
  41051. * @returns the input friendly name
  41052. */
  41053. getSimpleName(): string;
  41054. /**
  41055. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41056. * allow modification of the heightOffset value.
  41057. */
  41058. private _modifierHeightOffset;
  41059. /**
  41060. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41061. * allow modification of the rotationOffset value.
  41062. */
  41063. private _modifierRotationOffset;
  41064. /**
  41065. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41066. * allow modification of the radius value.
  41067. */
  41068. private _modifierRadius;
  41069. }
  41070. }
  41071. declare module BABYLON {
  41072. interface FreeCameraInputsManager {
  41073. /**
  41074. * @hidden
  41075. */
  41076. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41077. /**
  41078. * Add orientation input support to the input manager.
  41079. * @returns the current input manager
  41080. */
  41081. addDeviceOrientation(): FreeCameraInputsManager;
  41082. }
  41083. /**
  41084. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41085. * Screen rotation is taken into account.
  41086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41087. */
  41088. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41089. private _camera;
  41090. private _screenOrientationAngle;
  41091. private _constantTranform;
  41092. private _screenQuaternion;
  41093. private _alpha;
  41094. private _beta;
  41095. private _gamma;
  41096. /**
  41097. * Can be used to detect if a device orientation sensor is available on a device
  41098. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41099. * @returns a promise that will resolve on orientation change
  41100. */
  41101. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41102. /**
  41103. * @hidden
  41104. */
  41105. _onDeviceOrientationChangedObservable: Observable<void>;
  41106. /**
  41107. * Instantiates a new input
  41108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41109. */
  41110. constructor();
  41111. /**
  41112. * Define the camera controlled by the input.
  41113. */
  41114. get camera(): FreeCamera;
  41115. set camera(camera: FreeCamera);
  41116. /**
  41117. * Attach the input controls to a specific dom element to get the input from.
  41118. * @param element Defines the element the controls should be listened from
  41119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41120. */
  41121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41122. private _orientationChanged;
  41123. private _deviceOrientation;
  41124. /**
  41125. * Detach the current controls from the specified dom element.
  41126. * @param element Defines the element to stop listening the inputs from
  41127. */
  41128. detachControl(element: Nullable<HTMLElement>): void;
  41129. /**
  41130. * Update the current camera state depending on the inputs that have been used this frame.
  41131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41132. */
  41133. checkInputs(): void;
  41134. /**
  41135. * Gets the class name of the current intput.
  41136. * @returns the class name
  41137. */
  41138. getClassName(): string;
  41139. /**
  41140. * Get the friendly name associated with the input class.
  41141. * @returns the input friendly name
  41142. */
  41143. getSimpleName(): string;
  41144. }
  41145. }
  41146. declare module BABYLON {
  41147. /**
  41148. * Manage the gamepad inputs to control a free camera.
  41149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41150. */
  41151. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41152. /**
  41153. * Define the camera the input is attached to.
  41154. */
  41155. camera: FreeCamera;
  41156. /**
  41157. * Define the Gamepad controlling the input
  41158. */
  41159. gamepad: Nullable<Gamepad>;
  41160. /**
  41161. * Defines the gamepad rotation sensiblity.
  41162. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41163. */
  41164. gamepadAngularSensibility: number;
  41165. /**
  41166. * Defines the gamepad move sensiblity.
  41167. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41168. */
  41169. gamepadMoveSensibility: number;
  41170. private _yAxisScale;
  41171. /**
  41172. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41173. */
  41174. get invertYAxis(): boolean;
  41175. set invertYAxis(value: boolean);
  41176. private _onGamepadConnectedObserver;
  41177. private _onGamepadDisconnectedObserver;
  41178. private _cameraTransform;
  41179. private _deltaTransform;
  41180. private _vector3;
  41181. private _vector2;
  41182. /**
  41183. * Attach the input controls to a specific dom element to get the input from.
  41184. * @param element Defines the element the controls should be listened from
  41185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41186. */
  41187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41188. /**
  41189. * Detach the current controls from the specified dom element.
  41190. * @param element Defines the element to stop listening the inputs from
  41191. */
  41192. detachControl(element: Nullable<HTMLElement>): void;
  41193. /**
  41194. * Update the current camera state depending on the inputs that have been used this frame.
  41195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41196. */
  41197. checkInputs(): void;
  41198. /**
  41199. * Gets the class name of the current intput.
  41200. * @returns the class name
  41201. */
  41202. getClassName(): string;
  41203. /**
  41204. * Get the friendly name associated with the input class.
  41205. * @returns the input friendly name
  41206. */
  41207. getSimpleName(): string;
  41208. }
  41209. }
  41210. declare module BABYLON {
  41211. /**
  41212. * Defines the potential axis of a Joystick
  41213. */
  41214. export enum JoystickAxis {
  41215. /** X axis */
  41216. X = 0,
  41217. /** Y axis */
  41218. Y = 1,
  41219. /** Z axis */
  41220. Z = 2
  41221. }
  41222. /**
  41223. * Class used to define virtual joystick (used in touch mode)
  41224. */
  41225. export class VirtualJoystick {
  41226. /**
  41227. * Gets or sets a boolean indicating that left and right values must be inverted
  41228. */
  41229. reverseLeftRight: boolean;
  41230. /**
  41231. * Gets or sets a boolean indicating that up and down values must be inverted
  41232. */
  41233. reverseUpDown: boolean;
  41234. /**
  41235. * Gets the offset value for the position (ie. the change of the position value)
  41236. */
  41237. deltaPosition: Vector3;
  41238. /**
  41239. * Gets a boolean indicating if the virtual joystick was pressed
  41240. */
  41241. pressed: boolean;
  41242. /**
  41243. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41244. */
  41245. static Canvas: Nullable<HTMLCanvasElement>;
  41246. private static _globalJoystickIndex;
  41247. private static vjCanvasContext;
  41248. private static vjCanvasWidth;
  41249. private static vjCanvasHeight;
  41250. private static halfWidth;
  41251. private _action;
  41252. private _axisTargetedByLeftAndRight;
  41253. private _axisTargetedByUpAndDown;
  41254. private _joystickSensibility;
  41255. private _inversedSensibility;
  41256. private _joystickPointerID;
  41257. private _joystickColor;
  41258. private _joystickPointerPos;
  41259. private _joystickPreviousPointerPos;
  41260. private _joystickPointerStartPos;
  41261. private _deltaJoystickVector;
  41262. private _leftJoystick;
  41263. private _touches;
  41264. private _onPointerDownHandlerRef;
  41265. private _onPointerMoveHandlerRef;
  41266. private _onPointerUpHandlerRef;
  41267. private _onResize;
  41268. /**
  41269. * Creates a new virtual joystick
  41270. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41271. */
  41272. constructor(leftJoystick?: boolean);
  41273. /**
  41274. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41275. * @param newJoystickSensibility defines the new sensibility
  41276. */
  41277. setJoystickSensibility(newJoystickSensibility: number): void;
  41278. private _onPointerDown;
  41279. private _onPointerMove;
  41280. private _onPointerUp;
  41281. /**
  41282. * Change the color of the virtual joystick
  41283. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41284. */
  41285. setJoystickColor(newColor: string): void;
  41286. /**
  41287. * Defines a callback to call when the joystick is touched
  41288. * @param action defines the callback
  41289. */
  41290. setActionOnTouch(action: () => any): void;
  41291. /**
  41292. * Defines which axis you'd like to control for left & right
  41293. * @param axis defines the axis to use
  41294. */
  41295. setAxisForLeftRight(axis: JoystickAxis): void;
  41296. /**
  41297. * Defines which axis you'd like to control for up & down
  41298. * @param axis defines the axis to use
  41299. */
  41300. setAxisForUpDown(axis: JoystickAxis): void;
  41301. private _drawVirtualJoystick;
  41302. /**
  41303. * Release internal HTML canvas
  41304. */
  41305. releaseCanvas(): void;
  41306. }
  41307. }
  41308. declare module BABYLON {
  41309. interface FreeCameraInputsManager {
  41310. /**
  41311. * Add virtual joystick input support to the input manager.
  41312. * @returns the current input manager
  41313. */
  41314. addVirtualJoystick(): FreeCameraInputsManager;
  41315. }
  41316. /**
  41317. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41319. */
  41320. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41321. /**
  41322. * Defines the camera the input is attached to.
  41323. */
  41324. camera: FreeCamera;
  41325. private _leftjoystick;
  41326. private _rightjoystick;
  41327. /**
  41328. * Gets the left stick of the virtual joystick.
  41329. * @returns The virtual Joystick
  41330. */
  41331. getLeftJoystick(): VirtualJoystick;
  41332. /**
  41333. * Gets the right stick of the virtual joystick.
  41334. * @returns The virtual Joystick
  41335. */
  41336. getRightJoystick(): VirtualJoystick;
  41337. /**
  41338. * Update the current camera state depending on the inputs that have been used this frame.
  41339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41340. */
  41341. checkInputs(): void;
  41342. /**
  41343. * Attach the input controls to a specific dom element to get the input from.
  41344. * @param element Defines the element the controls should be listened from
  41345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41346. */
  41347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41348. /**
  41349. * Detach the current controls from the specified dom element.
  41350. * @param element Defines the element to stop listening the inputs from
  41351. */
  41352. detachControl(element: Nullable<HTMLElement>): void;
  41353. /**
  41354. * Gets the class name of the current intput.
  41355. * @returns the class name
  41356. */
  41357. getClassName(): string;
  41358. /**
  41359. * Get the friendly name associated with the input class.
  41360. * @returns the input friendly name
  41361. */
  41362. getSimpleName(): string;
  41363. }
  41364. }
  41365. declare module BABYLON {
  41366. /**
  41367. * This represents a FPS type of camera controlled by touch.
  41368. * This is like a universal camera minus the Gamepad controls.
  41369. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41370. */
  41371. export class TouchCamera extends FreeCamera {
  41372. /**
  41373. * Defines the touch sensibility for rotation.
  41374. * The higher the faster.
  41375. */
  41376. get touchAngularSensibility(): number;
  41377. set touchAngularSensibility(value: number);
  41378. /**
  41379. * Defines the touch sensibility for move.
  41380. * The higher the faster.
  41381. */
  41382. get touchMoveSensibility(): number;
  41383. set touchMoveSensibility(value: number);
  41384. /**
  41385. * Instantiates a new touch camera.
  41386. * This represents a FPS type of camera controlled by touch.
  41387. * This is like a universal camera minus the Gamepad controls.
  41388. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41389. * @param name Define the name of the camera in the scene
  41390. * @param position Define the start position of the camera in the scene
  41391. * @param scene Define the scene the camera belongs to
  41392. */
  41393. constructor(name: string, position: Vector3, scene: Scene);
  41394. /**
  41395. * Gets the current object class name.
  41396. * @return the class name
  41397. */
  41398. getClassName(): string;
  41399. /** @hidden */
  41400. _setupInputs(): void;
  41401. }
  41402. }
  41403. declare module BABYLON {
  41404. /**
  41405. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41406. * being tilted forward or back and left or right.
  41407. */
  41408. export class DeviceOrientationCamera extends FreeCamera {
  41409. private _initialQuaternion;
  41410. private _quaternionCache;
  41411. private _tmpDragQuaternion;
  41412. private _disablePointerInputWhenUsingDeviceOrientation;
  41413. /**
  41414. * Creates a new device orientation camera
  41415. * @param name The name of the camera
  41416. * @param position The start position camera
  41417. * @param scene The scene the camera belongs to
  41418. */
  41419. constructor(name: string, position: Vector3, scene: Scene);
  41420. /**
  41421. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41422. */
  41423. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41424. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41425. private _dragFactor;
  41426. /**
  41427. * Enabled turning on the y axis when the orientation sensor is active
  41428. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41429. */
  41430. enableHorizontalDragging(dragFactor?: number): void;
  41431. /**
  41432. * Gets the current instance class name ("DeviceOrientationCamera").
  41433. * This helps avoiding instanceof at run time.
  41434. * @returns the class name
  41435. */
  41436. getClassName(): string;
  41437. /**
  41438. * @hidden
  41439. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41440. */
  41441. _checkInputs(): void;
  41442. /**
  41443. * Reset the camera to its default orientation on the specified axis only.
  41444. * @param axis The axis to reset
  41445. */
  41446. resetToCurrentRotation(axis?: Axis): void;
  41447. }
  41448. }
  41449. declare module BABYLON {
  41450. /**
  41451. * Defines supported buttons for XBox360 compatible gamepads
  41452. */
  41453. export enum Xbox360Button {
  41454. /** A */
  41455. A = 0,
  41456. /** B */
  41457. B = 1,
  41458. /** X */
  41459. X = 2,
  41460. /** Y */
  41461. Y = 3,
  41462. /** Left button */
  41463. LB = 4,
  41464. /** Right button */
  41465. RB = 5,
  41466. /** Back */
  41467. Back = 8,
  41468. /** Start */
  41469. Start = 9,
  41470. /** Left stick */
  41471. LeftStick = 10,
  41472. /** Right stick */
  41473. RightStick = 11
  41474. }
  41475. /** Defines values for XBox360 DPad */
  41476. export enum Xbox360Dpad {
  41477. /** Up */
  41478. Up = 12,
  41479. /** Down */
  41480. Down = 13,
  41481. /** Left */
  41482. Left = 14,
  41483. /** Right */
  41484. Right = 15
  41485. }
  41486. /**
  41487. * Defines a XBox360 gamepad
  41488. */
  41489. export class Xbox360Pad extends Gamepad {
  41490. private _leftTrigger;
  41491. private _rightTrigger;
  41492. private _onlefttriggerchanged;
  41493. private _onrighttriggerchanged;
  41494. private _onbuttondown;
  41495. private _onbuttonup;
  41496. private _ondpaddown;
  41497. private _ondpadup;
  41498. /** Observable raised when a button is pressed */
  41499. onButtonDownObservable: Observable<Xbox360Button>;
  41500. /** Observable raised when a button is released */
  41501. onButtonUpObservable: Observable<Xbox360Button>;
  41502. /** Observable raised when a pad is pressed */
  41503. onPadDownObservable: Observable<Xbox360Dpad>;
  41504. /** Observable raised when a pad is released */
  41505. onPadUpObservable: Observable<Xbox360Dpad>;
  41506. private _buttonA;
  41507. private _buttonB;
  41508. private _buttonX;
  41509. private _buttonY;
  41510. private _buttonBack;
  41511. private _buttonStart;
  41512. private _buttonLB;
  41513. private _buttonRB;
  41514. private _buttonLeftStick;
  41515. private _buttonRightStick;
  41516. private _dPadUp;
  41517. private _dPadDown;
  41518. private _dPadLeft;
  41519. private _dPadRight;
  41520. private _isXboxOnePad;
  41521. /**
  41522. * Creates a new XBox360 gamepad object
  41523. * @param id defines the id of this gamepad
  41524. * @param index defines its index
  41525. * @param gamepad defines the internal HTML gamepad object
  41526. * @param xboxOne defines if it is a XBox One gamepad
  41527. */
  41528. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41529. /**
  41530. * Defines the callback to call when left trigger is pressed
  41531. * @param callback defines the callback to use
  41532. */
  41533. onlefttriggerchanged(callback: (value: number) => void): void;
  41534. /**
  41535. * Defines the callback to call when right trigger is pressed
  41536. * @param callback defines the callback to use
  41537. */
  41538. onrighttriggerchanged(callback: (value: number) => void): void;
  41539. /**
  41540. * Gets the left trigger value
  41541. */
  41542. get leftTrigger(): number;
  41543. /**
  41544. * Sets the left trigger value
  41545. */
  41546. set leftTrigger(newValue: number);
  41547. /**
  41548. * Gets the right trigger value
  41549. */
  41550. get rightTrigger(): number;
  41551. /**
  41552. * Sets the right trigger value
  41553. */
  41554. set rightTrigger(newValue: number);
  41555. /**
  41556. * Defines the callback to call when a button is pressed
  41557. * @param callback defines the callback to use
  41558. */
  41559. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41560. /**
  41561. * Defines the callback to call when a button is released
  41562. * @param callback defines the callback to use
  41563. */
  41564. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41565. /**
  41566. * Defines the callback to call when a pad is pressed
  41567. * @param callback defines the callback to use
  41568. */
  41569. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41570. /**
  41571. * Defines the callback to call when a pad is released
  41572. * @param callback defines the callback to use
  41573. */
  41574. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41575. private _setButtonValue;
  41576. private _setDPadValue;
  41577. /**
  41578. * Gets the value of the `A` button
  41579. */
  41580. get buttonA(): number;
  41581. /**
  41582. * Sets the value of the `A` button
  41583. */
  41584. set buttonA(value: number);
  41585. /**
  41586. * Gets the value of the `B` button
  41587. */
  41588. get buttonB(): number;
  41589. /**
  41590. * Sets the value of the `B` button
  41591. */
  41592. set buttonB(value: number);
  41593. /**
  41594. * Gets the value of the `X` button
  41595. */
  41596. get buttonX(): number;
  41597. /**
  41598. * Sets the value of the `X` button
  41599. */
  41600. set buttonX(value: number);
  41601. /**
  41602. * Gets the value of the `Y` button
  41603. */
  41604. get buttonY(): number;
  41605. /**
  41606. * Sets the value of the `Y` button
  41607. */
  41608. set buttonY(value: number);
  41609. /**
  41610. * Gets the value of the `Start` button
  41611. */
  41612. get buttonStart(): number;
  41613. /**
  41614. * Sets the value of the `Start` button
  41615. */
  41616. set buttonStart(value: number);
  41617. /**
  41618. * Gets the value of the `Back` button
  41619. */
  41620. get buttonBack(): number;
  41621. /**
  41622. * Sets the value of the `Back` button
  41623. */
  41624. set buttonBack(value: number);
  41625. /**
  41626. * Gets the value of the `Left` button
  41627. */
  41628. get buttonLB(): number;
  41629. /**
  41630. * Sets the value of the `Left` button
  41631. */
  41632. set buttonLB(value: number);
  41633. /**
  41634. * Gets the value of the `Right` button
  41635. */
  41636. get buttonRB(): number;
  41637. /**
  41638. * Sets the value of the `Right` button
  41639. */
  41640. set buttonRB(value: number);
  41641. /**
  41642. * Gets the value of the Left joystick
  41643. */
  41644. get buttonLeftStick(): number;
  41645. /**
  41646. * Sets the value of the Left joystick
  41647. */
  41648. set buttonLeftStick(value: number);
  41649. /**
  41650. * Gets the value of the Right joystick
  41651. */
  41652. get buttonRightStick(): number;
  41653. /**
  41654. * Sets the value of the Right joystick
  41655. */
  41656. set buttonRightStick(value: number);
  41657. /**
  41658. * Gets the value of D-pad up
  41659. */
  41660. get dPadUp(): number;
  41661. /**
  41662. * Sets the value of D-pad up
  41663. */
  41664. set dPadUp(value: number);
  41665. /**
  41666. * Gets the value of D-pad down
  41667. */
  41668. get dPadDown(): number;
  41669. /**
  41670. * Sets the value of D-pad down
  41671. */
  41672. set dPadDown(value: number);
  41673. /**
  41674. * Gets the value of D-pad left
  41675. */
  41676. get dPadLeft(): number;
  41677. /**
  41678. * Sets the value of D-pad left
  41679. */
  41680. set dPadLeft(value: number);
  41681. /**
  41682. * Gets the value of D-pad right
  41683. */
  41684. get dPadRight(): number;
  41685. /**
  41686. * Sets the value of D-pad right
  41687. */
  41688. set dPadRight(value: number);
  41689. /**
  41690. * Force the gamepad to synchronize with device values
  41691. */
  41692. update(): void;
  41693. /**
  41694. * Disposes the gamepad
  41695. */
  41696. dispose(): void;
  41697. }
  41698. }
  41699. declare module BABYLON {
  41700. /**
  41701. * Defines supported buttons for DualShock compatible gamepads
  41702. */
  41703. export enum DualShockButton {
  41704. /** Cross */
  41705. Cross = 0,
  41706. /** Circle */
  41707. Circle = 1,
  41708. /** Square */
  41709. Square = 2,
  41710. /** Triangle */
  41711. Triangle = 3,
  41712. /** L1 */
  41713. L1 = 4,
  41714. /** R1 */
  41715. R1 = 5,
  41716. /** Share */
  41717. Share = 8,
  41718. /** Options */
  41719. Options = 9,
  41720. /** Left stick */
  41721. LeftStick = 10,
  41722. /** Right stick */
  41723. RightStick = 11
  41724. }
  41725. /** Defines values for DualShock DPad */
  41726. export enum DualShockDpad {
  41727. /** Up */
  41728. Up = 12,
  41729. /** Down */
  41730. Down = 13,
  41731. /** Left */
  41732. Left = 14,
  41733. /** Right */
  41734. Right = 15
  41735. }
  41736. /**
  41737. * Defines a DualShock gamepad
  41738. */
  41739. export class DualShockPad extends Gamepad {
  41740. private _leftTrigger;
  41741. private _rightTrigger;
  41742. private _onlefttriggerchanged;
  41743. private _onrighttriggerchanged;
  41744. private _onbuttondown;
  41745. private _onbuttonup;
  41746. private _ondpaddown;
  41747. private _ondpadup;
  41748. /** Observable raised when a button is pressed */
  41749. onButtonDownObservable: Observable<DualShockButton>;
  41750. /** Observable raised when a button is released */
  41751. onButtonUpObservable: Observable<DualShockButton>;
  41752. /** Observable raised when a pad is pressed */
  41753. onPadDownObservable: Observable<DualShockDpad>;
  41754. /** Observable raised when a pad is released */
  41755. onPadUpObservable: Observable<DualShockDpad>;
  41756. private _buttonCross;
  41757. private _buttonCircle;
  41758. private _buttonSquare;
  41759. private _buttonTriangle;
  41760. private _buttonShare;
  41761. private _buttonOptions;
  41762. private _buttonL1;
  41763. private _buttonR1;
  41764. private _buttonLeftStick;
  41765. private _buttonRightStick;
  41766. private _dPadUp;
  41767. private _dPadDown;
  41768. private _dPadLeft;
  41769. private _dPadRight;
  41770. /**
  41771. * Creates a new DualShock gamepad object
  41772. * @param id defines the id of this gamepad
  41773. * @param index defines its index
  41774. * @param gamepad defines the internal HTML gamepad object
  41775. */
  41776. constructor(id: string, index: number, gamepad: any);
  41777. /**
  41778. * Defines the callback to call when left trigger is pressed
  41779. * @param callback defines the callback to use
  41780. */
  41781. onlefttriggerchanged(callback: (value: number) => void): void;
  41782. /**
  41783. * Defines the callback to call when right trigger is pressed
  41784. * @param callback defines the callback to use
  41785. */
  41786. onrighttriggerchanged(callback: (value: number) => void): void;
  41787. /**
  41788. * Gets the left trigger value
  41789. */
  41790. get leftTrigger(): number;
  41791. /**
  41792. * Sets the left trigger value
  41793. */
  41794. set leftTrigger(newValue: number);
  41795. /**
  41796. * Gets the right trigger value
  41797. */
  41798. get rightTrigger(): number;
  41799. /**
  41800. * Sets the right trigger value
  41801. */
  41802. set rightTrigger(newValue: number);
  41803. /**
  41804. * Defines the callback to call when a button is pressed
  41805. * @param callback defines the callback to use
  41806. */
  41807. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41808. /**
  41809. * Defines the callback to call when a button is released
  41810. * @param callback defines the callback to use
  41811. */
  41812. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41813. /**
  41814. * Defines the callback to call when a pad is pressed
  41815. * @param callback defines the callback to use
  41816. */
  41817. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41818. /**
  41819. * Defines the callback to call when a pad is released
  41820. * @param callback defines the callback to use
  41821. */
  41822. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41823. private _setButtonValue;
  41824. private _setDPadValue;
  41825. /**
  41826. * Gets the value of the `Cross` button
  41827. */
  41828. get buttonCross(): number;
  41829. /**
  41830. * Sets the value of the `Cross` button
  41831. */
  41832. set buttonCross(value: number);
  41833. /**
  41834. * Gets the value of the `Circle` button
  41835. */
  41836. get buttonCircle(): number;
  41837. /**
  41838. * Sets the value of the `Circle` button
  41839. */
  41840. set buttonCircle(value: number);
  41841. /**
  41842. * Gets the value of the `Square` button
  41843. */
  41844. get buttonSquare(): number;
  41845. /**
  41846. * Sets the value of the `Square` button
  41847. */
  41848. set buttonSquare(value: number);
  41849. /**
  41850. * Gets the value of the `Triangle` button
  41851. */
  41852. get buttonTriangle(): number;
  41853. /**
  41854. * Sets the value of the `Triangle` button
  41855. */
  41856. set buttonTriangle(value: number);
  41857. /**
  41858. * Gets the value of the `Options` button
  41859. */
  41860. get buttonOptions(): number;
  41861. /**
  41862. * Sets the value of the `Options` button
  41863. */
  41864. set buttonOptions(value: number);
  41865. /**
  41866. * Gets the value of the `Share` button
  41867. */
  41868. get buttonShare(): number;
  41869. /**
  41870. * Sets the value of the `Share` button
  41871. */
  41872. set buttonShare(value: number);
  41873. /**
  41874. * Gets the value of the `L1` button
  41875. */
  41876. get buttonL1(): number;
  41877. /**
  41878. * Sets the value of the `L1` button
  41879. */
  41880. set buttonL1(value: number);
  41881. /**
  41882. * Gets the value of the `R1` button
  41883. */
  41884. get buttonR1(): number;
  41885. /**
  41886. * Sets the value of the `R1` button
  41887. */
  41888. set buttonR1(value: number);
  41889. /**
  41890. * Gets the value of the Left joystick
  41891. */
  41892. get buttonLeftStick(): number;
  41893. /**
  41894. * Sets the value of the Left joystick
  41895. */
  41896. set buttonLeftStick(value: number);
  41897. /**
  41898. * Gets the value of the Right joystick
  41899. */
  41900. get buttonRightStick(): number;
  41901. /**
  41902. * Sets the value of the Right joystick
  41903. */
  41904. set buttonRightStick(value: number);
  41905. /**
  41906. * Gets the value of D-pad up
  41907. */
  41908. get dPadUp(): number;
  41909. /**
  41910. * Sets the value of D-pad up
  41911. */
  41912. set dPadUp(value: number);
  41913. /**
  41914. * Gets the value of D-pad down
  41915. */
  41916. get dPadDown(): number;
  41917. /**
  41918. * Sets the value of D-pad down
  41919. */
  41920. set dPadDown(value: number);
  41921. /**
  41922. * Gets the value of D-pad left
  41923. */
  41924. get dPadLeft(): number;
  41925. /**
  41926. * Sets the value of D-pad left
  41927. */
  41928. set dPadLeft(value: number);
  41929. /**
  41930. * Gets the value of D-pad right
  41931. */
  41932. get dPadRight(): number;
  41933. /**
  41934. * Sets the value of D-pad right
  41935. */
  41936. set dPadRight(value: number);
  41937. /**
  41938. * Force the gamepad to synchronize with device values
  41939. */
  41940. update(): void;
  41941. /**
  41942. * Disposes the gamepad
  41943. */
  41944. dispose(): void;
  41945. }
  41946. }
  41947. declare module BABYLON {
  41948. /**
  41949. * Manager for handling gamepads
  41950. */
  41951. export class GamepadManager {
  41952. private _scene?;
  41953. private _babylonGamepads;
  41954. private _oneGamepadConnected;
  41955. /** @hidden */
  41956. _isMonitoring: boolean;
  41957. private _gamepadEventSupported;
  41958. private _gamepadSupport?;
  41959. /**
  41960. * observable to be triggered when the gamepad controller has been connected
  41961. */
  41962. onGamepadConnectedObservable: Observable<Gamepad>;
  41963. /**
  41964. * observable to be triggered when the gamepad controller has been disconnected
  41965. */
  41966. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41967. private _onGamepadConnectedEvent;
  41968. private _onGamepadDisconnectedEvent;
  41969. /**
  41970. * Initializes the gamepad manager
  41971. * @param _scene BabylonJS scene
  41972. */
  41973. constructor(_scene?: Scene | undefined);
  41974. /**
  41975. * The gamepads in the game pad manager
  41976. */
  41977. get gamepads(): Gamepad[];
  41978. /**
  41979. * Get the gamepad controllers based on type
  41980. * @param type The type of gamepad controller
  41981. * @returns Nullable gamepad
  41982. */
  41983. getGamepadByType(type?: number): Nullable<Gamepad>;
  41984. /**
  41985. * Disposes the gamepad manager
  41986. */
  41987. dispose(): void;
  41988. private _addNewGamepad;
  41989. private _startMonitoringGamepads;
  41990. private _stopMonitoringGamepads;
  41991. /** @hidden */
  41992. _checkGamepadsStatus(): void;
  41993. private _updateGamepadObjects;
  41994. }
  41995. }
  41996. declare module BABYLON {
  41997. interface Scene {
  41998. /** @hidden */
  41999. _gamepadManager: Nullable<GamepadManager>;
  42000. /**
  42001. * Gets the gamepad manager associated with the scene
  42002. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42003. */
  42004. gamepadManager: GamepadManager;
  42005. }
  42006. /**
  42007. * Interface representing a free camera inputs manager
  42008. */
  42009. interface FreeCameraInputsManager {
  42010. /**
  42011. * Adds gamepad input support to the FreeCameraInputsManager.
  42012. * @returns the FreeCameraInputsManager
  42013. */
  42014. addGamepad(): FreeCameraInputsManager;
  42015. }
  42016. /**
  42017. * Interface representing an arc rotate camera inputs manager
  42018. */
  42019. interface ArcRotateCameraInputsManager {
  42020. /**
  42021. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42022. * @returns the camera inputs manager
  42023. */
  42024. addGamepad(): ArcRotateCameraInputsManager;
  42025. }
  42026. /**
  42027. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42028. */
  42029. export class GamepadSystemSceneComponent implements ISceneComponent {
  42030. /**
  42031. * The component name helpfull to identify the component in the list of scene components.
  42032. */
  42033. readonly name: string;
  42034. /**
  42035. * The scene the component belongs to.
  42036. */
  42037. scene: Scene;
  42038. /**
  42039. * Creates a new instance of the component for the given scene
  42040. * @param scene Defines the scene to register the component in
  42041. */
  42042. constructor(scene: Scene);
  42043. /**
  42044. * Registers the component in a given scene
  42045. */
  42046. register(): void;
  42047. /**
  42048. * Rebuilds the elements related to this component in case of
  42049. * context lost for instance.
  42050. */
  42051. rebuild(): void;
  42052. /**
  42053. * Disposes the component and the associated ressources
  42054. */
  42055. dispose(): void;
  42056. private _beforeCameraUpdate;
  42057. }
  42058. }
  42059. declare module BABYLON {
  42060. /**
  42061. * 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,
  42062. * which still works and will still be found in many Playgrounds.
  42063. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42064. */
  42065. export class UniversalCamera extends TouchCamera {
  42066. /**
  42067. * Defines the gamepad rotation sensiblity.
  42068. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42069. */
  42070. get gamepadAngularSensibility(): number;
  42071. set gamepadAngularSensibility(value: number);
  42072. /**
  42073. * Defines the gamepad move sensiblity.
  42074. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42075. */
  42076. get gamepadMoveSensibility(): number;
  42077. set gamepadMoveSensibility(value: number);
  42078. /**
  42079. * 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,
  42080. * which still works and will still be found in many Playgrounds.
  42081. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42082. * @param name Define the name of the camera in the scene
  42083. * @param position Define the start position of the camera in the scene
  42084. * @param scene Define the scene the camera belongs to
  42085. */
  42086. constructor(name: string, position: Vector3, scene: Scene);
  42087. /**
  42088. * Gets the current object class name.
  42089. * @return the class name
  42090. */
  42091. getClassName(): string;
  42092. }
  42093. }
  42094. declare module BABYLON {
  42095. /**
  42096. * This represents a FPS type of camera. This is only here for back compat purpose.
  42097. * Please use the UniversalCamera instead as both are identical.
  42098. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42099. */
  42100. export class GamepadCamera extends UniversalCamera {
  42101. /**
  42102. * Instantiates a new Gamepad Camera
  42103. * This represents a FPS type of camera. This is only here for back compat purpose.
  42104. * Please use the UniversalCamera instead as both are identical.
  42105. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42106. * @param name Define the name of the camera in the scene
  42107. * @param position Define the start position of the camera in the scene
  42108. * @param scene Define the scene the camera belongs to
  42109. */
  42110. constructor(name: string, position: Vector3, scene: Scene);
  42111. /**
  42112. * Gets the current object class name.
  42113. * @return the class name
  42114. */
  42115. getClassName(): string;
  42116. }
  42117. }
  42118. declare module BABYLON {
  42119. /** @hidden */
  42120. export var passPixelShader: {
  42121. name: string;
  42122. shader: string;
  42123. };
  42124. }
  42125. declare module BABYLON {
  42126. /** @hidden */
  42127. export var passCubePixelShader: {
  42128. name: string;
  42129. shader: string;
  42130. };
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * PassPostProcess which produces an output the same as it's input
  42135. */
  42136. export class PassPostProcess extends PostProcess {
  42137. /**
  42138. * Creates the PassPostProcess
  42139. * @param name The name of the effect.
  42140. * @param options The required width/height ratio to downsize to before computing the render pass.
  42141. * @param camera The camera to apply the render pass to.
  42142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42143. * @param engine The engine which the post process will be applied. (default: current engine)
  42144. * @param reusable If the post process can be reused on the same frame. (default: false)
  42145. * @param textureType The type of texture to be used when performing the post processing.
  42146. * @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)
  42147. */
  42148. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42149. }
  42150. /**
  42151. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42152. */
  42153. export class PassCubePostProcess extends PostProcess {
  42154. private _face;
  42155. /**
  42156. * Gets or sets the cube face to display.
  42157. * * 0 is +X
  42158. * * 1 is -X
  42159. * * 2 is +Y
  42160. * * 3 is -Y
  42161. * * 4 is +Z
  42162. * * 5 is -Z
  42163. */
  42164. get face(): number;
  42165. set face(value: number);
  42166. /**
  42167. * Creates the PassCubePostProcess
  42168. * @param name The name of the effect.
  42169. * @param options The required width/height ratio to downsize to before computing the render pass.
  42170. * @param camera The camera to apply the render pass to.
  42171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42172. * @param engine The engine which the post process will be applied. (default: current engine)
  42173. * @param reusable If the post process can be reused on the same frame. (default: false)
  42174. * @param textureType The type of texture to be used when performing the post processing.
  42175. * @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)
  42176. */
  42177. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42178. }
  42179. }
  42180. declare module BABYLON {
  42181. /** @hidden */
  42182. export var anaglyphPixelShader: {
  42183. name: string;
  42184. shader: string;
  42185. };
  42186. }
  42187. declare module BABYLON {
  42188. /**
  42189. * Postprocess used to generate anaglyphic rendering
  42190. */
  42191. export class AnaglyphPostProcess extends PostProcess {
  42192. private _passedProcess;
  42193. /**
  42194. * Creates a new AnaglyphPostProcess
  42195. * @param name defines postprocess name
  42196. * @param options defines creation options or target ratio scale
  42197. * @param rigCameras defines cameras using this postprocess
  42198. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42199. * @param engine defines hosting engine
  42200. * @param reusable defines if the postprocess will be reused multiple times per frame
  42201. */
  42202. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42203. }
  42204. }
  42205. declare module BABYLON {
  42206. /**
  42207. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42208. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42209. */
  42210. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42211. /**
  42212. * Creates a new AnaglyphArcRotateCamera
  42213. * @param name defines camera name
  42214. * @param alpha defines alpha angle (in radians)
  42215. * @param beta defines beta angle (in radians)
  42216. * @param radius defines radius
  42217. * @param target defines camera target
  42218. * @param interaxialDistance defines distance between each color axis
  42219. * @param scene defines the hosting scene
  42220. */
  42221. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42222. /**
  42223. * Gets camera class name
  42224. * @returns AnaglyphArcRotateCamera
  42225. */
  42226. getClassName(): string;
  42227. }
  42228. }
  42229. declare module BABYLON {
  42230. /**
  42231. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42232. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42233. */
  42234. export class AnaglyphFreeCamera extends FreeCamera {
  42235. /**
  42236. * Creates a new AnaglyphFreeCamera
  42237. * @param name defines camera name
  42238. * @param position defines initial position
  42239. * @param interaxialDistance defines distance between each color axis
  42240. * @param scene defines the hosting scene
  42241. */
  42242. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42243. /**
  42244. * Gets camera class name
  42245. * @returns AnaglyphFreeCamera
  42246. */
  42247. getClassName(): string;
  42248. }
  42249. }
  42250. declare module BABYLON {
  42251. /**
  42252. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42253. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42254. */
  42255. export class AnaglyphGamepadCamera extends GamepadCamera {
  42256. /**
  42257. * Creates a new AnaglyphGamepadCamera
  42258. * @param name defines camera name
  42259. * @param position defines initial position
  42260. * @param interaxialDistance defines distance between each color axis
  42261. * @param scene defines the hosting scene
  42262. */
  42263. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42264. /**
  42265. * Gets camera class name
  42266. * @returns AnaglyphGamepadCamera
  42267. */
  42268. getClassName(): string;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42274. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42275. */
  42276. export class AnaglyphUniversalCamera extends UniversalCamera {
  42277. /**
  42278. * Creates a new AnaglyphUniversalCamera
  42279. * @param name defines camera name
  42280. * @param position defines initial position
  42281. * @param interaxialDistance defines distance between each color axis
  42282. * @param scene defines the hosting scene
  42283. */
  42284. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42285. /**
  42286. * Gets camera class name
  42287. * @returns AnaglyphUniversalCamera
  42288. */
  42289. getClassName(): string;
  42290. }
  42291. }
  42292. declare module BABYLON {
  42293. /** @hidden */
  42294. export var stereoscopicInterlacePixelShader: {
  42295. name: string;
  42296. shader: string;
  42297. };
  42298. }
  42299. declare module BABYLON {
  42300. /**
  42301. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42302. */
  42303. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42304. private _stepSize;
  42305. private _passedProcess;
  42306. /**
  42307. * Initializes a StereoscopicInterlacePostProcessI
  42308. * @param name The name of the effect.
  42309. * @param rigCameras The rig cameras to be appled to the post process
  42310. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42311. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42313. * @param engine The engine which the post process will be applied. (default: current engine)
  42314. * @param reusable If the post process can be reused on the same frame. (default: false)
  42315. */
  42316. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42317. }
  42318. /**
  42319. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42320. */
  42321. export class StereoscopicInterlacePostProcess extends PostProcess {
  42322. private _stepSize;
  42323. private _passedProcess;
  42324. /**
  42325. * Initializes a StereoscopicInterlacePostProcess
  42326. * @param name The name of the effect.
  42327. * @param rigCameras The rig cameras to be appled to the post process
  42328. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42330. * @param engine The engine which the post process will be applied. (default: current engine)
  42331. * @param reusable If the post process can be reused on the same frame. (default: false)
  42332. */
  42333. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42334. }
  42335. }
  42336. declare module BABYLON {
  42337. /**
  42338. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42339. * @see http://doc.babylonjs.com/features/cameras
  42340. */
  42341. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42342. /**
  42343. * Creates a new StereoscopicArcRotateCamera
  42344. * @param name defines camera name
  42345. * @param alpha defines alpha angle (in radians)
  42346. * @param beta defines beta angle (in radians)
  42347. * @param radius defines radius
  42348. * @param target defines camera target
  42349. * @param interaxialDistance defines distance between each color axis
  42350. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42351. * @param scene defines the hosting scene
  42352. */
  42353. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42354. /**
  42355. * Gets camera class name
  42356. * @returns StereoscopicArcRotateCamera
  42357. */
  42358. getClassName(): string;
  42359. }
  42360. }
  42361. declare module BABYLON {
  42362. /**
  42363. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42364. * @see http://doc.babylonjs.com/features/cameras
  42365. */
  42366. export class StereoscopicFreeCamera extends FreeCamera {
  42367. /**
  42368. * Creates a new StereoscopicFreeCamera
  42369. * @param name defines camera name
  42370. * @param position defines initial position
  42371. * @param interaxialDistance defines distance between each color axis
  42372. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42373. * @param scene defines the hosting scene
  42374. */
  42375. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42376. /**
  42377. * Gets camera class name
  42378. * @returns StereoscopicFreeCamera
  42379. */
  42380. getClassName(): string;
  42381. }
  42382. }
  42383. declare module BABYLON {
  42384. /**
  42385. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42386. * @see http://doc.babylonjs.com/features/cameras
  42387. */
  42388. export class StereoscopicGamepadCamera extends GamepadCamera {
  42389. /**
  42390. * Creates a new StereoscopicGamepadCamera
  42391. * @param name defines camera name
  42392. * @param position defines initial position
  42393. * @param interaxialDistance defines distance between each color axis
  42394. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42395. * @param scene defines the hosting scene
  42396. */
  42397. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42398. /**
  42399. * Gets camera class name
  42400. * @returns StereoscopicGamepadCamera
  42401. */
  42402. getClassName(): string;
  42403. }
  42404. }
  42405. declare module BABYLON {
  42406. /**
  42407. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42408. * @see http://doc.babylonjs.com/features/cameras
  42409. */
  42410. export class StereoscopicUniversalCamera extends UniversalCamera {
  42411. /**
  42412. * Creates a new StereoscopicUniversalCamera
  42413. * @param name defines camera name
  42414. * @param position defines initial position
  42415. * @param interaxialDistance defines distance between each color axis
  42416. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42417. * @param scene defines the hosting scene
  42418. */
  42419. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42420. /**
  42421. * Gets camera class name
  42422. * @returns StereoscopicUniversalCamera
  42423. */
  42424. getClassName(): string;
  42425. }
  42426. }
  42427. declare module BABYLON {
  42428. /**
  42429. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42430. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42431. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42432. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42433. */
  42434. export class VirtualJoysticksCamera extends FreeCamera {
  42435. /**
  42436. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42437. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42438. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42439. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42440. * @param name Define the name of the camera in the scene
  42441. * @param position Define the start position of the camera in the scene
  42442. * @param scene Define the scene the camera belongs to
  42443. */
  42444. constructor(name: string, position: Vector3, scene: Scene);
  42445. /**
  42446. * Gets the current object class name.
  42447. * @return the class name
  42448. */
  42449. getClassName(): string;
  42450. }
  42451. }
  42452. declare module BABYLON {
  42453. /**
  42454. * This represents all the required metrics to create a VR camera.
  42455. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42456. */
  42457. export class VRCameraMetrics {
  42458. /**
  42459. * Define the horizontal resolution off the screen.
  42460. */
  42461. hResolution: number;
  42462. /**
  42463. * Define the vertical resolution off the screen.
  42464. */
  42465. vResolution: number;
  42466. /**
  42467. * Define the horizontal screen size.
  42468. */
  42469. hScreenSize: number;
  42470. /**
  42471. * Define the vertical screen size.
  42472. */
  42473. vScreenSize: number;
  42474. /**
  42475. * Define the vertical screen center position.
  42476. */
  42477. vScreenCenter: number;
  42478. /**
  42479. * Define the distance of the eyes to the screen.
  42480. */
  42481. eyeToScreenDistance: number;
  42482. /**
  42483. * Define the distance between both lenses
  42484. */
  42485. lensSeparationDistance: number;
  42486. /**
  42487. * Define the distance between both viewer's eyes.
  42488. */
  42489. interpupillaryDistance: number;
  42490. /**
  42491. * Define the distortion factor of the VR postprocess.
  42492. * Please, touch with care.
  42493. */
  42494. distortionK: number[];
  42495. /**
  42496. * Define the chromatic aberration correction factors for the VR post process.
  42497. */
  42498. chromaAbCorrection: number[];
  42499. /**
  42500. * Define the scale factor of the post process.
  42501. * The smaller the better but the slower.
  42502. */
  42503. postProcessScaleFactor: number;
  42504. /**
  42505. * Define an offset for the lens center.
  42506. */
  42507. lensCenterOffset: number;
  42508. /**
  42509. * Define if the current vr camera should compensate the distortion of the lense or not.
  42510. */
  42511. compensateDistortion: boolean;
  42512. /**
  42513. * Defines if multiview should be enabled when rendering (Default: false)
  42514. */
  42515. multiviewEnabled: boolean;
  42516. /**
  42517. * Gets the rendering aspect ratio based on the provided resolutions.
  42518. */
  42519. get aspectRatio(): number;
  42520. /**
  42521. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42522. */
  42523. get aspectRatioFov(): number;
  42524. /**
  42525. * @hidden
  42526. */
  42527. get leftHMatrix(): Matrix;
  42528. /**
  42529. * @hidden
  42530. */
  42531. get rightHMatrix(): Matrix;
  42532. /**
  42533. * @hidden
  42534. */
  42535. get leftPreViewMatrix(): Matrix;
  42536. /**
  42537. * @hidden
  42538. */
  42539. get rightPreViewMatrix(): Matrix;
  42540. /**
  42541. * Get the default VRMetrics based on the most generic setup.
  42542. * @returns the default vr metrics
  42543. */
  42544. static GetDefault(): VRCameraMetrics;
  42545. }
  42546. }
  42547. declare module BABYLON {
  42548. /** @hidden */
  42549. export var vrDistortionCorrectionPixelShader: {
  42550. name: string;
  42551. shader: string;
  42552. };
  42553. }
  42554. declare module BABYLON {
  42555. /**
  42556. * VRDistortionCorrectionPostProcess used for mobile VR
  42557. */
  42558. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42559. private _isRightEye;
  42560. private _distortionFactors;
  42561. private _postProcessScaleFactor;
  42562. private _lensCenterOffset;
  42563. private _scaleIn;
  42564. private _scaleFactor;
  42565. private _lensCenter;
  42566. /**
  42567. * Initializes the VRDistortionCorrectionPostProcess
  42568. * @param name The name of the effect.
  42569. * @param camera The camera to apply the render pass to.
  42570. * @param isRightEye If this is for the right eye distortion
  42571. * @param vrMetrics All the required metrics for the VR camera
  42572. */
  42573. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42574. }
  42575. }
  42576. declare module BABYLON {
  42577. /**
  42578. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42579. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42580. */
  42581. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42582. /**
  42583. * Creates a new VRDeviceOrientationArcRotateCamera
  42584. * @param name defines camera name
  42585. * @param alpha defines the camera rotation along the logitudinal axis
  42586. * @param beta defines the camera rotation along the latitudinal axis
  42587. * @param radius defines the camera distance from its target
  42588. * @param target defines the camera target
  42589. * @param scene defines the scene the camera belongs to
  42590. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42591. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42592. */
  42593. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42594. /**
  42595. * Gets camera class name
  42596. * @returns VRDeviceOrientationArcRotateCamera
  42597. */
  42598. getClassName(): string;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * Camera used to simulate VR rendering (based on FreeCamera)
  42604. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42605. */
  42606. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42607. /**
  42608. * Creates a new VRDeviceOrientationFreeCamera
  42609. * @param name defines camera name
  42610. * @param position defines the start position of the camera
  42611. * @param scene defines the scene the camera belongs to
  42612. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42613. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42614. */
  42615. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42616. /**
  42617. * Gets camera class name
  42618. * @returns VRDeviceOrientationFreeCamera
  42619. */
  42620. getClassName(): string;
  42621. }
  42622. }
  42623. declare module BABYLON {
  42624. /**
  42625. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42626. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42627. */
  42628. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42629. /**
  42630. * Creates a new VRDeviceOrientationGamepadCamera
  42631. * @param name defines camera name
  42632. * @param position defines the start position of the camera
  42633. * @param scene defines the scene the camera belongs to
  42634. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42635. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42636. */
  42637. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42638. /**
  42639. * Gets camera class name
  42640. * @returns VRDeviceOrientationGamepadCamera
  42641. */
  42642. getClassName(): string;
  42643. }
  42644. }
  42645. declare module BABYLON {
  42646. /** @hidden */
  42647. export var imageProcessingPixelShader: {
  42648. name: string;
  42649. shader: string;
  42650. };
  42651. }
  42652. declare module BABYLON {
  42653. /**
  42654. * ImageProcessingPostProcess
  42655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42656. */
  42657. export class ImageProcessingPostProcess extends PostProcess {
  42658. /**
  42659. * Default configuration related to image processing available in the PBR Material.
  42660. */
  42661. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42662. /**
  42663. * Gets the image processing configuration used either in this material.
  42664. */
  42665. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42666. /**
  42667. * Sets the Default image processing configuration used either in the this material.
  42668. *
  42669. * If sets to null, the scene one is in use.
  42670. */
  42671. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42672. /**
  42673. * Keep track of the image processing observer to allow dispose and replace.
  42674. */
  42675. private _imageProcessingObserver;
  42676. /**
  42677. * Attaches a new image processing configuration to the PBR Material.
  42678. * @param configuration
  42679. */
  42680. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42681. /**
  42682. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42683. */
  42684. get colorCurves(): Nullable<ColorCurves>;
  42685. /**
  42686. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42687. */
  42688. set colorCurves(value: Nullable<ColorCurves>);
  42689. /**
  42690. * Gets wether the color curves effect is enabled.
  42691. */
  42692. get colorCurvesEnabled(): boolean;
  42693. /**
  42694. * Sets wether the color curves effect is enabled.
  42695. */
  42696. set colorCurvesEnabled(value: boolean);
  42697. /**
  42698. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42699. */
  42700. get colorGradingTexture(): Nullable<BaseTexture>;
  42701. /**
  42702. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42703. */
  42704. set colorGradingTexture(value: Nullable<BaseTexture>);
  42705. /**
  42706. * Gets wether the color grading effect is enabled.
  42707. */
  42708. get colorGradingEnabled(): boolean;
  42709. /**
  42710. * Gets wether the color grading effect is enabled.
  42711. */
  42712. set colorGradingEnabled(value: boolean);
  42713. /**
  42714. * Gets exposure used in the effect.
  42715. */
  42716. get exposure(): number;
  42717. /**
  42718. * Sets exposure used in the effect.
  42719. */
  42720. set exposure(value: number);
  42721. /**
  42722. * Gets wether tonemapping is enabled or not.
  42723. */
  42724. get toneMappingEnabled(): boolean;
  42725. /**
  42726. * Sets wether tonemapping is enabled or not
  42727. */
  42728. set toneMappingEnabled(value: boolean);
  42729. /**
  42730. * Gets the type of tone mapping effect.
  42731. */
  42732. get toneMappingType(): number;
  42733. /**
  42734. * Sets the type of tone mapping effect.
  42735. */
  42736. set toneMappingType(value: number);
  42737. /**
  42738. * Gets contrast used in the effect.
  42739. */
  42740. get contrast(): number;
  42741. /**
  42742. * Sets contrast used in the effect.
  42743. */
  42744. set contrast(value: number);
  42745. /**
  42746. * Gets Vignette stretch size.
  42747. */
  42748. get vignetteStretch(): number;
  42749. /**
  42750. * Sets Vignette stretch size.
  42751. */
  42752. set vignetteStretch(value: number);
  42753. /**
  42754. * Gets Vignette centre X Offset.
  42755. */
  42756. get vignetteCentreX(): number;
  42757. /**
  42758. * Sets Vignette centre X Offset.
  42759. */
  42760. set vignetteCentreX(value: number);
  42761. /**
  42762. * Gets Vignette centre Y Offset.
  42763. */
  42764. get vignetteCentreY(): number;
  42765. /**
  42766. * Sets Vignette centre Y Offset.
  42767. */
  42768. set vignetteCentreY(value: number);
  42769. /**
  42770. * Gets Vignette weight or intensity of the vignette effect.
  42771. */
  42772. get vignetteWeight(): number;
  42773. /**
  42774. * Sets Vignette weight or intensity of the vignette effect.
  42775. */
  42776. set vignetteWeight(value: number);
  42777. /**
  42778. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42779. * if vignetteEnabled is set to true.
  42780. */
  42781. get vignetteColor(): Color4;
  42782. /**
  42783. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42784. * if vignetteEnabled is set to true.
  42785. */
  42786. set vignetteColor(value: Color4);
  42787. /**
  42788. * Gets Camera field of view used by the Vignette effect.
  42789. */
  42790. get vignetteCameraFov(): number;
  42791. /**
  42792. * Sets Camera field of view used by the Vignette effect.
  42793. */
  42794. set vignetteCameraFov(value: number);
  42795. /**
  42796. * Gets the vignette blend mode allowing different kind of effect.
  42797. */
  42798. get vignetteBlendMode(): number;
  42799. /**
  42800. * Sets the vignette blend mode allowing different kind of effect.
  42801. */
  42802. set vignetteBlendMode(value: number);
  42803. /**
  42804. * Gets wether the vignette effect is enabled.
  42805. */
  42806. get vignetteEnabled(): boolean;
  42807. /**
  42808. * Sets wether the vignette effect is enabled.
  42809. */
  42810. set vignetteEnabled(value: boolean);
  42811. private _fromLinearSpace;
  42812. /**
  42813. * Gets wether the input of the processing is in Gamma or Linear Space.
  42814. */
  42815. get fromLinearSpace(): boolean;
  42816. /**
  42817. * Sets wether the input of the processing is in Gamma or Linear Space.
  42818. */
  42819. set fromLinearSpace(value: boolean);
  42820. /**
  42821. * Defines cache preventing GC.
  42822. */
  42823. private _defines;
  42824. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42825. /**
  42826. * "ImageProcessingPostProcess"
  42827. * @returns "ImageProcessingPostProcess"
  42828. */
  42829. getClassName(): string;
  42830. protected _updateParameters(): void;
  42831. dispose(camera?: Camera): void;
  42832. }
  42833. }
  42834. declare module BABYLON {
  42835. /**
  42836. * Class containing static functions to help procedurally build meshes
  42837. */
  42838. export class GroundBuilder {
  42839. /**
  42840. * Creates a ground mesh
  42841. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42842. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42844. * @param name defines the name of the mesh
  42845. * @param options defines the options used to create the mesh
  42846. * @param scene defines the hosting scene
  42847. * @returns the ground mesh
  42848. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42849. */
  42850. static CreateGround(name: string, options: {
  42851. width?: number;
  42852. height?: number;
  42853. subdivisions?: number;
  42854. subdivisionsX?: number;
  42855. subdivisionsY?: number;
  42856. updatable?: boolean;
  42857. }, scene: any): Mesh;
  42858. /**
  42859. * Creates a tiled ground mesh
  42860. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42861. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42862. * * 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
  42863. * * 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
  42864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42865. * @param name defines the name of the mesh
  42866. * @param options defines the options used to create the mesh
  42867. * @param scene defines the hosting scene
  42868. * @returns the tiled ground mesh
  42869. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42870. */
  42871. static CreateTiledGround(name: string, options: {
  42872. xmin: number;
  42873. zmin: number;
  42874. xmax: number;
  42875. zmax: number;
  42876. subdivisions?: {
  42877. w: number;
  42878. h: number;
  42879. };
  42880. precision?: {
  42881. w: number;
  42882. h: number;
  42883. };
  42884. updatable?: boolean;
  42885. }, scene?: Nullable<Scene>): Mesh;
  42886. /**
  42887. * Creates a ground mesh from a height map
  42888. * * The parameter `url` sets the URL of the height map image resource.
  42889. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42890. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42891. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42892. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42893. * * 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.
  42894. * * 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).
  42895. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42897. * @param name defines the name of the mesh
  42898. * @param url defines the url to the height map
  42899. * @param options defines the options used to create the mesh
  42900. * @param scene defines the hosting scene
  42901. * @returns the ground mesh
  42902. * @see https://doc.babylonjs.com/babylon101/height_map
  42903. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42904. */
  42905. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42906. width?: number;
  42907. height?: number;
  42908. subdivisions?: number;
  42909. minHeight?: number;
  42910. maxHeight?: number;
  42911. colorFilter?: Color3;
  42912. alphaFilter?: number;
  42913. updatable?: boolean;
  42914. onReady?: (mesh: GroundMesh) => void;
  42915. }, scene?: Nullable<Scene>): GroundMesh;
  42916. }
  42917. }
  42918. declare module BABYLON {
  42919. /**
  42920. * Class containing static functions to help procedurally build meshes
  42921. */
  42922. export class TorusBuilder {
  42923. /**
  42924. * Creates a torus mesh
  42925. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42926. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42927. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42929. * * 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
  42930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42931. * @param name defines the name of the mesh
  42932. * @param options defines the options used to create the mesh
  42933. * @param scene defines the hosting scene
  42934. * @returns the torus mesh
  42935. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42936. */
  42937. static CreateTorus(name: string, options: {
  42938. diameter?: number;
  42939. thickness?: number;
  42940. tessellation?: number;
  42941. updatable?: boolean;
  42942. sideOrientation?: number;
  42943. frontUVs?: Vector4;
  42944. backUVs?: Vector4;
  42945. }, scene: any): Mesh;
  42946. }
  42947. }
  42948. declare module BABYLON {
  42949. /**
  42950. * Class containing static functions to help procedurally build meshes
  42951. */
  42952. export class CylinderBuilder {
  42953. /**
  42954. * Creates a cylinder or a cone mesh
  42955. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42956. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42957. * * 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.
  42958. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42959. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42960. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42961. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42962. * * 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).
  42963. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42964. * * 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).
  42965. * * 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
  42966. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42967. * * 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
  42968. * * 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.
  42969. * * If `enclose` is false, a ring surface is one element.
  42970. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42971. * * 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
  42972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42973. * * 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
  42974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42975. * @param name defines the name of the mesh
  42976. * @param options defines the options used to create the mesh
  42977. * @param scene defines the hosting scene
  42978. * @returns the cylinder mesh
  42979. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42980. */
  42981. static CreateCylinder(name: string, options: {
  42982. height?: number;
  42983. diameterTop?: number;
  42984. diameterBottom?: number;
  42985. diameter?: number;
  42986. tessellation?: number;
  42987. subdivisions?: number;
  42988. arc?: number;
  42989. faceColors?: Color4[];
  42990. faceUV?: Vector4[];
  42991. updatable?: boolean;
  42992. hasRings?: boolean;
  42993. enclose?: boolean;
  42994. cap?: number;
  42995. sideOrientation?: number;
  42996. frontUVs?: Vector4;
  42997. backUVs?: Vector4;
  42998. }, scene: any): Mesh;
  42999. }
  43000. }
  43001. declare module BABYLON {
  43002. /**
  43003. * States of the webXR experience
  43004. */
  43005. export enum WebXRState {
  43006. /**
  43007. * Transitioning to being in XR mode
  43008. */
  43009. ENTERING_XR = 0,
  43010. /**
  43011. * Transitioning to non XR mode
  43012. */
  43013. EXITING_XR = 1,
  43014. /**
  43015. * In XR mode and presenting
  43016. */
  43017. IN_XR = 2,
  43018. /**
  43019. * Not entered XR mode
  43020. */
  43021. NOT_IN_XR = 3
  43022. }
  43023. /**
  43024. * Abstraction of the XR render target
  43025. */
  43026. export interface WebXRRenderTarget extends IDisposable {
  43027. /**
  43028. * xrpresent context of the canvas which can be used to display/mirror xr content
  43029. */
  43030. canvasContext: WebGLRenderingContext;
  43031. /**
  43032. * xr layer for the canvas
  43033. */
  43034. xrLayer: Nullable<XRWebGLLayer>;
  43035. /**
  43036. * Initializes the xr layer for the session
  43037. * @param xrSession xr session
  43038. * @returns a promise that will resolve once the XR Layer has been created
  43039. */
  43040. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43041. }
  43042. }
  43043. declare module BABYLON {
  43044. /**
  43045. * COnfiguration object for WebXR output canvas
  43046. */
  43047. export class WebXRManagedOutputCanvasOptions {
  43048. /**
  43049. * An optional canvas in case you wish to create it yourself and provide it here.
  43050. * If not provided, a new canvas will be created
  43051. */
  43052. canvasElement?: HTMLCanvasElement;
  43053. /**
  43054. * Options for this XR Layer output
  43055. */
  43056. canvasOptions?: XRWebGLLayerOptions;
  43057. /**
  43058. * CSS styling for a newly created canvas (if not provided)
  43059. */
  43060. newCanvasCssStyle?: string;
  43061. /**
  43062. * Get the default values of the configuration object
  43063. * @returns default values of this configuration object
  43064. */
  43065. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43066. }
  43067. /**
  43068. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43069. */
  43070. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43071. private _options;
  43072. private _canvas;
  43073. private _engine;
  43074. /**
  43075. * Rendering context of the canvas which can be used to display/mirror xr content
  43076. */
  43077. canvasContext: WebGLRenderingContext;
  43078. /**
  43079. * xr layer for the canvas
  43080. */
  43081. xrLayer: Nullable<XRWebGLLayer>;
  43082. /**
  43083. * Initializes the canvas to be added/removed upon entering/exiting xr
  43084. * @param _xrSessionManager The XR Session manager
  43085. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43086. */
  43087. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43088. /**
  43089. * Disposes of the object
  43090. */
  43091. dispose(): void;
  43092. /**
  43093. * Initializes the xr layer for the session
  43094. * @param xrSession xr session
  43095. * @returns a promise that will resolve once the XR Layer has been created
  43096. */
  43097. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43098. private _addCanvas;
  43099. private _removeCanvas;
  43100. private _setManagedOutputCanvas;
  43101. }
  43102. }
  43103. declare module BABYLON {
  43104. /**
  43105. * Manages an XRSession to work with Babylon's engine
  43106. * @see https://doc.babylonjs.com/how_to/webxr
  43107. */
  43108. export class WebXRSessionManager implements IDisposable {
  43109. /** The scene which the session should be created for */
  43110. scene: Scene;
  43111. private _referenceSpace;
  43112. private _rttProvider;
  43113. private _sessionEnded;
  43114. private _xrNavigator;
  43115. private baseLayer;
  43116. /**
  43117. * The base reference space from which the session started. good if you want to reset your
  43118. * reference space
  43119. */
  43120. baseReferenceSpace: XRReferenceSpace;
  43121. /**
  43122. * Current XR frame
  43123. */
  43124. currentFrame: Nullable<XRFrame>;
  43125. /** WebXR timestamp updated every frame */
  43126. currentTimestamp: number;
  43127. /**
  43128. * Used just in case of a failure to initialize an immersive session.
  43129. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43130. */
  43131. defaultHeightCompensation: number;
  43132. /**
  43133. * Fires every time a new xrFrame arrives which can be used to update the camera
  43134. */
  43135. onXRFrameObservable: Observable<XRFrame>;
  43136. /**
  43137. * Fires when the reference space changed
  43138. */
  43139. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43140. /**
  43141. * Fires when the xr session is ended either by the device or manually done
  43142. */
  43143. onXRSessionEnded: Observable<any>;
  43144. /**
  43145. * Fires when the xr session is ended either by the device or manually done
  43146. */
  43147. onXRSessionInit: Observable<XRSession>;
  43148. /**
  43149. * Underlying xr session
  43150. */
  43151. session: XRSession;
  43152. /**
  43153. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43154. * or get the offset the player is currently at.
  43155. */
  43156. viewerReferenceSpace: XRReferenceSpace;
  43157. /**
  43158. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43159. * @param scene The scene which the session should be created for
  43160. */
  43161. constructor(
  43162. /** The scene which the session should be created for */
  43163. scene: Scene);
  43164. /**
  43165. * The current reference space used in this session. This reference space can constantly change!
  43166. * It is mainly used to offset the camera's position.
  43167. */
  43168. get referenceSpace(): XRReferenceSpace;
  43169. /**
  43170. * Set a new reference space and triggers the observable
  43171. */
  43172. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43173. /**
  43174. * Disposes of the session manager
  43175. */
  43176. dispose(): void;
  43177. /**
  43178. * Stops the xrSession and restores the render loop
  43179. * @returns Promise which resolves after it exits XR
  43180. */
  43181. exitXRAsync(): Promise<void>;
  43182. /**
  43183. * Gets the correct render target texture to be rendered this frame for this eye
  43184. * @param eye the eye for which to get the render target
  43185. * @returns the render target for the specified eye
  43186. */
  43187. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43188. /**
  43189. * Creates a WebXRRenderTarget object for the XR session
  43190. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43191. * @param options optional options to provide when creating a new render target
  43192. * @returns a WebXR render target to which the session can render
  43193. */
  43194. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43195. /**
  43196. * Initializes the manager
  43197. * After initialization enterXR can be called to start an XR session
  43198. * @returns Promise which resolves after it is initialized
  43199. */
  43200. initializeAsync(): Promise<void>;
  43201. /**
  43202. * Initializes an xr session
  43203. * @param xrSessionMode mode to initialize
  43204. * @param xrSessionInit defines optional and required values to pass to the session builder
  43205. * @returns a promise which will resolve once the session has been initialized
  43206. */
  43207. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43208. /**
  43209. * Checks if a session would be supported for the creation options specified
  43210. * @param sessionMode session mode to check if supported eg. immersive-vr
  43211. * @returns A Promise that resolves to true if supported and false if not
  43212. */
  43213. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43214. /**
  43215. * Resets the reference space to the one started the session
  43216. */
  43217. resetReferenceSpace(): void;
  43218. /**
  43219. * Starts rendering to the xr layer
  43220. */
  43221. runXRRenderLoop(): void;
  43222. /**
  43223. * Sets the reference space on the xr session
  43224. * @param referenceSpaceType space to set
  43225. * @returns a promise that will resolve once the reference space has been set
  43226. */
  43227. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43228. /**
  43229. * Updates the render state of the session
  43230. * @param state state to set
  43231. * @returns a promise that resolves once the render state has been updated
  43232. */
  43233. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43234. /**
  43235. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43236. * @param sessionMode defines the session to test
  43237. * @returns a promise with boolean as final value
  43238. */
  43239. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43240. private _createRenderTargetTexture;
  43241. }
  43242. }
  43243. declare module BABYLON {
  43244. /**
  43245. * WebXR Camera which holds the views for the xrSession
  43246. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43247. */
  43248. export class WebXRCamera extends FreeCamera {
  43249. private _xrSessionManager;
  43250. private _firstFrame;
  43251. private _referenceQuaternion;
  43252. private _referencedPosition;
  43253. private _xrInvPositionCache;
  43254. private _xrInvQuaternionCache;
  43255. /**
  43256. * Should position compensation execute on first frame.
  43257. * This is used when copying the position from a native (non XR) camera
  43258. */
  43259. compensateOnFirstFrame: boolean;
  43260. /**
  43261. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43262. * @param name the name of the camera
  43263. * @param scene the scene to add the camera to
  43264. * @param _xrSessionManager a constructed xr session manager
  43265. */
  43266. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43267. /**
  43268. * Return the user's height, unrelated to the current ground.
  43269. * This will be the y position of this camera, when ground level is 0.
  43270. */
  43271. get realWorldHeight(): number;
  43272. /** @hidden */
  43273. _updateForDualEyeDebugging(): void;
  43274. /**
  43275. * Sets this camera's transformation based on a non-vr camera
  43276. * @param otherCamera the non-vr camera to copy the transformation from
  43277. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43278. */
  43279. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43280. /**
  43281. * Gets the current instance class name ("WebXRCamera").
  43282. * @returns the class name
  43283. */
  43284. getClassName(): string;
  43285. private _updateFromXRSession;
  43286. private _updateNumberOfRigCameras;
  43287. private _updateReferenceSpace;
  43288. private _updateReferenceSpaceOffset;
  43289. }
  43290. }
  43291. declare module BABYLON {
  43292. /**
  43293. * Defining the interface required for a (webxr) feature
  43294. */
  43295. export interface IWebXRFeature extends IDisposable {
  43296. /**
  43297. * Is this feature attached
  43298. */
  43299. attached: boolean;
  43300. /**
  43301. * Should auto-attach be disabled?
  43302. */
  43303. disableAutoAttach: boolean;
  43304. /**
  43305. * Attach the feature to the session
  43306. * Will usually be called by the features manager
  43307. *
  43308. * @param force should attachment be forced (even when already attached)
  43309. * @returns true if successful.
  43310. */
  43311. attach(force?: boolean): boolean;
  43312. /**
  43313. * Detach the feature from the session
  43314. * Will usually be called by the features manager
  43315. *
  43316. * @returns true if successful.
  43317. */
  43318. detach(): boolean;
  43319. }
  43320. /**
  43321. * A list of the currently available features without referencing them
  43322. */
  43323. export class WebXRFeatureName {
  43324. /**
  43325. * The name of the anchor system feature
  43326. */
  43327. static ANCHOR_SYSTEM: string;
  43328. /**
  43329. * The name of the background remover feature
  43330. */
  43331. static BACKGROUND_REMOVER: string;
  43332. /**
  43333. * The name of the hit test feature
  43334. */
  43335. static HIT_TEST: string;
  43336. /**
  43337. * physics impostors for xr controllers feature
  43338. */
  43339. static PHYSICS_CONTROLLERS: string;
  43340. /**
  43341. * The name of the plane detection feature
  43342. */
  43343. static PLANE_DETECTION: string;
  43344. /**
  43345. * The name of the pointer selection feature
  43346. */
  43347. static POINTER_SELECTION: string;
  43348. /**
  43349. * The name of the teleportation feature
  43350. */
  43351. static TELEPORTATION: string;
  43352. }
  43353. /**
  43354. * Defining the constructor of a feature. Used to register the modules.
  43355. */
  43356. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43357. /**
  43358. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43359. * It is mainly used in AR sessions.
  43360. *
  43361. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43362. */
  43363. export class WebXRFeaturesManager implements IDisposable {
  43364. private _xrSessionManager;
  43365. private static readonly _AvailableFeatures;
  43366. private _features;
  43367. /**
  43368. * constructs a new features manages.
  43369. *
  43370. * @param _xrSessionManager an instance of WebXRSessionManager
  43371. */
  43372. constructor(_xrSessionManager: WebXRSessionManager);
  43373. /**
  43374. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43375. * Mainly used internally.
  43376. *
  43377. * @param featureName the name of the feature to register
  43378. * @param constructorFunction the function used to construct the module
  43379. * @param version the (babylon) version of the module
  43380. * @param stable is that a stable version of this module
  43381. */
  43382. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43383. /**
  43384. * Returns a constructor of a specific feature.
  43385. *
  43386. * @param featureName the name of the feature to construct
  43387. * @param version the version of the feature to load
  43388. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43389. * @param options optional options provided to the module.
  43390. * @returns a function that, when called, will return a new instance of this feature
  43391. */
  43392. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43393. /**
  43394. * Can be used to return the list of features currently registered
  43395. *
  43396. * @returns an Array of available features
  43397. */
  43398. static GetAvailableFeatures(): string[];
  43399. /**
  43400. * Gets the versions available for a specific feature
  43401. * @param featureName the name of the feature
  43402. * @returns an array with the available versions
  43403. */
  43404. static GetAvailableVersions(featureName: string): string[];
  43405. /**
  43406. * Return the latest unstable version of this feature
  43407. * @param featureName the name of the feature to search
  43408. * @returns the version number. if not found will return -1
  43409. */
  43410. static GetLatestVersionOfFeature(featureName: string): number;
  43411. /**
  43412. * Return the latest stable version of this feature
  43413. * @param featureName the name of the feature to search
  43414. * @returns the version number. if not found will return -1
  43415. */
  43416. static GetStableVersionOfFeature(featureName: string): number;
  43417. /**
  43418. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43419. * Can be used during a session to start a feature
  43420. * @param featureName the name of feature to attach
  43421. */
  43422. attachFeature(featureName: string): void;
  43423. /**
  43424. * Can be used inside a session or when the session ends to detach a specific feature
  43425. * @param featureName the name of the feature to detach
  43426. */
  43427. detachFeature(featureName: string): void;
  43428. /**
  43429. * Used to disable an already-enabled feature
  43430. * The feature will be disposed and will be recreated once enabled.
  43431. * @param featureName the feature to disable
  43432. * @returns true if disable was successful
  43433. */
  43434. disableFeature(featureName: string | {
  43435. Name: string;
  43436. }): boolean;
  43437. /**
  43438. * dispose this features manager
  43439. */
  43440. dispose(): void;
  43441. /**
  43442. * 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.
  43443. * 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.
  43444. *
  43445. * @param featureName the name of the feature to load or the class of the feature
  43446. * @param version optional version to load. if not provided the latest version will be enabled
  43447. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43448. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43449. * @returns a new constructed feature or throws an error if feature not found.
  43450. */
  43451. enableFeature(featureName: string | {
  43452. Name: string;
  43453. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43454. /**
  43455. * get the implementation of an enabled feature.
  43456. * @param featureName the name of the feature to load
  43457. * @returns the feature class, if found
  43458. */
  43459. getEnabledFeature(featureName: string): IWebXRFeature;
  43460. /**
  43461. * Get the list of enabled features
  43462. * @returns an array of enabled features
  43463. */
  43464. getEnabledFeatures(): string[];
  43465. }
  43466. }
  43467. declare module BABYLON {
  43468. /**
  43469. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43470. * @see https://doc.babylonjs.com/how_to/webxr
  43471. */
  43472. export class WebXRExperienceHelper implements IDisposable {
  43473. private scene;
  43474. private _nonVRCamera;
  43475. private _originalSceneAutoClear;
  43476. private _supported;
  43477. /**
  43478. * Camera used to render xr content
  43479. */
  43480. camera: WebXRCamera;
  43481. /** A features manager for this xr session */
  43482. featuresManager: WebXRFeaturesManager;
  43483. /**
  43484. * Observers registered here will be triggered after the camera's initial transformation is set
  43485. * This can be used to set a different ground level or an extra rotation.
  43486. *
  43487. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43488. * to the position set after this observable is done executing.
  43489. */
  43490. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43491. /**
  43492. * Fires when the state of the experience helper has changed
  43493. */
  43494. onStateChangedObservable: Observable<WebXRState>;
  43495. /** Session manager used to keep track of xr session */
  43496. sessionManager: WebXRSessionManager;
  43497. /**
  43498. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43499. */
  43500. state: WebXRState;
  43501. /**
  43502. * Creates a WebXRExperienceHelper
  43503. * @param scene The scene the helper should be created in
  43504. */
  43505. private constructor();
  43506. /**
  43507. * Creates the experience helper
  43508. * @param scene the scene to attach the experience helper to
  43509. * @returns a promise for the experience helper
  43510. */
  43511. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43512. /**
  43513. * Disposes of the experience helper
  43514. */
  43515. dispose(): void;
  43516. /**
  43517. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43518. * @param sessionMode options for the XR session
  43519. * @param referenceSpaceType frame of reference of the XR session
  43520. * @param renderTarget the output canvas that will be used to enter XR mode
  43521. * @returns promise that resolves after xr mode has entered
  43522. */
  43523. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43524. /**
  43525. * Exits XR mode and returns the scene to its original state
  43526. * @returns promise that resolves after xr mode has exited
  43527. */
  43528. exitXRAsync(): Promise<void>;
  43529. private _nonXRToXRCamera;
  43530. private _setState;
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /**
  43535. * X-Y values for axes in WebXR
  43536. */
  43537. export interface IWebXRMotionControllerAxesValue {
  43538. /**
  43539. * The value of the x axis
  43540. */
  43541. x: number;
  43542. /**
  43543. * The value of the y-axis
  43544. */
  43545. y: number;
  43546. }
  43547. /**
  43548. * changed / previous values for the values of this component
  43549. */
  43550. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43551. /**
  43552. * current (this frame) value
  43553. */
  43554. current: T;
  43555. /**
  43556. * previous (last change) value
  43557. */
  43558. previous: T;
  43559. }
  43560. /**
  43561. * Represents changes in the component between current frame and last values recorded
  43562. */
  43563. export interface IWebXRMotionControllerComponentChanges {
  43564. /**
  43565. * will be populated with previous and current values if axes changed
  43566. */
  43567. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43568. /**
  43569. * will be populated with previous and current values if pressed changed
  43570. */
  43571. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43572. /**
  43573. * will be populated with previous and current values if touched changed
  43574. */
  43575. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43576. /**
  43577. * will be populated with previous and current values if value changed
  43578. */
  43579. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43580. }
  43581. /**
  43582. * This class represents a single component (for example button or thumbstick) of a motion controller
  43583. */
  43584. export class WebXRControllerComponent implements IDisposable {
  43585. /**
  43586. * the id of this component
  43587. */
  43588. id: string;
  43589. /**
  43590. * the type of the component
  43591. */
  43592. type: MotionControllerComponentType;
  43593. private _buttonIndex;
  43594. private _axesIndices;
  43595. private _axes;
  43596. private _changes;
  43597. private _currentValue;
  43598. private _hasChanges;
  43599. private _pressed;
  43600. private _touched;
  43601. /**
  43602. * button component type
  43603. */
  43604. static BUTTON_TYPE: MotionControllerComponentType;
  43605. /**
  43606. * squeeze component type
  43607. */
  43608. static SQUEEZE_TYPE: MotionControllerComponentType;
  43609. /**
  43610. * Thumbstick component type
  43611. */
  43612. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43613. /**
  43614. * Touchpad component type
  43615. */
  43616. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43617. /**
  43618. * trigger component type
  43619. */
  43620. static TRIGGER_TYPE: MotionControllerComponentType;
  43621. /**
  43622. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43623. * the axes data changes
  43624. */
  43625. onAxisValueChangedObservable: Observable<{
  43626. x: number;
  43627. y: number;
  43628. }>;
  43629. /**
  43630. * Observers registered here will be triggered when the state of a button changes
  43631. * State change is either pressed / touched / value
  43632. */
  43633. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43634. /**
  43635. * Creates a new component for a motion controller.
  43636. * It is created by the motion controller itself
  43637. *
  43638. * @param id the id of this component
  43639. * @param type the type of the component
  43640. * @param _buttonIndex index in the buttons array of the gamepad
  43641. * @param _axesIndices indices of the values in the axes array of the gamepad
  43642. */
  43643. constructor(
  43644. /**
  43645. * the id of this component
  43646. */
  43647. id: string,
  43648. /**
  43649. * the type of the component
  43650. */
  43651. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43652. /**
  43653. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43654. */
  43655. get axes(): IWebXRMotionControllerAxesValue;
  43656. /**
  43657. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43658. */
  43659. get changes(): IWebXRMotionControllerComponentChanges;
  43660. /**
  43661. * Return whether or not the component changed the last frame
  43662. */
  43663. get hasChanges(): boolean;
  43664. /**
  43665. * is the button currently pressed
  43666. */
  43667. get pressed(): boolean;
  43668. /**
  43669. * is the button currently touched
  43670. */
  43671. get touched(): boolean;
  43672. /**
  43673. * Get the current value of this component
  43674. */
  43675. get value(): number;
  43676. /**
  43677. * Dispose this component
  43678. */
  43679. dispose(): void;
  43680. /**
  43681. * Are there axes correlating to this component
  43682. * @return true is axes data is available
  43683. */
  43684. isAxes(): boolean;
  43685. /**
  43686. * Is this component a button (hence - pressable)
  43687. * @returns true if can be pressed
  43688. */
  43689. isButton(): boolean;
  43690. /**
  43691. * update this component using the gamepad object it is in. Called on every frame
  43692. * @param nativeController the native gamepad controller object
  43693. */
  43694. update(nativeController: IMinimalMotionControllerObject): void;
  43695. }
  43696. }
  43697. declare module BABYLON {
  43698. /**
  43699. * Class used to represent data loading progression
  43700. */
  43701. export class SceneLoaderProgressEvent {
  43702. /** defines if data length to load can be evaluated */
  43703. readonly lengthComputable: boolean;
  43704. /** defines the loaded data length */
  43705. readonly loaded: number;
  43706. /** defines the data length to load */
  43707. readonly total: number;
  43708. /**
  43709. * Create a new progress event
  43710. * @param lengthComputable defines if data length to load can be evaluated
  43711. * @param loaded defines the loaded data length
  43712. * @param total defines the data length to load
  43713. */
  43714. constructor(
  43715. /** defines if data length to load can be evaluated */
  43716. lengthComputable: boolean,
  43717. /** defines the loaded data length */
  43718. loaded: number,
  43719. /** defines the data length to load */
  43720. total: number);
  43721. /**
  43722. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43723. * @param event defines the source event
  43724. * @returns a new SceneLoaderProgressEvent
  43725. */
  43726. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43727. }
  43728. /**
  43729. * Interface used by SceneLoader plugins to define supported file extensions
  43730. */
  43731. export interface ISceneLoaderPluginExtensions {
  43732. /**
  43733. * Defines the list of supported extensions
  43734. */
  43735. [extension: string]: {
  43736. isBinary: boolean;
  43737. };
  43738. }
  43739. /**
  43740. * Interface used by SceneLoader plugin factory
  43741. */
  43742. export interface ISceneLoaderPluginFactory {
  43743. /**
  43744. * Defines the name of the factory
  43745. */
  43746. name: string;
  43747. /**
  43748. * Function called to create a new plugin
  43749. * @return the new plugin
  43750. */
  43751. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43752. /**
  43753. * The callback that returns true if the data can be directly loaded.
  43754. * @param data string containing the file data
  43755. * @returns if the data can be loaded directly
  43756. */
  43757. canDirectLoad?(data: string): boolean;
  43758. }
  43759. /**
  43760. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43761. */
  43762. export interface ISceneLoaderPluginBase {
  43763. /**
  43764. * The friendly name of this plugin.
  43765. */
  43766. name: string;
  43767. /**
  43768. * The file extensions supported by this plugin.
  43769. */
  43770. extensions: string | ISceneLoaderPluginExtensions;
  43771. /**
  43772. * The callback called when loading from a url.
  43773. * @param scene scene loading this url
  43774. * @param url url to load
  43775. * @param onSuccess callback called when the file successfully loads
  43776. * @param onProgress callback called while file is loading (if the server supports this mode)
  43777. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43778. * @param onError callback called when the file fails to load
  43779. * @returns a file request object
  43780. */
  43781. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43782. /**
  43783. * The callback called when loading from a file object.
  43784. * @param scene scene loading this file
  43785. * @param file defines the file to load
  43786. * @param onSuccess defines the callback to call when data is loaded
  43787. * @param onProgress defines the callback to call during loading process
  43788. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43789. * @param onError defines the callback to call when an error occurs
  43790. * @returns a file request object
  43791. */
  43792. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43793. /**
  43794. * The callback that returns true if the data can be directly loaded.
  43795. * @param data string containing the file data
  43796. * @returns if the data can be loaded directly
  43797. */
  43798. canDirectLoad?(data: string): boolean;
  43799. /**
  43800. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43801. * @param scene scene loading this data
  43802. * @param data string containing the data
  43803. * @returns data to pass to the plugin
  43804. */
  43805. directLoad?(scene: Scene, data: string): any;
  43806. /**
  43807. * The callback that allows custom handling of the root url based on the response url.
  43808. * @param rootUrl the original root url
  43809. * @param responseURL the response url if available
  43810. * @returns the new root url
  43811. */
  43812. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43813. }
  43814. /**
  43815. * Interface used to define a SceneLoader plugin
  43816. */
  43817. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43818. /**
  43819. * Import meshes into a scene.
  43820. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43821. * @param scene The scene to import into
  43822. * @param data The data to import
  43823. * @param rootUrl The root url for scene and resources
  43824. * @param meshes The meshes array to import into
  43825. * @param particleSystems The particle systems array to import into
  43826. * @param skeletons The skeletons array to import into
  43827. * @param onError The callback when import fails
  43828. * @returns True if successful or false otherwise
  43829. */
  43830. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43831. /**
  43832. * Load into a scene.
  43833. * @param scene The scene to load into
  43834. * @param data The data to import
  43835. * @param rootUrl The root url for scene and resources
  43836. * @param onError The callback when import fails
  43837. * @returns True if successful or false otherwise
  43838. */
  43839. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43840. /**
  43841. * Load into an asset container.
  43842. * @param scene The scene to load into
  43843. * @param data The data to import
  43844. * @param rootUrl The root url for scene and resources
  43845. * @param onError The callback when import fails
  43846. * @returns The loaded asset container
  43847. */
  43848. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43849. }
  43850. /**
  43851. * Interface used to define an async SceneLoader plugin
  43852. */
  43853. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43854. /**
  43855. * Import meshes into a scene.
  43856. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43857. * @param scene The scene to import into
  43858. * @param data The data to import
  43859. * @param rootUrl The root url for scene and resources
  43860. * @param onProgress The callback when the load progresses
  43861. * @param fileName Defines the name of the file to load
  43862. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43863. */
  43864. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43865. meshes: AbstractMesh[];
  43866. particleSystems: IParticleSystem[];
  43867. skeletons: Skeleton[];
  43868. animationGroups: AnimationGroup[];
  43869. }>;
  43870. /**
  43871. * Load into a scene.
  43872. * @param scene The scene to load into
  43873. * @param data The data to import
  43874. * @param rootUrl The root url for scene and resources
  43875. * @param onProgress The callback when the load progresses
  43876. * @param fileName Defines the name of the file to load
  43877. * @returns Nothing
  43878. */
  43879. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43880. /**
  43881. * Load into an asset container.
  43882. * @param scene The scene to load into
  43883. * @param data The data to import
  43884. * @param rootUrl The root url for scene and resources
  43885. * @param onProgress The callback when the load progresses
  43886. * @param fileName Defines the name of the file to load
  43887. * @returns The loaded asset container
  43888. */
  43889. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43890. }
  43891. /**
  43892. * Mode that determines how to handle old animation groups before loading new ones.
  43893. */
  43894. export enum SceneLoaderAnimationGroupLoadingMode {
  43895. /**
  43896. * Reset all old animations to initial state then dispose them.
  43897. */
  43898. Clean = 0,
  43899. /**
  43900. * Stop all old animations.
  43901. */
  43902. Stop = 1,
  43903. /**
  43904. * Restart old animations from first frame.
  43905. */
  43906. Sync = 2,
  43907. /**
  43908. * Old animations remains untouched.
  43909. */
  43910. NoSync = 3
  43911. }
  43912. /**
  43913. * Class used to load scene from various file formats using registered plugins
  43914. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43915. */
  43916. export class SceneLoader {
  43917. /**
  43918. * No logging while loading
  43919. */
  43920. static readonly NO_LOGGING: number;
  43921. /**
  43922. * Minimal logging while loading
  43923. */
  43924. static readonly MINIMAL_LOGGING: number;
  43925. /**
  43926. * Summary logging while loading
  43927. */
  43928. static readonly SUMMARY_LOGGING: number;
  43929. /**
  43930. * Detailled logging while loading
  43931. */
  43932. static readonly DETAILED_LOGGING: number;
  43933. /**
  43934. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43935. */
  43936. static get ForceFullSceneLoadingForIncremental(): boolean;
  43937. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43938. /**
  43939. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43940. */
  43941. static get ShowLoadingScreen(): boolean;
  43942. static set ShowLoadingScreen(value: boolean);
  43943. /**
  43944. * Defines the current logging level (while loading the scene)
  43945. * @ignorenaming
  43946. */
  43947. static get loggingLevel(): number;
  43948. static set loggingLevel(value: number);
  43949. /**
  43950. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43951. */
  43952. static get CleanBoneMatrixWeights(): boolean;
  43953. static set CleanBoneMatrixWeights(value: boolean);
  43954. /**
  43955. * Event raised when a plugin is used to load a scene
  43956. */
  43957. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43958. private static _registeredPlugins;
  43959. private static _getDefaultPlugin;
  43960. private static _getPluginForExtension;
  43961. private static _getPluginForDirectLoad;
  43962. private static _getPluginForFilename;
  43963. private static _getDirectLoad;
  43964. private static _loadData;
  43965. private static _getFileInfo;
  43966. /**
  43967. * Gets a plugin that can load the given extension
  43968. * @param extension defines the extension to load
  43969. * @returns a plugin or null if none works
  43970. */
  43971. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43972. /**
  43973. * Gets a boolean indicating that the given extension can be loaded
  43974. * @param extension defines the extension to load
  43975. * @returns true if the extension is supported
  43976. */
  43977. static IsPluginForExtensionAvailable(extension: string): boolean;
  43978. /**
  43979. * Adds a new plugin to the list of registered plugins
  43980. * @param plugin defines the plugin to add
  43981. */
  43982. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43983. /**
  43984. * Import meshes into a scene
  43985. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43986. * @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)
  43987. * @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)
  43988. * @param scene the instance of BABYLON.Scene to append to
  43989. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43990. * @param onProgress a callback with a progress event for each file being loaded
  43991. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43992. * @param pluginExtension the extension used to determine the plugin
  43993. * @returns The loaded plugin
  43994. */
  43995. 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>;
  43996. /**
  43997. * Import meshes into a scene
  43998. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43999. * @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)
  44000. * @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)
  44001. * @param scene the instance of BABYLON.Scene to append to
  44002. * @param onProgress a callback with a progress event for each file being loaded
  44003. * @param pluginExtension the extension used to determine the plugin
  44004. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44005. */
  44006. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44007. meshes: AbstractMesh[];
  44008. particleSystems: IParticleSystem[];
  44009. skeletons: Skeleton[];
  44010. animationGroups: AnimationGroup[];
  44011. }>;
  44012. /**
  44013. * Load a scene
  44014. * @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)
  44015. * @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)
  44016. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44017. * @param onSuccess a callback with the scene when import succeeds
  44018. * @param onProgress a callback with a progress event for each file being loaded
  44019. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44020. * @param pluginExtension the extension used to determine the plugin
  44021. * @returns The loaded plugin
  44022. */
  44023. 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>;
  44024. /**
  44025. * Load a scene
  44026. * @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)
  44027. * @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)
  44028. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44029. * @param onProgress a callback with a progress event for each file being loaded
  44030. * @param pluginExtension the extension used to determine the plugin
  44031. * @returns The loaded scene
  44032. */
  44033. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44034. /**
  44035. * Append a scene
  44036. * @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)
  44037. * @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)
  44038. * @param scene is the instance of BABYLON.Scene to append to
  44039. * @param onSuccess a callback with the scene when import succeeds
  44040. * @param onProgress a callback with a progress event for each file being loaded
  44041. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44042. * @param pluginExtension the extension used to determine the plugin
  44043. * @returns The loaded plugin
  44044. */
  44045. 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>;
  44046. /**
  44047. * Append a scene
  44048. * @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)
  44049. * @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)
  44050. * @param scene is the instance of BABYLON.Scene to append to
  44051. * @param onProgress a callback with a progress event for each file being loaded
  44052. * @param pluginExtension the extension used to determine the plugin
  44053. * @returns The given scene
  44054. */
  44055. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44056. /**
  44057. * Load a scene into an asset container
  44058. * @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)
  44059. * @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)
  44060. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44061. * @param onSuccess a callback with the scene when import succeeds
  44062. * @param onProgress a callback with a progress event for each file being loaded
  44063. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44064. * @param pluginExtension the extension used to determine the plugin
  44065. * @returns The loaded plugin
  44066. */
  44067. 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>;
  44068. /**
  44069. * Load a scene into an asset container
  44070. * @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)
  44071. * @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)
  44072. * @param scene is the instance of Scene to append to
  44073. * @param onProgress a callback with a progress event for each file being loaded
  44074. * @param pluginExtension the extension used to determine the plugin
  44075. * @returns The loaded asset container
  44076. */
  44077. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44078. /**
  44079. * Import animations from a file into a scene
  44080. * @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)
  44081. * @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)
  44082. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44083. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44084. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44085. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44086. * @param onSuccess a callback with the scene when import succeeds
  44087. * @param onProgress a callback with a progress event for each file being loaded
  44088. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44089. */
  44090. 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;
  44091. /**
  44092. * Import animations from a file into a scene
  44093. * @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)
  44094. * @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)
  44095. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44096. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44097. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44098. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44099. * @param onSuccess a callback with the scene when import succeeds
  44100. * @param onProgress a callback with a progress event for each file being loaded
  44101. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44102. * @returns the updated scene with imported animations
  44103. */
  44104. 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>;
  44105. }
  44106. }
  44107. declare module BABYLON {
  44108. /**
  44109. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44110. */
  44111. export type MotionControllerHandness = "none" | "left" | "right";
  44112. /**
  44113. * The type of components available in motion controllers.
  44114. * This is not the name of the component.
  44115. */
  44116. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44117. /**
  44118. * The state of a controller component
  44119. */
  44120. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44121. /**
  44122. * The schema of motion controller layout.
  44123. * No object will be initialized using this interface
  44124. * This is used just to define the profile.
  44125. */
  44126. export interface IMotionControllerLayout {
  44127. /**
  44128. * Path to load the assets. Usually relative to the base path
  44129. */
  44130. assetPath: string;
  44131. /**
  44132. * Available components (unsorted)
  44133. */
  44134. components: {
  44135. /**
  44136. * A map of component Ids
  44137. */
  44138. [componentId: string]: {
  44139. /**
  44140. * The type of input the component outputs
  44141. */
  44142. type: MotionControllerComponentType;
  44143. /**
  44144. * The indices of this component in the gamepad object
  44145. */
  44146. gamepadIndices: {
  44147. /**
  44148. * Index of button
  44149. */
  44150. button?: number;
  44151. /**
  44152. * If available, index of x-axis
  44153. */
  44154. xAxis?: number;
  44155. /**
  44156. * If available, index of y-axis
  44157. */
  44158. yAxis?: number;
  44159. };
  44160. /**
  44161. * The mesh's root node name
  44162. */
  44163. rootNodeName: string;
  44164. /**
  44165. * Animation definitions for this model
  44166. */
  44167. visualResponses: {
  44168. [stateKey: string]: {
  44169. /**
  44170. * What property will be animated
  44171. */
  44172. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44173. /**
  44174. * What states influence this visual response
  44175. */
  44176. states: MotionControllerComponentStateType[];
  44177. /**
  44178. * Type of animation - movement or visibility
  44179. */
  44180. valueNodeProperty: "transform" | "visibility";
  44181. /**
  44182. * Base node name to move. Its position will be calculated according to the min and max nodes
  44183. */
  44184. valueNodeName?: string;
  44185. /**
  44186. * Minimum movement node
  44187. */
  44188. minNodeName?: string;
  44189. /**
  44190. * Max movement node
  44191. */
  44192. maxNodeName?: string;
  44193. };
  44194. };
  44195. /**
  44196. * If touch enabled, what is the name of node to display user feedback
  44197. */
  44198. touchPointNodeName?: string;
  44199. };
  44200. };
  44201. /**
  44202. * Is it xr standard mapping or not
  44203. */
  44204. gamepadMapping: "" | "xr-standard";
  44205. /**
  44206. * Base root node of this entire model
  44207. */
  44208. rootNodeName: string;
  44209. /**
  44210. * Defines the main button component id
  44211. */
  44212. selectComponentId: string;
  44213. }
  44214. /**
  44215. * A definition for the layout map in the input profile
  44216. */
  44217. export interface IMotionControllerLayoutMap {
  44218. /**
  44219. * Layouts with handness type as a key
  44220. */
  44221. [handness: string]: IMotionControllerLayout;
  44222. }
  44223. /**
  44224. * The XR Input profile schema
  44225. * Profiles can be found here:
  44226. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44227. */
  44228. export interface IMotionControllerProfile {
  44229. /**
  44230. * fallback profiles for this profileId
  44231. */
  44232. fallbackProfileIds: string[];
  44233. /**
  44234. * The layout map, with handness as key
  44235. */
  44236. layouts: IMotionControllerLayoutMap;
  44237. /**
  44238. * The id of this profile
  44239. * correlates to the profile(s) in the xrInput.profiles array
  44240. */
  44241. profileId: string;
  44242. }
  44243. /**
  44244. * A helper-interface for the 3 meshes needed for controller button animation
  44245. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44246. */
  44247. export interface IMotionControllerButtonMeshMap {
  44248. /**
  44249. * the mesh that defines the pressed value mesh position.
  44250. * This is used to find the max-position of this button
  44251. */
  44252. pressedMesh: AbstractMesh;
  44253. /**
  44254. * the mesh that defines the unpressed value mesh position.
  44255. * This is used to find the min (or initial) position of this button
  44256. */
  44257. unpressedMesh: AbstractMesh;
  44258. /**
  44259. * The mesh that will be changed when value changes
  44260. */
  44261. valueMesh: AbstractMesh;
  44262. }
  44263. /**
  44264. * A helper-interface for the 3 meshes needed for controller axis animation.
  44265. * This will be expanded when touchpad animations are fully supported
  44266. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44267. */
  44268. export interface IMotionControllerMeshMap {
  44269. /**
  44270. * the mesh that defines the maximum value mesh position.
  44271. */
  44272. maxMesh?: AbstractMesh;
  44273. /**
  44274. * the mesh that defines the minimum value mesh position.
  44275. */
  44276. minMesh?: AbstractMesh;
  44277. /**
  44278. * The mesh that will be changed when axis value changes
  44279. */
  44280. valueMesh: AbstractMesh;
  44281. }
  44282. /**
  44283. * The elements needed for change-detection of the gamepad objects in motion controllers
  44284. */
  44285. export interface IMinimalMotionControllerObject {
  44286. /**
  44287. * Available axes of this controller
  44288. */
  44289. axes: number[];
  44290. /**
  44291. * An array of available buttons
  44292. */
  44293. buttons: Array<{
  44294. /**
  44295. * Value of the button/trigger
  44296. */
  44297. value: number;
  44298. /**
  44299. * If the button/trigger is currently touched
  44300. */
  44301. touched: boolean;
  44302. /**
  44303. * If the button/trigger is currently pressed
  44304. */
  44305. pressed: boolean;
  44306. }>;
  44307. }
  44308. /**
  44309. * An Abstract Motion controller
  44310. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44311. * Each component has an observable to check for changes in value and state
  44312. */
  44313. export abstract class WebXRAbstractMotionController implements IDisposable {
  44314. protected scene: Scene;
  44315. protected layout: IMotionControllerLayout;
  44316. /**
  44317. * The gamepad object correlating to this controller
  44318. */
  44319. gamepadObject: IMinimalMotionControllerObject;
  44320. /**
  44321. * handness (left/right/none) of this controller
  44322. */
  44323. handness: MotionControllerHandness;
  44324. private _initComponent;
  44325. private _modelReady;
  44326. /**
  44327. * A map of components (WebXRControllerComponent) in this motion controller
  44328. * Components have a ComponentType and can also have both button and axis definitions
  44329. */
  44330. readonly components: {
  44331. [id: string]: WebXRControllerComponent;
  44332. };
  44333. /**
  44334. * Disable the model's animation. Can be set at any time.
  44335. */
  44336. disableAnimation: boolean;
  44337. /**
  44338. * Observers registered here will be triggered when the model of this controller is done loading
  44339. */
  44340. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44341. /**
  44342. * The profile id of this motion controller
  44343. */
  44344. abstract profileId: string;
  44345. /**
  44346. * The root mesh of the model. It is null if the model was not yet initialized
  44347. */
  44348. rootMesh: Nullable<AbstractMesh>;
  44349. /**
  44350. * constructs a new abstract motion controller
  44351. * @param scene the scene to which the model of the controller will be added
  44352. * @param layout The profile layout to load
  44353. * @param gamepadObject The gamepad object correlating to this controller
  44354. * @param handness handness (left/right/none) of this controller
  44355. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44356. */
  44357. constructor(scene: Scene, layout: IMotionControllerLayout,
  44358. /**
  44359. * The gamepad object correlating to this controller
  44360. */
  44361. gamepadObject: IMinimalMotionControllerObject,
  44362. /**
  44363. * handness (left/right/none) of this controller
  44364. */
  44365. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44366. /**
  44367. * Dispose this controller, the model mesh and all its components
  44368. */
  44369. dispose(): void;
  44370. /**
  44371. * Returns all components of specific type
  44372. * @param type the type to search for
  44373. * @return an array of components with this type
  44374. */
  44375. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44376. /**
  44377. * get a component based an its component id as defined in layout.components
  44378. * @param id the id of the component
  44379. * @returns the component correlates to the id or undefined if not found
  44380. */
  44381. getComponent(id: string): WebXRControllerComponent;
  44382. /**
  44383. * Get the list of components available in this motion controller
  44384. * @returns an array of strings correlating to available components
  44385. */
  44386. getComponentIds(): string[];
  44387. /**
  44388. * Get the first component of specific type
  44389. * @param type type of component to find
  44390. * @return a controller component or null if not found
  44391. */
  44392. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44393. /**
  44394. * Get the main (Select) component of this controller as defined in the layout
  44395. * @returns the main component of this controller
  44396. */
  44397. getMainComponent(): WebXRControllerComponent;
  44398. /**
  44399. * Loads the model correlating to this controller
  44400. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44401. * @returns A promise fulfilled with the result of the model loading
  44402. */
  44403. loadModel(): Promise<boolean>;
  44404. /**
  44405. * Update this model using the current XRFrame
  44406. * @param xrFrame the current xr frame to use and update the model
  44407. */
  44408. updateFromXRFrame(xrFrame: XRFrame): void;
  44409. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44410. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44411. /**
  44412. * Moves the axis on the controller mesh based on its current state
  44413. * @param axis the index of the axis
  44414. * @param axisValue the value of the axis which determines the meshes new position
  44415. * @hidden
  44416. */
  44417. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44418. /**
  44419. * Update the model itself with the current frame data
  44420. * @param xrFrame the frame to use for updating the model mesh
  44421. */
  44422. protected updateModel(xrFrame: XRFrame): void;
  44423. /**
  44424. * Get the filename and path for this controller's model
  44425. * @returns a map of filename and path
  44426. */
  44427. protected abstract _getFilenameAndPath(): {
  44428. filename: string;
  44429. path: string;
  44430. };
  44431. /**
  44432. * This function is called before the mesh is loaded. It checks for loading constraints.
  44433. * For example, this function can check if the GLB loader is available
  44434. * If this function returns false, the generic controller will be loaded instead
  44435. * @returns Is the client ready to load the mesh
  44436. */
  44437. protected abstract _getModelLoadingConstraints(): boolean;
  44438. /**
  44439. * This function will be called after the model was successfully loaded and can be used
  44440. * for mesh transformations before it is available for the user
  44441. * @param meshes the loaded meshes
  44442. */
  44443. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44444. /**
  44445. * Set the root mesh for this controller. Important for the WebXR controller class
  44446. * @param meshes the loaded meshes
  44447. */
  44448. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44449. /**
  44450. * A function executed each frame that updates the mesh (if needed)
  44451. * @param xrFrame the current xrFrame
  44452. */
  44453. protected abstract _updateModel(xrFrame: XRFrame): void;
  44454. private _getGenericFilenameAndPath;
  44455. private _getGenericParentMesh;
  44456. }
  44457. }
  44458. declare module BABYLON {
  44459. /**
  44460. * A generic trigger-only motion controller for WebXR
  44461. */
  44462. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44463. /**
  44464. * Static version of the profile id of this controller
  44465. */
  44466. static ProfileId: string;
  44467. profileId: string;
  44468. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44469. protected _getFilenameAndPath(): {
  44470. filename: string;
  44471. path: string;
  44472. };
  44473. protected _getModelLoadingConstraints(): boolean;
  44474. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44475. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44476. protected _updateModel(): void;
  44477. }
  44478. }
  44479. declare module BABYLON {
  44480. /**
  44481. * Class containing static functions to help procedurally build meshes
  44482. */
  44483. export class SphereBuilder {
  44484. /**
  44485. * Creates a sphere mesh
  44486. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44487. * * 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`)
  44488. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44489. * * 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
  44490. * * 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)
  44491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44492. * * 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
  44493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44494. * @param name defines the name of the mesh
  44495. * @param options defines the options used to create the mesh
  44496. * @param scene defines the hosting scene
  44497. * @returns the sphere mesh
  44498. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44499. */
  44500. static CreateSphere(name: string, options: {
  44501. segments?: number;
  44502. diameter?: number;
  44503. diameterX?: number;
  44504. diameterY?: number;
  44505. diameterZ?: number;
  44506. arc?: number;
  44507. slice?: number;
  44508. sideOrientation?: number;
  44509. frontUVs?: Vector4;
  44510. backUVs?: Vector4;
  44511. updatable?: boolean;
  44512. }, scene?: Nullable<Scene>): Mesh;
  44513. }
  44514. }
  44515. declare module BABYLON {
  44516. /**
  44517. * A profiled motion controller has its profile loaded from an online repository.
  44518. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44519. */
  44520. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44521. private _repositoryUrl;
  44522. private _buttonMeshMapping;
  44523. private _touchDots;
  44524. /**
  44525. * The profile ID of this controller. Will be populated when the controller initializes.
  44526. */
  44527. profileId: string;
  44528. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44529. dispose(): void;
  44530. protected _getFilenameAndPath(): {
  44531. filename: string;
  44532. path: string;
  44533. };
  44534. protected _getModelLoadingConstraints(): boolean;
  44535. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44536. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44537. protected _updateModel(_xrFrame: XRFrame): void;
  44538. }
  44539. }
  44540. declare module BABYLON {
  44541. /**
  44542. * A construction function type to create a new controller based on an xrInput object
  44543. */
  44544. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44545. /**
  44546. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44547. *
  44548. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44549. * it should be replaced with auto-loaded controllers.
  44550. *
  44551. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44552. */
  44553. export class WebXRMotionControllerManager {
  44554. private static _AvailableControllers;
  44555. private static _Fallbacks;
  44556. private static _ProfileLoadingPromises;
  44557. private static _ProfilesList;
  44558. /**
  44559. * The base URL of the online controller repository. Can be changed at any time.
  44560. */
  44561. static BaseRepositoryUrl: string;
  44562. /**
  44563. * Which repository gets priority - local or online
  44564. */
  44565. static PrioritizeOnlineRepository: boolean;
  44566. /**
  44567. * Use the online repository, or use only locally-defined controllers
  44568. */
  44569. static UseOnlineRepository: boolean;
  44570. /**
  44571. * Clear the cache used for profile loading and reload when requested again
  44572. */
  44573. static ClearProfilesCache(): void;
  44574. /**
  44575. * Register the default fallbacks.
  44576. * This function is called automatically when this file is imported.
  44577. */
  44578. static DefaultFallbacks(): void;
  44579. /**
  44580. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44581. * @param profileId the profile to which a fallback needs to be found
  44582. * @return an array with corresponding fallback profiles
  44583. */
  44584. static FindFallbackWithProfileId(profileId: string): string[];
  44585. /**
  44586. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44587. * The order of search:
  44588. *
  44589. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44590. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44591. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44592. * 4) return the generic trigger controller if none were found
  44593. *
  44594. * @param xrInput the xrInput to which a new controller is initialized
  44595. * @param scene the scene to which the model will be added
  44596. * @param forceProfile force a certain profile for this controller
  44597. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44598. */
  44599. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44600. /**
  44601. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44602. *
  44603. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44604. *
  44605. * @param type the profile type to register
  44606. * @param constructFunction the function to be called when loading this profile
  44607. */
  44608. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44609. /**
  44610. * Register a fallback to a specific profile.
  44611. * @param profileId the profileId that will receive the fallbacks
  44612. * @param fallbacks A list of fallback profiles
  44613. */
  44614. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44615. /**
  44616. * Will update the list of profiles available in the repository
  44617. * @return a promise that resolves to a map of profiles available online
  44618. */
  44619. static UpdateProfilesList(): Promise<{
  44620. [profile: string]: string;
  44621. }>;
  44622. private static _LoadProfileFromRepository;
  44623. private static _LoadProfilesFromAvailableControllers;
  44624. }
  44625. }
  44626. declare module BABYLON {
  44627. /**
  44628. * Configuration options for the WebXR controller creation
  44629. */
  44630. export interface IWebXRControllerOptions {
  44631. /**
  44632. * Should the controller mesh be animated when a user interacts with it
  44633. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44634. */
  44635. disableMotionControllerAnimation?: boolean;
  44636. /**
  44637. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44638. */
  44639. doNotLoadControllerMesh?: boolean;
  44640. /**
  44641. * Force a specific controller type for this controller.
  44642. * This can be used when creating your own profile or when testing different controllers
  44643. */
  44644. forceControllerProfile?: string;
  44645. }
  44646. /**
  44647. * Represents an XR controller
  44648. */
  44649. export class WebXRInputSource {
  44650. private _scene;
  44651. /** The underlying input source for the controller */
  44652. inputSource: XRInputSource;
  44653. private _options;
  44654. private _tmpQuaternion;
  44655. private _tmpVector;
  44656. private _uniqueId;
  44657. /**
  44658. * 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
  44659. */
  44660. grip?: AbstractMesh;
  44661. /**
  44662. * If available, this is the gamepad object related to this controller.
  44663. * Using this object it is possible to get click events and trackpad changes of the
  44664. * webxr controller that is currently being used.
  44665. */
  44666. motionController?: WebXRAbstractMotionController;
  44667. /**
  44668. * Event that fires when the controller is removed/disposed.
  44669. * The object provided as event data is this controller, after associated assets were disposed.
  44670. * uniqueId is still available.
  44671. */
  44672. onDisposeObservable: Observable<WebXRInputSource>;
  44673. /**
  44674. * Will be triggered when the mesh associated with the motion controller is done loading.
  44675. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44676. * A shortened version of controller -> motion controller -> on mesh loaded.
  44677. */
  44678. onMeshLoadedObservable: Observable<AbstractMesh>;
  44679. /**
  44680. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44681. */
  44682. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44683. /**
  44684. * Pointer which can be used to select objects or attach a visible laser to
  44685. */
  44686. pointer: AbstractMesh;
  44687. /**
  44688. * Creates the controller
  44689. * @see https://doc.babylonjs.com/how_to/webxr
  44690. * @param _scene the scene which the controller should be associated to
  44691. * @param inputSource the underlying input source for the controller
  44692. * @param _options options for this controller creation
  44693. */
  44694. constructor(_scene: Scene,
  44695. /** The underlying input source for the controller */
  44696. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44697. /**
  44698. * Get this controllers unique id
  44699. */
  44700. get uniqueId(): string;
  44701. /**
  44702. * Disposes of the object
  44703. */
  44704. dispose(): void;
  44705. /**
  44706. * Gets a world space ray coming from the pointer or grip
  44707. * @param result the resulting ray
  44708. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44709. */
  44710. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44711. /**
  44712. * Updates the controller pose based on the given XRFrame
  44713. * @param xrFrame xr frame to update the pose with
  44714. * @param referenceSpace reference space to use
  44715. */
  44716. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44717. }
  44718. }
  44719. declare module BABYLON {
  44720. /**
  44721. * The schema for initialization options of the XR Input class
  44722. */
  44723. export interface IWebXRInputOptions {
  44724. /**
  44725. * If set to true no model will be automatically loaded
  44726. */
  44727. doNotLoadControllerMeshes?: boolean;
  44728. /**
  44729. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44730. * If not found, the xr input profile data will be used.
  44731. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44732. */
  44733. forceInputProfile?: string;
  44734. /**
  44735. * Do not send a request to the controller repository to load the profile.
  44736. *
  44737. * Instead, use the controllers available in babylon itself.
  44738. */
  44739. disableOnlineControllerRepository?: boolean;
  44740. /**
  44741. * A custom URL for the controllers repository
  44742. */
  44743. customControllersRepositoryURL?: string;
  44744. /**
  44745. * Should the controller model's components not move according to the user input
  44746. */
  44747. disableControllerAnimation?: boolean;
  44748. }
  44749. /**
  44750. * XR input used to track XR inputs such as controllers/rays
  44751. */
  44752. export class WebXRInput implements IDisposable {
  44753. /**
  44754. * the xr session manager for this session
  44755. */
  44756. xrSessionManager: WebXRSessionManager;
  44757. /**
  44758. * the WebXR camera for this session. Mainly used for teleportation
  44759. */
  44760. xrCamera: WebXRCamera;
  44761. private readonly options;
  44762. /**
  44763. * XR controllers being tracked
  44764. */
  44765. controllers: Array<WebXRInputSource>;
  44766. private _frameObserver;
  44767. private _sessionEndedObserver;
  44768. private _sessionInitObserver;
  44769. /**
  44770. * Event when a controller has been connected/added
  44771. */
  44772. onControllerAddedObservable: Observable<WebXRInputSource>;
  44773. /**
  44774. * Event when a controller has been removed/disconnected
  44775. */
  44776. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44777. /**
  44778. * Initializes the WebXRInput
  44779. * @param xrSessionManager the xr session manager for this session
  44780. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44781. * @param options = initialization options for this xr input
  44782. */
  44783. constructor(
  44784. /**
  44785. * the xr session manager for this session
  44786. */
  44787. xrSessionManager: WebXRSessionManager,
  44788. /**
  44789. * the WebXR camera for this session. Mainly used for teleportation
  44790. */
  44791. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44792. private _onInputSourcesChange;
  44793. private _addAndRemoveControllers;
  44794. /**
  44795. * Disposes of the object
  44796. */
  44797. dispose(): void;
  44798. }
  44799. }
  44800. declare module BABYLON {
  44801. /**
  44802. * This is the base class for all WebXR features.
  44803. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44804. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44805. */
  44806. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44807. protected _xrSessionManager: WebXRSessionManager;
  44808. private _attached;
  44809. private _removeOnDetach;
  44810. /**
  44811. * Should auto-attach be disabled?
  44812. */
  44813. disableAutoAttach: boolean;
  44814. /**
  44815. * Construct a new (abstract) WebXR feature
  44816. * @param _xrSessionManager the xr session manager for this feature
  44817. */
  44818. constructor(_xrSessionManager: WebXRSessionManager);
  44819. /**
  44820. * Is this feature attached
  44821. */
  44822. get attached(): boolean;
  44823. /**
  44824. * attach this feature
  44825. *
  44826. * @param force should attachment be forced (even when already attached)
  44827. * @returns true if successful, false is failed or already attached
  44828. */
  44829. attach(force?: boolean): boolean;
  44830. /**
  44831. * detach this feature.
  44832. *
  44833. * @returns true if successful, false if failed or already detached
  44834. */
  44835. detach(): boolean;
  44836. /**
  44837. * Dispose this feature and all of the resources attached
  44838. */
  44839. dispose(): void;
  44840. /**
  44841. * This is used to register callbacks that will automatically be removed when detach is called.
  44842. * @param observable the observable to which the observer will be attached
  44843. * @param callback the callback to register
  44844. */
  44845. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44846. /**
  44847. * Code in this function will be executed on each xrFrame received from the browser.
  44848. * This function will not execute after the feature is detached.
  44849. * @param _xrFrame the current frame
  44850. */
  44851. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44852. }
  44853. }
  44854. declare module BABYLON {
  44855. /**
  44856. * Renders a layer on top of an existing scene
  44857. */
  44858. export class UtilityLayerRenderer implements IDisposable {
  44859. /** the original scene that will be rendered on top of */
  44860. originalScene: Scene;
  44861. private _pointerCaptures;
  44862. private _lastPointerEvents;
  44863. private static _DefaultUtilityLayer;
  44864. private static _DefaultKeepDepthUtilityLayer;
  44865. private _sharedGizmoLight;
  44866. private _renderCamera;
  44867. /**
  44868. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44869. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44870. * @returns the camera that is used when rendering the utility layer
  44871. */
  44872. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44873. /**
  44874. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44875. * @param cam the camera that should be used when rendering the utility layer
  44876. */
  44877. setRenderCamera(cam: Nullable<Camera>): void;
  44878. /**
  44879. * @hidden
  44880. * Light which used by gizmos to get light shading
  44881. */
  44882. _getSharedGizmoLight(): HemisphericLight;
  44883. /**
  44884. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44885. */
  44886. pickUtilitySceneFirst: boolean;
  44887. /**
  44888. * 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)
  44889. */
  44890. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44891. /**
  44892. * 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)
  44893. */
  44894. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44895. /**
  44896. * The scene that is rendered on top of the original scene
  44897. */
  44898. utilityLayerScene: Scene;
  44899. /**
  44900. * If the utility layer should automatically be rendered on top of existing scene
  44901. */
  44902. shouldRender: boolean;
  44903. /**
  44904. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44905. */
  44906. onlyCheckPointerDownEvents: boolean;
  44907. /**
  44908. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44909. */
  44910. processAllEvents: boolean;
  44911. /**
  44912. * Observable raised when the pointer move from the utility layer scene to the main scene
  44913. */
  44914. onPointerOutObservable: Observable<number>;
  44915. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44916. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44917. private _afterRenderObserver;
  44918. private _sceneDisposeObserver;
  44919. private _originalPointerObserver;
  44920. /**
  44921. * Instantiates a UtilityLayerRenderer
  44922. * @param originalScene the original scene that will be rendered on top of
  44923. * @param handleEvents boolean indicating if the utility layer should handle events
  44924. */
  44925. constructor(
  44926. /** the original scene that will be rendered on top of */
  44927. originalScene: Scene, handleEvents?: boolean);
  44928. private _notifyObservers;
  44929. /**
  44930. * Renders the utility layers scene on top of the original scene
  44931. */
  44932. render(): void;
  44933. /**
  44934. * Disposes of the renderer
  44935. */
  44936. dispose(): void;
  44937. private _updateCamera;
  44938. }
  44939. }
  44940. declare module BABYLON {
  44941. /**
  44942. * Options interface for the pointer selection module
  44943. */
  44944. export interface IWebXRControllerPointerSelectionOptions {
  44945. /**
  44946. * if provided, this scene will be used to render meshes.
  44947. */
  44948. customUtilityLayerScene?: Scene;
  44949. /**
  44950. * 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)
  44951. * If not disabled, the last picked point will be used to execute a pointer up event
  44952. * If disabled, pointer up event will be triggered right after the pointer down event.
  44953. * Used in screen and gaze target ray mode only
  44954. */
  44955. disablePointerUpOnTouchOut: boolean;
  44956. /**
  44957. * For gaze mode (time to select instead of press)
  44958. */
  44959. forceGazeMode: boolean;
  44960. /**
  44961. * 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
  44962. * to start a new countdown to the pointer down event.
  44963. * Defaults to 1.
  44964. */
  44965. gazeModePointerMovedFactor?: number;
  44966. /**
  44967. * Different button type to use instead of the main component
  44968. */
  44969. overrideButtonId?: string;
  44970. /**
  44971. * use this rendering group id for the meshes (optional)
  44972. */
  44973. renderingGroupId?: number;
  44974. /**
  44975. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44976. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44977. * 3000 means 3 seconds between pointing at something and selecting it
  44978. */
  44979. timeToSelect?: number;
  44980. /**
  44981. * Should meshes created here be added to a utility layer or the main scene
  44982. */
  44983. useUtilityLayer?: boolean;
  44984. /**
  44985. * the xr input to use with this pointer selection
  44986. */
  44987. xrInput: WebXRInput;
  44988. }
  44989. /**
  44990. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44991. */
  44992. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44993. private readonly _options;
  44994. private static _idCounter;
  44995. private _attachController;
  44996. private _controllers;
  44997. private _scene;
  44998. private _tmpVectorForPickCompare;
  44999. /**
  45000. * The module's name
  45001. */
  45002. static readonly Name: string;
  45003. /**
  45004. * The (Babylon) version of this module.
  45005. * This is an integer representing the implementation version.
  45006. * This number does not correspond to the WebXR specs version
  45007. */
  45008. static readonly Version: number;
  45009. /**
  45010. * Disable lighting on the laser pointer (so it will always be visible)
  45011. */
  45012. disablePointerLighting: boolean;
  45013. /**
  45014. * Disable lighting on the selection mesh (so it will always be visible)
  45015. */
  45016. disableSelectionMeshLighting: boolean;
  45017. /**
  45018. * Should the laser pointer be displayed
  45019. */
  45020. displayLaserPointer: boolean;
  45021. /**
  45022. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45023. */
  45024. displaySelectionMesh: boolean;
  45025. /**
  45026. * This color will be set to the laser pointer when selection is triggered
  45027. */
  45028. laserPointerPickedColor: Color3;
  45029. /**
  45030. * Default color of the laser pointer
  45031. */
  45032. lasterPointerDefaultColor: Color3;
  45033. /**
  45034. * default color of the selection ring
  45035. */
  45036. selectionMeshDefaultColor: Color3;
  45037. /**
  45038. * This color will be applied to the selection ring when selection is triggered
  45039. */
  45040. selectionMeshPickedColor: Color3;
  45041. /**
  45042. * Optional filter to be used for ray selection. This predicate shares behavior with
  45043. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45044. */
  45045. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45046. /**
  45047. * constructs a new background remover module
  45048. * @param _xrSessionManager the session manager for this module
  45049. * @param _options read-only options to be used in this module
  45050. */
  45051. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45052. /**
  45053. * attach this feature
  45054. * Will usually be called by the features manager
  45055. *
  45056. * @returns true if successful.
  45057. */
  45058. attach(): boolean;
  45059. /**
  45060. * detach this feature.
  45061. * Will usually be called by the features manager
  45062. *
  45063. * @returns true if successful.
  45064. */
  45065. detach(): boolean;
  45066. /**
  45067. * Will get the mesh under a specific pointer.
  45068. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45069. * @param controllerId the controllerId to check
  45070. * @returns The mesh under pointer or null if no mesh is under the pointer
  45071. */
  45072. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45073. /**
  45074. * Get the xr controller that correlates to the pointer id in the pointer event
  45075. *
  45076. * @param id the pointer id to search for
  45077. * @returns the controller that correlates to this id or null if not found
  45078. */
  45079. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45080. protected _onXRFrame(_xrFrame: XRFrame): void;
  45081. private _attachGazeMode;
  45082. private _attachScreenRayMode;
  45083. private _attachTrackedPointerRayMode;
  45084. private _convertNormalToDirectionOfRay;
  45085. private _detachController;
  45086. private _generateNewMeshPair;
  45087. private _pickingMoved;
  45088. private _updatePointerDistance;
  45089. }
  45090. }
  45091. declare module BABYLON {
  45092. /**
  45093. * Button which can be used to enter a different mode of XR
  45094. */
  45095. export class WebXREnterExitUIButton {
  45096. /** button element */
  45097. element: HTMLElement;
  45098. /** XR initialization options for the button */
  45099. sessionMode: XRSessionMode;
  45100. /** Reference space type */
  45101. referenceSpaceType: XRReferenceSpaceType;
  45102. /**
  45103. * Creates a WebXREnterExitUIButton
  45104. * @param element button element
  45105. * @param sessionMode XR initialization session mode
  45106. * @param referenceSpaceType the type of reference space to be used
  45107. */
  45108. constructor(
  45109. /** button element */
  45110. element: HTMLElement,
  45111. /** XR initialization options for the button */
  45112. sessionMode: XRSessionMode,
  45113. /** Reference space type */
  45114. referenceSpaceType: XRReferenceSpaceType);
  45115. /**
  45116. * Extendable function which can be used to update the button's visuals when the state changes
  45117. * @param activeButton the current active button in the UI
  45118. */
  45119. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45120. }
  45121. /**
  45122. * Options to create the webXR UI
  45123. */
  45124. export class WebXREnterExitUIOptions {
  45125. /**
  45126. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45127. */
  45128. customButtons?: Array<WebXREnterExitUIButton>;
  45129. /**
  45130. * A reference space type to use when creating the default button.
  45131. * Default is local-floor
  45132. */
  45133. referenceSpaceType?: XRReferenceSpaceType;
  45134. /**
  45135. * Context to enter xr with
  45136. */
  45137. renderTarget?: Nullable<WebXRRenderTarget>;
  45138. /**
  45139. * A session mode to use when creating the default button.
  45140. * Default is immersive-vr
  45141. */
  45142. sessionMode?: XRSessionMode;
  45143. }
  45144. /**
  45145. * UI to allow the user to enter/exit XR mode
  45146. */
  45147. export class WebXREnterExitUI implements IDisposable {
  45148. private scene;
  45149. /** version of the options passed to this UI */
  45150. options: WebXREnterExitUIOptions;
  45151. private _activeButton;
  45152. private _buttons;
  45153. private _overlay;
  45154. /**
  45155. * Fired every time the active button is changed.
  45156. *
  45157. * When xr is entered via a button that launches xr that button will be the callback parameter
  45158. *
  45159. * When exiting xr the callback parameter will be null)
  45160. */
  45161. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45162. /**
  45163. *
  45164. * @param scene babylon scene object to use
  45165. * @param options (read-only) version of the options passed to this UI
  45166. */
  45167. private constructor();
  45168. /**
  45169. * Creates UI to allow the user to enter/exit XR mode
  45170. * @param scene the scene to add the ui to
  45171. * @param helper the xr experience helper to enter/exit xr with
  45172. * @param options options to configure the UI
  45173. * @returns the created ui
  45174. */
  45175. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45176. /**
  45177. * Disposes of the XR UI component
  45178. */
  45179. dispose(): void;
  45180. private _updateButtons;
  45181. }
  45182. }
  45183. declare module BABYLON {
  45184. /**
  45185. * Class containing static functions to help procedurally build meshes
  45186. */
  45187. export class LinesBuilder {
  45188. /**
  45189. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45190. * * 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
  45191. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45192. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45193. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45194. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45195. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45196. * * 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
  45197. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45200. * @param name defines the name of the new line system
  45201. * @param options defines the options used to create the line system
  45202. * @param scene defines the hosting scene
  45203. * @returns a new line system mesh
  45204. */
  45205. static CreateLineSystem(name: string, options: {
  45206. lines: Vector3[][];
  45207. updatable?: boolean;
  45208. instance?: Nullable<LinesMesh>;
  45209. colors?: Nullable<Color4[][]>;
  45210. useVertexAlpha?: boolean;
  45211. }, scene: Nullable<Scene>): LinesMesh;
  45212. /**
  45213. * Creates a line mesh
  45214. * 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
  45215. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45216. * * The parameter `points` is an array successive Vector3
  45217. * * 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
  45218. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45219. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45220. * * When updating an instance, remember that only point positions can change, not the number of points
  45221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45223. * @param name defines the name of the new line system
  45224. * @param options defines the options used to create the line system
  45225. * @param scene defines the hosting scene
  45226. * @returns a new line mesh
  45227. */
  45228. static CreateLines(name: string, options: {
  45229. points: Vector3[];
  45230. updatable?: boolean;
  45231. instance?: Nullable<LinesMesh>;
  45232. colors?: Color4[];
  45233. useVertexAlpha?: boolean;
  45234. }, scene?: Nullable<Scene>): LinesMesh;
  45235. /**
  45236. * Creates a dashed line mesh
  45237. * * 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
  45238. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45239. * * The parameter `points` is an array successive Vector3
  45240. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45241. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45242. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45243. * * 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
  45244. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45245. * * When updating an instance, remember that only point positions can change, not the number of points
  45246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45247. * @param name defines the name of the mesh
  45248. * @param options defines the options used to create the mesh
  45249. * @param scene defines the hosting scene
  45250. * @returns the dashed line mesh
  45251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45252. */
  45253. static CreateDashedLines(name: string, options: {
  45254. points: Vector3[];
  45255. dashSize?: number;
  45256. gapSize?: number;
  45257. dashNb?: number;
  45258. updatable?: boolean;
  45259. instance?: LinesMesh;
  45260. useVertexAlpha?: boolean;
  45261. }, scene?: Nullable<Scene>): LinesMesh;
  45262. }
  45263. }
  45264. declare module BABYLON {
  45265. /**
  45266. * The options container for the teleportation module
  45267. */
  45268. export interface IWebXRTeleportationOptions {
  45269. /**
  45270. * if provided, this scene will be used to render meshes.
  45271. */
  45272. customUtilityLayerScene?: Scene;
  45273. /**
  45274. * Values to configure the default target mesh
  45275. */
  45276. defaultTargetMeshOptions?: {
  45277. /**
  45278. * Fill color of the teleportation area
  45279. */
  45280. teleportationFillColor?: string;
  45281. /**
  45282. * Border color for the teleportation area
  45283. */
  45284. teleportationBorderColor?: string;
  45285. /**
  45286. * Disable the mesh's animation sequence
  45287. */
  45288. disableAnimation?: boolean;
  45289. /**
  45290. * Disable lighting on the material or the ring and arrow
  45291. */
  45292. disableLighting?: boolean;
  45293. /**
  45294. * Override the default material of the torus and arrow
  45295. */
  45296. torusArrowMaterial?: Material;
  45297. };
  45298. /**
  45299. * A list of meshes to use as floor meshes.
  45300. * Meshes can be added and removed after initializing the feature using the
  45301. * addFloorMesh and removeFloorMesh functions
  45302. * If empty, rotation will still work
  45303. */
  45304. floorMeshes?: AbstractMesh[];
  45305. /**
  45306. * use this rendering group id for the meshes (optional)
  45307. */
  45308. renderingGroupId?: number;
  45309. /**
  45310. * Should teleportation move only to snap points
  45311. */
  45312. snapPointsOnly?: boolean;
  45313. /**
  45314. * An array of points to which the teleportation will snap to.
  45315. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45316. */
  45317. snapPositions?: Vector3[];
  45318. /**
  45319. * How close should the teleportation ray be in order to snap to position.
  45320. * Default to 0.8 units (meters)
  45321. */
  45322. snapToPositionRadius?: number;
  45323. /**
  45324. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45325. * If you want to support rotation, make sure your mesh has a direction indicator.
  45326. *
  45327. * When left untouched, the default mesh will be initialized.
  45328. */
  45329. teleportationTargetMesh?: AbstractMesh;
  45330. /**
  45331. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45332. */
  45333. timeToTeleport?: number;
  45334. /**
  45335. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45336. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45337. */
  45338. useMainComponentOnly?: boolean;
  45339. /**
  45340. * Should meshes created here be added to a utility layer or the main scene
  45341. */
  45342. useUtilityLayer?: boolean;
  45343. /**
  45344. * Babylon XR Input class for controller
  45345. */
  45346. xrInput: WebXRInput;
  45347. }
  45348. /**
  45349. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45350. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45351. * the input of the attached controllers.
  45352. */
  45353. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45354. private _options;
  45355. private _controllers;
  45356. private _currentTeleportationControllerId;
  45357. private _floorMeshes;
  45358. private _quadraticBezierCurve;
  45359. private _selectionFeature;
  45360. private _snapToPositions;
  45361. private _snappedToPoint;
  45362. private _teleportationRingMaterial?;
  45363. private _tmpRay;
  45364. private _tmpVector;
  45365. /**
  45366. * The module's name
  45367. */
  45368. static readonly Name: string;
  45369. /**
  45370. * The (Babylon) version of this module.
  45371. * This is an integer representing the implementation version.
  45372. * This number does not correspond to the webxr specs version
  45373. */
  45374. static readonly Version: number;
  45375. /**
  45376. * Is movement backwards enabled
  45377. */
  45378. backwardsMovementEnabled: boolean;
  45379. /**
  45380. * Distance to travel when moving backwards
  45381. */
  45382. backwardsTeleportationDistance: number;
  45383. /**
  45384. * The distance from the user to the inspection point in the direction of the controller
  45385. * A higher number will allow the user to move further
  45386. * defaults to 5 (meters, in xr units)
  45387. */
  45388. parabolicCheckRadius: number;
  45389. /**
  45390. * Should the module support parabolic ray on top of direct ray
  45391. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45392. * Very helpful when moving between floors / different heights
  45393. */
  45394. parabolicRayEnabled: boolean;
  45395. /**
  45396. * How much rotation should be applied when rotating right and left
  45397. */
  45398. rotationAngle: number;
  45399. /**
  45400. * Is rotation enabled when moving forward?
  45401. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45402. */
  45403. rotationEnabled: boolean;
  45404. /**
  45405. * constructs a new anchor system
  45406. * @param _xrSessionManager an instance of WebXRSessionManager
  45407. * @param _options configuration object for this feature
  45408. */
  45409. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45410. /**
  45411. * Get the snapPointsOnly flag
  45412. */
  45413. get snapPointsOnly(): boolean;
  45414. /**
  45415. * Sets the snapPointsOnly flag
  45416. * @param snapToPoints should teleportation be exclusively to snap points
  45417. */
  45418. set snapPointsOnly(snapToPoints: boolean);
  45419. /**
  45420. * Add a new mesh to the floor meshes array
  45421. * @param mesh the mesh to use as floor mesh
  45422. */
  45423. addFloorMesh(mesh: AbstractMesh): void;
  45424. /**
  45425. * Add a new snap-to point to fix teleportation to this position
  45426. * @param newSnapPoint The new Snap-To point
  45427. */
  45428. addSnapPoint(newSnapPoint: Vector3): void;
  45429. attach(): boolean;
  45430. detach(): boolean;
  45431. dispose(): void;
  45432. /**
  45433. * Remove a mesh from the floor meshes array
  45434. * @param mesh the mesh to remove
  45435. */
  45436. removeFloorMesh(mesh: AbstractMesh): void;
  45437. /**
  45438. * Remove a mesh from the floor meshes array using its name
  45439. * @param name the mesh name to remove
  45440. */
  45441. removeFloorMeshByName(name: string): void;
  45442. /**
  45443. * 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
  45444. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45445. * @returns was the point found and removed or not
  45446. */
  45447. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45448. /**
  45449. * This function sets a selection feature that will be disabled when
  45450. * the forward ray is shown and will be reattached when hidden.
  45451. * This is used to remove the selection rays when moving.
  45452. * @param selectionFeature the feature to disable when forward movement is enabled
  45453. */
  45454. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45455. protected _onXRFrame(_xrFrame: XRFrame): void;
  45456. private _attachController;
  45457. private _createDefaultTargetMesh;
  45458. private _detachController;
  45459. private _findClosestSnapPointWithRadius;
  45460. private _setTargetMeshPosition;
  45461. private _setTargetMeshVisibility;
  45462. private _showParabolicPath;
  45463. private _teleportForward;
  45464. }
  45465. }
  45466. declare module BABYLON {
  45467. /**
  45468. * Options for the default xr helper
  45469. */
  45470. export class WebXRDefaultExperienceOptions {
  45471. /**
  45472. * Enable or disable default UI to enter XR
  45473. */
  45474. disableDefaultUI?: boolean;
  45475. /**
  45476. * Should teleportation not initialize. defaults to false.
  45477. */
  45478. disableTeleportation?: boolean;
  45479. /**
  45480. * Floor meshes that will be used for teleport
  45481. */
  45482. floorMeshes?: Array<AbstractMesh>;
  45483. /**
  45484. * If set to true, the first frame will not be used to reset position
  45485. * The first frame is mainly used when copying transformation from the old camera
  45486. * Mainly used in AR
  45487. */
  45488. ignoreNativeCameraTransformation?: boolean;
  45489. /**
  45490. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45491. */
  45492. inputOptions?: IWebXRInputOptions;
  45493. /**
  45494. * optional configuration for the output canvas
  45495. */
  45496. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45497. /**
  45498. * optional UI options. This can be used among other to change session mode and reference space type
  45499. */
  45500. uiOptions?: WebXREnterExitUIOptions;
  45501. /**
  45502. * When loading teleportation and pointer select, use stable versions instead of latest.
  45503. */
  45504. useStablePlugins?: boolean;
  45505. }
  45506. /**
  45507. * Default experience which provides a similar setup to the previous webVRExperience
  45508. */
  45509. export class WebXRDefaultExperience {
  45510. /**
  45511. * Base experience
  45512. */
  45513. baseExperience: WebXRExperienceHelper;
  45514. /**
  45515. * Enables ui for entering/exiting xr
  45516. */
  45517. enterExitUI: WebXREnterExitUI;
  45518. /**
  45519. * Input experience extension
  45520. */
  45521. input: WebXRInput;
  45522. /**
  45523. * Enables laser pointer and selection
  45524. */
  45525. pointerSelection: WebXRControllerPointerSelection;
  45526. /**
  45527. * Default target xr should render to
  45528. */
  45529. renderTarget: WebXRRenderTarget;
  45530. /**
  45531. * Enables teleportation
  45532. */
  45533. teleportation: WebXRMotionControllerTeleportation;
  45534. private constructor();
  45535. /**
  45536. * Creates the default xr experience
  45537. * @param scene scene
  45538. * @param options options for basic configuration
  45539. * @returns resulting WebXRDefaultExperience
  45540. */
  45541. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45542. /**
  45543. * DIsposes of the experience helper
  45544. */
  45545. dispose(): void;
  45546. }
  45547. }
  45548. declare module BABYLON {
  45549. /**
  45550. * Options to modify the vr teleportation behavior.
  45551. */
  45552. export interface VRTeleportationOptions {
  45553. /**
  45554. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45555. */
  45556. floorMeshName?: string;
  45557. /**
  45558. * A list of meshes to be used as the teleportation floor. (default: empty)
  45559. */
  45560. floorMeshes?: Mesh[];
  45561. /**
  45562. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45563. */
  45564. teleportationMode?: number;
  45565. /**
  45566. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45567. */
  45568. teleportationTime?: number;
  45569. /**
  45570. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45571. */
  45572. teleportationSpeed?: number;
  45573. /**
  45574. * The easing function used in the animation or null for Linear. (default CircleEase)
  45575. */
  45576. easingFunction?: EasingFunction;
  45577. }
  45578. /**
  45579. * Options to modify the vr experience helper's behavior.
  45580. */
  45581. export interface VRExperienceHelperOptions extends WebVROptions {
  45582. /**
  45583. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45584. */
  45585. createDeviceOrientationCamera?: boolean;
  45586. /**
  45587. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45588. */
  45589. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45590. /**
  45591. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45592. */
  45593. laserToggle?: boolean;
  45594. /**
  45595. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45596. */
  45597. floorMeshes?: Mesh[];
  45598. /**
  45599. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45600. */
  45601. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45602. /**
  45603. * Defines if WebXR should be used instead of WebVR (if available)
  45604. */
  45605. useXR?: boolean;
  45606. }
  45607. /**
  45608. * Event containing information after VR has been entered
  45609. */
  45610. export class OnAfterEnteringVRObservableEvent {
  45611. /**
  45612. * If entering vr was successful
  45613. */
  45614. success: boolean;
  45615. }
  45616. /**
  45617. * Helps to quickly add VR support to an existing scene.
  45618. * See http://doc.babylonjs.com/how_to/webvr_helper
  45619. */
  45620. export class VRExperienceHelper {
  45621. /** Options to modify the vr experience helper's behavior. */
  45622. webVROptions: VRExperienceHelperOptions;
  45623. private _scene;
  45624. private _position;
  45625. private _btnVR;
  45626. private _btnVRDisplayed;
  45627. private _webVRsupported;
  45628. private _webVRready;
  45629. private _webVRrequesting;
  45630. private _webVRpresenting;
  45631. private _hasEnteredVR;
  45632. private _fullscreenVRpresenting;
  45633. private _inputElement;
  45634. private _webVRCamera;
  45635. private _vrDeviceOrientationCamera;
  45636. private _deviceOrientationCamera;
  45637. private _existingCamera;
  45638. private _onKeyDown;
  45639. private _onVrDisplayPresentChange;
  45640. private _onVRDisplayChanged;
  45641. private _onVRRequestPresentStart;
  45642. private _onVRRequestPresentComplete;
  45643. /**
  45644. * 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)
  45645. */
  45646. enableGazeEvenWhenNoPointerLock: boolean;
  45647. /**
  45648. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45649. */
  45650. exitVROnDoubleTap: boolean;
  45651. /**
  45652. * Observable raised right before entering VR.
  45653. */
  45654. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45655. /**
  45656. * Observable raised when entering VR has completed.
  45657. */
  45658. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45659. /**
  45660. * Observable raised when exiting VR.
  45661. */
  45662. onExitingVRObservable: Observable<VRExperienceHelper>;
  45663. /**
  45664. * Observable raised when controller mesh is loaded.
  45665. */
  45666. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45667. /** Return this.onEnteringVRObservable
  45668. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45669. */
  45670. get onEnteringVR(): Observable<VRExperienceHelper>;
  45671. /** Return this.onExitingVRObservable
  45672. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45673. */
  45674. get onExitingVR(): Observable<VRExperienceHelper>;
  45675. /** Return this.onControllerMeshLoadedObservable
  45676. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45677. */
  45678. get onControllerMeshLoaded(): Observable<WebVRController>;
  45679. private _rayLength;
  45680. private _useCustomVRButton;
  45681. private _teleportationRequested;
  45682. private _teleportActive;
  45683. private _floorMeshName;
  45684. private _floorMeshesCollection;
  45685. private _teleportationMode;
  45686. private _teleportationTime;
  45687. private _teleportationSpeed;
  45688. private _teleportationEasing;
  45689. private _rotationAllowed;
  45690. private _teleportBackwardsVector;
  45691. private _teleportationTarget;
  45692. private _isDefaultTeleportationTarget;
  45693. private _postProcessMove;
  45694. private _teleportationFillColor;
  45695. private _teleportationBorderColor;
  45696. private _rotationAngle;
  45697. private _haloCenter;
  45698. private _cameraGazer;
  45699. private _padSensibilityUp;
  45700. private _padSensibilityDown;
  45701. private _leftController;
  45702. private _rightController;
  45703. private _gazeColor;
  45704. private _laserColor;
  45705. private _pickedLaserColor;
  45706. private _pickedGazeColor;
  45707. /**
  45708. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45709. */
  45710. onNewMeshSelected: Observable<AbstractMesh>;
  45711. /**
  45712. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45713. * This observable will provide the mesh and the controller used to select the mesh
  45714. */
  45715. onMeshSelectedWithController: Observable<{
  45716. mesh: AbstractMesh;
  45717. controller: WebVRController;
  45718. }>;
  45719. /**
  45720. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45721. */
  45722. onNewMeshPicked: Observable<PickingInfo>;
  45723. private _circleEase;
  45724. /**
  45725. * Observable raised before camera teleportation
  45726. */
  45727. onBeforeCameraTeleport: Observable<Vector3>;
  45728. /**
  45729. * Observable raised after camera teleportation
  45730. */
  45731. onAfterCameraTeleport: Observable<Vector3>;
  45732. /**
  45733. * Observable raised when current selected mesh gets unselected
  45734. */
  45735. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45736. private _raySelectionPredicate;
  45737. /**
  45738. * To be optionaly changed by user to define custom ray selection
  45739. */
  45740. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45741. /**
  45742. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45743. */
  45744. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45745. /**
  45746. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45747. */
  45748. teleportationEnabled: boolean;
  45749. private _defaultHeight;
  45750. private _teleportationInitialized;
  45751. private _interactionsEnabled;
  45752. private _interactionsRequested;
  45753. private _displayGaze;
  45754. private _displayLaserPointer;
  45755. /**
  45756. * The mesh used to display where the user is going to teleport.
  45757. */
  45758. get teleportationTarget(): Mesh;
  45759. /**
  45760. * Sets the mesh to be used to display where the user is going to teleport.
  45761. */
  45762. set teleportationTarget(value: Mesh);
  45763. /**
  45764. * 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
  45765. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45766. * See http://doc.babylonjs.com/resources/baking_transformations
  45767. */
  45768. get gazeTrackerMesh(): Mesh;
  45769. set gazeTrackerMesh(value: Mesh);
  45770. /**
  45771. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45772. */
  45773. updateGazeTrackerScale: boolean;
  45774. /**
  45775. * If the gaze trackers color should be updated when selecting meshes
  45776. */
  45777. updateGazeTrackerColor: boolean;
  45778. /**
  45779. * If the controller laser color should be updated when selecting meshes
  45780. */
  45781. updateControllerLaserColor: boolean;
  45782. /**
  45783. * The gaze tracking mesh corresponding to the left controller
  45784. */
  45785. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45786. /**
  45787. * The gaze tracking mesh corresponding to the right controller
  45788. */
  45789. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45790. /**
  45791. * If the ray of the gaze should be displayed.
  45792. */
  45793. get displayGaze(): boolean;
  45794. /**
  45795. * Sets if the ray of the gaze should be displayed.
  45796. */
  45797. set displayGaze(value: boolean);
  45798. /**
  45799. * If the ray of the LaserPointer should be displayed.
  45800. */
  45801. get displayLaserPointer(): boolean;
  45802. /**
  45803. * Sets if the ray of the LaserPointer should be displayed.
  45804. */
  45805. set displayLaserPointer(value: boolean);
  45806. /**
  45807. * The deviceOrientationCamera used as the camera when not in VR.
  45808. */
  45809. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45810. /**
  45811. * Based on the current WebVR support, returns the current VR camera used.
  45812. */
  45813. get currentVRCamera(): Nullable<Camera>;
  45814. /**
  45815. * The webVRCamera which is used when in VR.
  45816. */
  45817. get webVRCamera(): WebVRFreeCamera;
  45818. /**
  45819. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45820. */
  45821. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45822. /**
  45823. * The html button that is used to trigger entering into VR.
  45824. */
  45825. get vrButton(): Nullable<HTMLButtonElement>;
  45826. private get _teleportationRequestInitiated();
  45827. /**
  45828. * Defines whether or not Pointer lock should be requested when switching to
  45829. * full screen.
  45830. */
  45831. requestPointerLockOnFullScreen: boolean;
  45832. /**
  45833. * If asking to force XR, this will be populated with the default xr experience
  45834. */
  45835. xr: WebXRDefaultExperience;
  45836. /**
  45837. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45838. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45839. */
  45840. xrTestDone: boolean;
  45841. /**
  45842. * Instantiates a VRExperienceHelper.
  45843. * Helps to quickly add VR support to an existing scene.
  45844. * @param scene The scene the VRExperienceHelper belongs to.
  45845. * @param webVROptions Options to modify the vr experience helper's behavior.
  45846. */
  45847. constructor(scene: Scene,
  45848. /** Options to modify the vr experience helper's behavior. */
  45849. webVROptions?: VRExperienceHelperOptions);
  45850. private completeVRInit;
  45851. private _onDefaultMeshLoaded;
  45852. private _onResize;
  45853. private _onFullscreenChange;
  45854. /**
  45855. * Gets a value indicating if we are currently in VR mode.
  45856. */
  45857. get isInVRMode(): boolean;
  45858. private onVrDisplayPresentChange;
  45859. private onVRDisplayChanged;
  45860. private moveButtonToBottomRight;
  45861. private displayVRButton;
  45862. private updateButtonVisibility;
  45863. private _cachedAngularSensibility;
  45864. /**
  45865. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45866. * Otherwise, will use the fullscreen API.
  45867. */
  45868. enterVR(): void;
  45869. /**
  45870. * Attempt to exit VR, or fullscreen.
  45871. */
  45872. exitVR(): void;
  45873. /**
  45874. * The position of the vr experience helper.
  45875. */
  45876. get position(): Vector3;
  45877. /**
  45878. * Sets the position of the vr experience helper.
  45879. */
  45880. set position(value: Vector3);
  45881. /**
  45882. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45883. */
  45884. enableInteractions(): void;
  45885. private get _noControllerIsActive();
  45886. private beforeRender;
  45887. private _isTeleportationFloor;
  45888. /**
  45889. * Adds a floor mesh to be used for teleportation.
  45890. * @param floorMesh the mesh to be used for teleportation.
  45891. */
  45892. addFloorMesh(floorMesh: Mesh): void;
  45893. /**
  45894. * Removes a floor mesh from being used for teleportation.
  45895. * @param floorMesh the mesh to be removed.
  45896. */
  45897. removeFloorMesh(floorMesh: Mesh): void;
  45898. /**
  45899. * Enables interactions and teleportation using the VR controllers and gaze.
  45900. * @param vrTeleportationOptions options to modify teleportation behavior.
  45901. */
  45902. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45903. private _onNewGamepadConnected;
  45904. private _tryEnableInteractionOnController;
  45905. private _onNewGamepadDisconnected;
  45906. private _enableInteractionOnController;
  45907. private _checkTeleportWithRay;
  45908. private _checkRotate;
  45909. private _checkTeleportBackwards;
  45910. private _enableTeleportationOnController;
  45911. private _createTeleportationCircles;
  45912. private _displayTeleportationTarget;
  45913. private _hideTeleportationTarget;
  45914. private _rotateCamera;
  45915. private _moveTeleportationSelectorTo;
  45916. private _workingVector;
  45917. private _workingQuaternion;
  45918. private _workingMatrix;
  45919. /**
  45920. * Time Constant Teleportation Mode
  45921. */
  45922. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45923. /**
  45924. * Speed Constant Teleportation Mode
  45925. */
  45926. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45927. /**
  45928. * Teleports the users feet to the desired location
  45929. * @param location The location where the user's feet should be placed
  45930. */
  45931. teleportCamera(location: Vector3): void;
  45932. private _convertNormalToDirectionOfRay;
  45933. private _castRayAndSelectObject;
  45934. private _notifySelectedMeshUnselected;
  45935. /**
  45936. * Permanently set new colors for the laser pointer
  45937. * @param color the new laser color
  45938. * @param pickedColor the new laser color when picked mesh detected
  45939. */
  45940. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45941. /**
  45942. * Set lighting enabled / disabled on the laser pointer of both controllers
  45943. * @param enabled should the lighting be enabled on the laser pointer
  45944. */
  45945. setLaserLightingState(enabled?: boolean): void;
  45946. /**
  45947. * Permanently set new colors for the gaze pointer
  45948. * @param color the new gaze color
  45949. * @param pickedColor the new gaze color when picked mesh detected
  45950. */
  45951. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45952. /**
  45953. * Sets the color of the laser ray from the vr controllers.
  45954. * @param color new color for the ray.
  45955. */
  45956. changeLaserColor(color: Color3): void;
  45957. /**
  45958. * Sets the color of the ray from the vr headsets gaze.
  45959. * @param color new color for the ray.
  45960. */
  45961. changeGazeColor(color: Color3): void;
  45962. /**
  45963. * Exits VR and disposes of the vr experience helper
  45964. */
  45965. dispose(): void;
  45966. /**
  45967. * Gets the name of the VRExperienceHelper class
  45968. * @returns "VRExperienceHelper"
  45969. */
  45970. getClassName(): string;
  45971. }
  45972. }
  45973. declare module BABYLON {
  45974. /**
  45975. * Contains an array of blocks representing the octree
  45976. */
  45977. export interface IOctreeContainer<T> {
  45978. /**
  45979. * Blocks within the octree
  45980. */
  45981. blocks: Array<OctreeBlock<T>>;
  45982. }
  45983. /**
  45984. * Class used to store a cell in an octree
  45985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45986. */
  45987. export class OctreeBlock<T> {
  45988. /**
  45989. * Gets the content of the current block
  45990. */
  45991. entries: T[];
  45992. /**
  45993. * Gets the list of block children
  45994. */
  45995. blocks: Array<OctreeBlock<T>>;
  45996. private _depth;
  45997. private _maxDepth;
  45998. private _capacity;
  45999. private _minPoint;
  46000. private _maxPoint;
  46001. private _boundingVectors;
  46002. private _creationFunc;
  46003. /**
  46004. * Creates a new block
  46005. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46006. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46007. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46008. * @param depth defines the current depth of this block in the octree
  46009. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46010. * @param creationFunc defines a callback to call when an element is added to the block
  46011. */
  46012. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46013. /**
  46014. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46015. */
  46016. get capacity(): number;
  46017. /**
  46018. * Gets the minimum vector (in world space) of the block's bounding box
  46019. */
  46020. get minPoint(): Vector3;
  46021. /**
  46022. * Gets the maximum vector (in world space) of the block's bounding box
  46023. */
  46024. get maxPoint(): Vector3;
  46025. /**
  46026. * Add a new element to this block
  46027. * @param entry defines the element to add
  46028. */
  46029. addEntry(entry: T): void;
  46030. /**
  46031. * Remove an element from this block
  46032. * @param entry defines the element to remove
  46033. */
  46034. removeEntry(entry: T): void;
  46035. /**
  46036. * Add an array of elements to this block
  46037. * @param entries defines the array of elements to add
  46038. */
  46039. addEntries(entries: T[]): void;
  46040. /**
  46041. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46042. * @param frustumPlanes defines the frustum planes to test
  46043. * @param selection defines the array to store current content if selection is positive
  46044. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46045. */
  46046. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46047. /**
  46048. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46049. * @param sphereCenter defines the bounding sphere center
  46050. * @param sphereRadius defines the bounding sphere radius
  46051. * @param selection defines the array to store current content if selection is positive
  46052. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46053. */
  46054. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46055. /**
  46056. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46057. * @param ray defines the ray to test with
  46058. * @param selection defines the array to store current content if selection is positive
  46059. */
  46060. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46061. /**
  46062. * Subdivide the content into child blocks (this block will then be empty)
  46063. */
  46064. createInnerBlocks(): void;
  46065. /**
  46066. * @hidden
  46067. */
  46068. 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;
  46069. }
  46070. }
  46071. declare module BABYLON {
  46072. /**
  46073. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46074. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46075. */
  46076. export class Octree<T> {
  46077. /** 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.) */
  46078. maxDepth: number;
  46079. /**
  46080. * Blocks within the octree containing objects
  46081. */
  46082. blocks: Array<OctreeBlock<T>>;
  46083. /**
  46084. * Content stored in the octree
  46085. */
  46086. dynamicContent: T[];
  46087. private _maxBlockCapacity;
  46088. private _selectionContent;
  46089. private _creationFunc;
  46090. /**
  46091. * Creates a octree
  46092. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46093. * @param creationFunc function to be used to instatiate the octree
  46094. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46095. * @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.)
  46096. */
  46097. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46098. /** 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.) */
  46099. maxDepth?: number);
  46100. /**
  46101. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46102. * @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);
  46103. * @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);
  46104. * @param entries meshes to be added to the octree blocks
  46105. */
  46106. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46107. /**
  46108. * Adds a mesh to the octree
  46109. * @param entry Mesh to add to the octree
  46110. */
  46111. addMesh(entry: T): void;
  46112. /**
  46113. * Remove an element from the octree
  46114. * @param entry defines the element to remove
  46115. */
  46116. removeMesh(entry: T): void;
  46117. /**
  46118. * Selects an array of meshes within the frustum
  46119. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46120. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46121. * @returns array of meshes within the frustum
  46122. */
  46123. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46124. /**
  46125. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46126. * @param sphereCenter defines the bounding sphere center
  46127. * @param sphereRadius defines the bounding sphere radius
  46128. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46129. * @returns an array of objects that intersect the sphere
  46130. */
  46131. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46132. /**
  46133. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46134. * @param ray defines the ray to test with
  46135. * @returns array of intersected objects
  46136. */
  46137. intersectsRay(ray: Ray): SmartArray<T>;
  46138. /**
  46139. * Adds a mesh into the octree block if it intersects the block
  46140. */
  46141. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46142. /**
  46143. * Adds a submesh into the octree block if it intersects the block
  46144. */
  46145. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46146. }
  46147. }
  46148. declare module BABYLON {
  46149. interface Scene {
  46150. /**
  46151. * @hidden
  46152. * Backing Filed
  46153. */
  46154. _selectionOctree: Octree<AbstractMesh>;
  46155. /**
  46156. * Gets the octree used to boost mesh selection (picking)
  46157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46158. */
  46159. selectionOctree: Octree<AbstractMesh>;
  46160. /**
  46161. * Creates or updates the octree used to boost selection (picking)
  46162. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46163. * @param maxCapacity defines the maximum capacity per leaf
  46164. * @param maxDepth defines the maximum depth of the octree
  46165. * @returns an octree of AbstractMesh
  46166. */
  46167. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46168. }
  46169. interface AbstractMesh {
  46170. /**
  46171. * @hidden
  46172. * Backing Field
  46173. */
  46174. _submeshesOctree: Octree<SubMesh>;
  46175. /**
  46176. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46177. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46178. * @param maxCapacity defines the maximum size of each block (64 by default)
  46179. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46180. * @returns the new octree
  46181. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46183. */
  46184. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46185. }
  46186. /**
  46187. * Defines the octree scene component responsible to manage any octrees
  46188. * in a given scene.
  46189. */
  46190. export class OctreeSceneComponent {
  46191. /**
  46192. * The component name help to identify the component in the list of scene components.
  46193. */
  46194. readonly name: string;
  46195. /**
  46196. * The scene the component belongs to.
  46197. */
  46198. scene: Scene;
  46199. /**
  46200. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46201. */
  46202. readonly checksIsEnabled: boolean;
  46203. /**
  46204. * Creates a new instance of the component for the given scene
  46205. * @param scene Defines the scene to register the component in
  46206. */
  46207. constructor(scene: Scene);
  46208. /**
  46209. * Registers the component in a given scene
  46210. */
  46211. register(): void;
  46212. /**
  46213. * Return the list of active meshes
  46214. * @returns the list of active meshes
  46215. */
  46216. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46217. /**
  46218. * Return the list of active sub meshes
  46219. * @param mesh The mesh to get the candidates sub meshes from
  46220. * @returns the list of active sub meshes
  46221. */
  46222. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46223. private _tempRay;
  46224. /**
  46225. * Return the list of sub meshes intersecting with a given local ray
  46226. * @param mesh defines the mesh to find the submesh for
  46227. * @param localRay defines the ray in local space
  46228. * @returns the list of intersecting sub meshes
  46229. */
  46230. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46231. /**
  46232. * Return the list of sub meshes colliding with a collider
  46233. * @param mesh defines the mesh to find the submesh for
  46234. * @param collider defines the collider to evaluate the collision against
  46235. * @returns the list of colliding sub meshes
  46236. */
  46237. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46238. /**
  46239. * Rebuilds the elements related to this component in case of
  46240. * context lost for instance.
  46241. */
  46242. rebuild(): void;
  46243. /**
  46244. * Disposes the component and the associated ressources.
  46245. */
  46246. dispose(): void;
  46247. }
  46248. }
  46249. declare module BABYLON {
  46250. /**
  46251. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46252. */
  46253. export class Gizmo implements IDisposable {
  46254. /** The utility layer the gizmo will be added to */
  46255. gizmoLayer: UtilityLayerRenderer;
  46256. /**
  46257. * The root mesh of the gizmo
  46258. */
  46259. _rootMesh: Mesh;
  46260. private _attachedMesh;
  46261. /**
  46262. * Ratio for the scale of the gizmo (Default: 1)
  46263. */
  46264. scaleRatio: number;
  46265. /**
  46266. * If a custom mesh has been set (Default: false)
  46267. */
  46268. protected _customMeshSet: boolean;
  46269. /**
  46270. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46271. * * When set, interactions will be enabled
  46272. */
  46273. get attachedMesh(): Nullable<AbstractMesh>;
  46274. set attachedMesh(value: Nullable<AbstractMesh>);
  46275. /**
  46276. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46277. * @param mesh The mesh to replace the default mesh of the gizmo
  46278. */
  46279. setCustomMesh(mesh: Mesh): void;
  46280. /**
  46281. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46282. */
  46283. updateGizmoRotationToMatchAttachedMesh: boolean;
  46284. /**
  46285. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46286. */
  46287. updateGizmoPositionToMatchAttachedMesh: boolean;
  46288. /**
  46289. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46290. */
  46291. updateScale: boolean;
  46292. protected _interactionsEnabled: boolean;
  46293. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46294. private _beforeRenderObserver;
  46295. private _tempVector;
  46296. /**
  46297. * Creates a gizmo
  46298. * @param gizmoLayer The utility layer the gizmo will be added to
  46299. */
  46300. constructor(
  46301. /** The utility layer the gizmo will be added to */
  46302. gizmoLayer?: UtilityLayerRenderer);
  46303. /**
  46304. * Updates the gizmo to match the attached mesh's position/rotation
  46305. */
  46306. protected _update(): void;
  46307. /**
  46308. * Disposes of the gizmo
  46309. */
  46310. dispose(): void;
  46311. }
  46312. }
  46313. declare module BABYLON {
  46314. /**
  46315. * Single plane drag gizmo
  46316. */
  46317. export class PlaneDragGizmo extends Gizmo {
  46318. /**
  46319. * Drag behavior responsible for the gizmos dragging interactions
  46320. */
  46321. dragBehavior: PointerDragBehavior;
  46322. private _pointerObserver;
  46323. /**
  46324. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46325. */
  46326. snapDistance: number;
  46327. /**
  46328. * Event that fires each time the gizmo snaps to a new location.
  46329. * * snapDistance is the the change in distance
  46330. */
  46331. onSnapObservable: Observable<{
  46332. snapDistance: number;
  46333. }>;
  46334. private _plane;
  46335. private _coloredMaterial;
  46336. private _hoverMaterial;
  46337. private _isEnabled;
  46338. private _parent;
  46339. /** @hidden */
  46340. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46341. /** @hidden */
  46342. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46343. /**
  46344. * Creates a PlaneDragGizmo
  46345. * @param gizmoLayer The utility layer the gizmo will be added to
  46346. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46347. * @param color The color of the gizmo
  46348. */
  46349. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46350. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46351. /**
  46352. * If the gizmo is enabled
  46353. */
  46354. set isEnabled(value: boolean);
  46355. get isEnabled(): boolean;
  46356. /**
  46357. * Disposes of the gizmo
  46358. */
  46359. dispose(): void;
  46360. }
  46361. }
  46362. declare module BABYLON {
  46363. /**
  46364. * Gizmo that enables dragging a mesh along 3 axis
  46365. */
  46366. export class PositionGizmo extends Gizmo {
  46367. /**
  46368. * Internal gizmo used for interactions on the x axis
  46369. */
  46370. xGizmo: AxisDragGizmo;
  46371. /**
  46372. * Internal gizmo used for interactions on the y axis
  46373. */
  46374. yGizmo: AxisDragGizmo;
  46375. /**
  46376. * Internal gizmo used for interactions on the z axis
  46377. */
  46378. zGizmo: AxisDragGizmo;
  46379. /**
  46380. * Internal gizmo used for interactions on the yz plane
  46381. */
  46382. xPlaneGizmo: PlaneDragGizmo;
  46383. /**
  46384. * Internal gizmo used for interactions on the xz plane
  46385. */
  46386. yPlaneGizmo: PlaneDragGizmo;
  46387. /**
  46388. * Internal gizmo used for interactions on the xy plane
  46389. */
  46390. zPlaneGizmo: PlaneDragGizmo;
  46391. /**
  46392. * private variables
  46393. */
  46394. private _meshAttached;
  46395. private _updateGizmoRotationToMatchAttachedMesh;
  46396. private _snapDistance;
  46397. private _scaleRatio;
  46398. /** Fires an event when any of it's sub gizmos are dragged */
  46399. onDragStartObservable: Observable<unknown>;
  46400. /** Fires an event when any of it's sub gizmos are released from dragging */
  46401. onDragEndObservable: Observable<unknown>;
  46402. /**
  46403. * If set to true, planar drag is enabled
  46404. */
  46405. private _planarGizmoEnabled;
  46406. get attachedMesh(): Nullable<AbstractMesh>;
  46407. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46408. /**
  46409. * Creates a PositionGizmo
  46410. * @param gizmoLayer The utility layer the gizmo will be added to
  46411. */
  46412. constructor(gizmoLayer?: UtilityLayerRenderer);
  46413. /**
  46414. * If the planar drag gizmo is enabled
  46415. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46416. */
  46417. set planarGizmoEnabled(value: boolean);
  46418. get planarGizmoEnabled(): boolean;
  46419. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46420. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46421. /**
  46422. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46423. */
  46424. set snapDistance(value: number);
  46425. get snapDistance(): number;
  46426. /**
  46427. * Ratio for the scale of the gizmo (Default: 1)
  46428. */
  46429. set scaleRatio(value: number);
  46430. get scaleRatio(): number;
  46431. /**
  46432. * Disposes of the gizmo
  46433. */
  46434. dispose(): void;
  46435. /**
  46436. * CustomMeshes are not supported by this gizmo
  46437. * @param mesh The mesh to replace the default mesh of the gizmo
  46438. */
  46439. setCustomMesh(mesh: Mesh): void;
  46440. }
  46441. }
  46442. declare module BABYLON {
  46443. /**
  46444. * Single axis drag gizmo
  46445. */
  46446. export class AxisDragGizmo extends Gizmo {
  46447. /**
  46448. * Drag behavior responsible for the gizmos dragging interactions
  46449. */
  46450. dragBehavior: PointerDragBehavior;
  46451. private _pointerObserver;
  46452. /**
  46453. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46454. */
  46455. snapDistance: number;
  46456. /**
  46457. * Event that fires each time the gizmo snaps to a new location.
  46458. * * snapDistance is the the change in distance
  46459. */
  46460. onSnapObservable: Observable<{
  46461. snapDistance: number;
  46462. }>;
  46463. private _isEnabled;
  46464. private _parent;
  46465. private _arrow;
  46466. private _coloredMaterial;
  46467. private _hoverMaterial;
  46468. /** @hidden */
  46469. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46470. /** @hidden */
  46471. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46472. /**
  46473. * Creates an AxisDragGizmo
  46474. * @param gizmoLayer The utility layer the gizmo will be added to
  46475. * @param dragAxis The axis which the gizmo will be able to drag on
  46476. * @param color The color of the gizmo
  46477. */
  46478. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46479. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46480. /**
  46481. * If the gizmo is enabled
  46482. */
  46483. set isEnabled(value: boolean);
  46484. get isEnabled(): boolean;
  46485. /**
  46486. * Disposes of the gizmo
  46487. */
  46488. dispose(): void;
  46489. }
  46490. }
  46491. declare module BABYLON.Debug {
  46492. /**
  46493. * The Axes viewer will show 3 axes in a specific point in space
  46494. */
  46495. export class AxesViewer {
  46496. private _xAxis;
  46497. private _yAxis;
  46498. private _zAxis;
  46499. private _scaleLinesFactor;
  46500. private _instanced;
  46501. /**
  46502. * Gets the hosting scene
  46503. */
  46504. scene: Scene;
  46505. /**
  46506. * Gets or sets a number used to scale line length
  46507. */
  46508. scaleLines: number;
  46509. /** Gets the node hierarchy used to render x-axis */
  46510. get xAxis(): TransformNode;
  46511. /** Gets the node hierarchy used to render y-axis */
  46512. get yAxis(): TransformNode;
  46513. /** Gets the node hierarchy used to render z-axis */
  46514. get zAxis(): TransformNode;
  46515. /**
  46516. * Creates a new AxesViewer
  46517. * @param scene defines the hosting scene
  46518. * @param scaleLines defines a number used to scale line length (1 by default)
  46519. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46520. * @param xAxis defines the node hierarchy used to render the x-axis
  46521. * @param yAxis defines the node hierarchy used to render the y-axis
  46522. * @param zAxis defines the node hierarchy used to render the z-axis
  46523. */
  46524. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46525. /**
  46526. * Force the viewer to update
  46527. * @param position defines the position of the viewer
  46528. * @param xaxis defines the x axis of the viewer
  46529. * @param yaxis defines the y axis of the viewer
  46530. * @param zaxis defines the z axis of the viewer
  46531. */
  46532. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46533. /**
  46534. * Creates an instance of this axes viewer.
  46535. * @returns a new axes viewer with instanced meshes
  46536. */
  46537. createInstance(): AxesViewer;
  46538. /** Releases resources */
  46539. dispose(): void;
  46540. private static _SetRenderingGroupId;
  46541. }
  46542. }
  46543. declare module BABYLON.Debug {
  46544. /**
  46545. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46546. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46547. */
  46548. export class BoneAxesViewer extends AxesViewer {
  46549. /**
  46550. * Gets or sets the target mesh where to display the axes viewer
  46551. */
  46552. mesh: Nullable<Mesh>;
  46553. /**
  46554. * Gets or sets the target bone where to display the axes viewer
  46555. */
  46556. bone: Nullable<Bone>;
  46557. /** Gets current position */
  46558. pos: Vector3;
  46559. /** Gets direction of X axis */
  46560. xaxis: Vector3;
  46561. /** Gets direction of Y axis */
  46562. yaxis: Vector3;
  46563. /** Gets direction of Z axis */
  46564. zaxis: Vector3;
  46565. /**
  46566. * Creates a new BoneAxesViewer
  46567. * @param scene defines the hosting scene
  46568. * @param bone defines the target bone
  46569. * @param mesh defines the target mesh
  46570. * @param scaleLines defines a scaling factor for line length (1 by default)
  46571. */
  46572. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46573. /**
  46574. * Force the viewer to update
  46575. */
  46576. update(): void;
  46577. /** Releases resources */
  46578. dispose(): void;
  46579. }
  46580. }
  46581. declare module BABYLON {
  46582. /**
  46583. * Interface used to define scene explorer extensibility option
  46584. */
  46585. export interface IExplorerExtensibilityOption {
  46586. /**
  46587. * Define the option label
  46588. */
  46589. label: string;
  46590. /**
  46591. * Defines the action to execute on click
  46592. */
  46593. action: (entity: any) => void;
  46594. }
  46595. /**
  46596. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46597. */
  46598. export interface IExplorerExtensibilityGroup {
  46599. /**
  46600. * Defines a predicate to test if a given type mut be extended
  46601. */
  46602. predicate: (entity: any) => boolean;
  46603. /**
  46604. * Gets the list of options added to a type
  46605. */
  46606. entries: IExplorerExtensibilityOption[];
  46607. }
  46608. /**
  46609. * Interface used to define the options to use to create the Inspector
  46610. */
  46611. export interface IInspectorOptions {
  46612. /**
  46613. * Display in overlay mode (default: false)
  46614. */
  46615. overlay?: boolean;
  46616. /**
  46617. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46618. */
  46619. globalRoot?: HTMLElement;
  46620. /**
  46621. * Display the Scene explorer
  46622. */
  46623. showExplorer?: boolean;
  46624. /**
  46625. * Display the property inspector
  46626. */
  46627. showInspector?: boolean;
  46628. /**
  46629. * Display in embed mode (both panes on the right)
  46630. */
  46631. embedMode?: boolean;
  46632. /**
  46633. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46634. */
  46635. handleResize?: boolean;
  46636. /**
  46637. * Allow the panes to popup (default: true)
  46638. */
  46639. enablePopup?: boolean;
  46640. /**
  46641. * Allow the panes to be closed by users (default: true)
  46642. */
  46643. enableClose?: boolean;
  46644. /**
  46645. * Optional list of extensibility entries
  46646. */
  46647. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46648. /**
  46649. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46650. */
  46651. inspectorURL?: string;
  46652. /**
  46653. * Optional initial tab (default to DebugLayerTab.Properties)
  46654. */
  46655. initialTab?: DebugLayerTab;
  46656. }
  46657. interface Scene {
  46658. /**
  46659. * @hidden
  46660. * Backing field
  46661. */
  46662. _debugLayer: DebugLayer;
  46663. /**
  46664. * Gets the debug layer (aka Inspector) associated with the scene
  46665. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46666. */
  46667. debugLayer: DebugLayer;
  46668. }
  46669. /**
  46670. * Enum of inspector action tab
  46671. */
  46672. export enum DebugLayerTab {
  46673. /**
  46674. * Properties tag (default)
  46675. */
  46676. Properties = 0,
  46677. /**
  46678. * Debug tab
  46679. */
  46680. Debug = 1,
  46681. /**
  46682. * Statistics tab
  46683. */
  46684. Statistics = 2,
  46685. /**
  46686. * Tools tab
  46687. */
  46688. Tools = 3,
  46689. /**
  46690. * Settings tab
  46691. */
  46692. Settings = 4
  46693. }
  46694. /**
  46695. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46696. * what is happening in your scene
  46697. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46698. */
  46699. export class DebugLayer {
  46700. /**
  46701. * Define the url to get the inspector script from.
  46702. * By default it uses the babylonjs CDN.
  46703. * @ignoreNaming
  46704. */
  46705. static InspectorURL: string;
  46706. private _scene;
  46707. private BJSINSPECTOR;
  46708. private _onPropertyChangedObservable?;
  46709. /**
  46710. * Observable triggered when a property is changed through the inspector.
  46711. */
  46712. get onPropertyChangedObservable(): any;
  46713. /**
  46714. * Instantiates a new debug layer.
  46715. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46716. * what is happening in your scene
  46717. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46718. * @param scene Defines the scene to inspect
  46719. */
  46720. constructor(scene: Scene);
  46721. /** Creates the inspector window. */
  46722. private _createInspector;
  46723. /**
  46724. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46725. * @param entity defines the entity to select
  46726. * @param lineContainerTitle defines the specific block to highlight
  46727. */
  46728. select(entity: any, lineContainerTitle?: string): void;
  46729. /** Get the inspector from bundle or global */
  46730. private _getGlobalInspector;
  46731. /**
  46732. * Get if the inspector is visible or not.
  46733. * @returns true if visible otherwise, false
  46734. */
  46735. isVisible(): boolean;
  46736. /**
  46737. * Hide the inspector and close its window.
  46738. */
  46739. hide(): void;
  46740. /**
  46741. * Launch the debugLayer.
  46742. * @param config Define the configuration of the inspector
  46743. * @return a promise fulfilled when the debug layer is visible
  46744. */
  46745. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46746. }
  46747. }
  46748. declare module BABYLON {
  46749. /**
  46750. * Class containing static functions to help procedurally build meshes
  46751. */
  46752. export class BoxBuilder {
  46753. /**
  46754. * Creates a box mesh
  46755. * * The parameter `size` sets the size (float) of each box side (default 1)
  46756. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46757. * * 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)
  46758. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46760. * * 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
  46761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46762. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46763. * @param name defines the name of the mesh
  46764. * @param options defines the options used to create the mesh
  46765. * @param scene defines the hosting scene
  46766. * @returns the box mesh
  46767. */
  46768. static CreateBox(name: string, options: {
  46769. size?: number;
  46770. width?: number;
  46771. height?: number;
  46772. depth?: number;
  46773. faceUV?: Vector4[];
  46774. faceColors?: Color4[];
  46775. sideOrientation?: number;
  46776. frontUVs?: Vector4;
  46777. backUVs?: Vector4;
  46778. wrap?: boolean;
  46779. topBaseAt?: number;
  46780. bottomBaseAt?: number;
  46781. updatable?: boolean;
  46782. }, scene?: Nullable<Scene>): Mesh;
  46783. }
  46784. }
  46785. declare module BABYLON.Debug {
  46786. /**
  46787. * Used to show the physics impostor around the specific mesh
  46788. */
  46789. export class PhysicsViewer {
  46790. /** @hidden */
  46791. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46792. /** @hidden */
  46793. protected _meshes: Array<Nullable<AbstractMesh>>;
  46794. /** @hidden */
  46795. protected _scene: Nullable<Scene>;
  46796. /** @hidden */
  46797. protected _numMeshes: number;
  46798. /** @hidden */
  46799. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46800. private _renderFunction;
  46801. private _utilityLayer;
  46802. private _debugBoxMesh;
  46803. private _debugSphereMesh;
  46804. private _debugCylinderMesh;
  46805. private _debugMaterial;
  46806. private _debugMeshMeshes;
  46807. /**
  46808. * Creates a new PhysicsViewer
  46809. * @param scene defines the hosting scene
  46810. */
  46811. constructor(scene: Scene);
  46812. /** @hidden */
  46813. protected _updateDebugMeshes(): void;
  46814. /**
  46815. * Renders a specified physic impostor
  46816. * @param impostor defines the impostor to render
  46817. * @param targetMesh defines the mesh represented by the impostor
  46818. * @returns the new debug mesh used to render the impostor
  46819. */
  46820. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46821. /**
  46822. * Hides a specified physic impostor
  46823. * @param impostor defines the impostor to hide
  46824. */
  46825. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46826. private _getDebugMaterial;
  46827. private _getDebugBoxMesh;
  46828. private _getDebugSphereMesh;
  46829. private _getDebugCylinderMesh;
  46830. private _getDebugMeshMesh;
  46831. private _getDebugMesh;
  46832. /** Releases all resources */
  46833. dispose(): void;
  46834. }
  46835. }
  46836. declare module BABYLON {
  46837. /**
  46838. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46839. * in order to better appreciate the issue one might have.
  46840. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46841. */
  46842. export class RayHelper {
  46843. /**
  46844. * Defines the ray we are currently tryin to visualize.
  46845. */
  46846. ray: Nullable<Ray>;
  46847. private _renderPoints;
  46848. private _renderLine;
  46849. private _renderFunction;
  46850. private _scene;
  46851. private _updateToMeshFunction;
  46852. private _attachedToMesh;
  46853. private _meshSpaceDirection;
  46854. private _meshSpaceOrigin;
  46855. /**
  46856. * Helper function to create a colored helper in a scene in one line.
  46857. * @param ray Defines the ray we are currently tryin to visualize
  46858. * @param scene Defines the scene the ray is used in
  46859. * @param color Defines the color we want to see the ray in
  46860. * @returns The newly created ray helper.
  46861. */
  46862. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46863. /**
  46864. * Instantiate a new ray helper.
  46865. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46866. * in order to better appreciate the issue one might have.
  46867. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46868. * @param ray Defines the ray we are currently tryin to visualize
  46869. */
  46870. constructor(ray: Ray);
  46871. /**
  46872. * Shows the ray we are willing to debug.
  46873. * @param scene Defines the scene the ray needs to be rendered in
  46874. * @param color Defines the color the ray needs to be rendered in
  46875. */
  46876. show(scene: Scene, color?: Color3): void;
  46877. /**
  46878. * Hides the ray we are debugging.
  46879. */
  46880. hide(): void;
  46881. private _render;
  46882. /**
  46883. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46884. * @param mesh Defines the mesh we want the helper attached to
  46885. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46886. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46887. * @param length Defines the length of the ray
  46888. */
  46889. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46890. /**
  46891. * Detach the ray helper from the mesh it has previously been attached to.
  46892. */
  46893. detachFromMesh(): void;
  46894. private _updateToMesh;
  46895. /**
  46896. * Dispose the helper and release its associated resources.
  46897. */
  46898. dispose(): void;
  46899. }
  46900. }
  46901. declare module BABYLON.Debug {
  46902. /**
  46903. * Class used to render a debug view of a given skeleton
  46904. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46905. */
  46906. export class SkeletonViewer {
  46907. /** defines the skeleton to render */
  46908. skeleton: Skeleton;
  46909. /** defines the mesh attached to the skeleton */
  46910. mesh: AbstractMesh;
  46911. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46912. autoUpdateBonesMatrices: boolean;
  46913. /** defines the rendering group id to use with the viewer */
  46914. renderingGroupId: number;
  46915. /** Gets or sets the color used to render the skeleton */
  46916. color: Color3;
  46917. private _scene;
  46918. private _debugLines;
  46919. private _debugMesh;
  46920. private _isEnabled;
  46921. private _renderFunction;
  46922. private _utilityLayer;
  46923. /**
  46924. * Returns the mesh used to render the bones
  46925. */
  46926. get debugMesh(): Nullable<LinesMesh>;
  46927. /**
  46928. * Creates a new SkeletonViewer
  46929. * @param skeleton defines the skeleton to render
  46930. * @param mesh defines the mesh attached to the skeleton
  46931. * @param scene defines the hosting scene
  46932. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46933. * @param renderingGroupId defines the rendering group id to use with the viewer
  46934. */
  46935. constructor(
  46936. /** defines the skeleton to render */
  46937. skeleton: Skeleton,
  46938. /** defines the mesh attached to the skeleton */
  46939. mesh: AbstractMesh, scene: Scene,
  46940. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46941. autoUpdateBonesMatrices?: boolean,
  46942. /** defines the rendering group id to use with the viewer */
  46943. renderingGroupId?: number);
  46944. /** Gets or sets a boolean indicating if the viewer is enabled */
  46945. set isEnabled(value: boolean);
  46946. get isEnabled(): boolean;
  46947. private _getBonePosition;
  46948. private _getLinesForBonesWithLength;
  46949. private _getLinesForBonesNoLength;
  46950. /** Update the viewer to sync with current skeleton state */
  46951. update(): void;
  46952. /** Release associated resources */
  46953. dispose(): void;
  46954. }
  46955. }
  46956. declare module BABYLON {
  46957. /**
  46958. * Options to create the null engine
  46959. */
  46960. export class NullEngineOptions {
  46961. /**
  46962. * Render width (Default: 512)
  46963. */
  46964. renderWidth: number;
  46965. /**
  46966. * Render height (Default: 256)
  46967. */
  46968. renderHeight: number;
  46969. /**
  46970. * Texture size (Default: 512)
  46971. */
  46972. textureSize: number;
  46973. /**
  46974. * If delta time between frames should be constant
  46975. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46976. */
  46977. deterministicLockstep: boolean;
  46978. /**
  46979. * Maximum about of steps between frames (Default: 4)
  46980. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46981. */
  46982. lockstepMaxSteps: number;
  46983. }
  46984. /**
  46985. * The null engine class provides support for headless version of babylon.js.
  46986. * This can be used in server side scenario or for testing purposes
  46987. */
  46988. export class NullEngine extends Engine {
  46989. private _options;
  46990. /**
  46991. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46993. * @returns true if engine is in deterministic lock step mode
  46994. */
  46995. isDeterministicLockStep(): boolean;
  46996. /**
  46997. * Gets the max steps when engine is running in deterministic lock step
  46998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46999. * @returns the max steps
  47000. */
  47001. getLockstepMaxSteps(): number;
  47002. /**
  47003. * Gets the current hardware scaling level.
  47004. * By default the hardware scaling level is computed from the window device ratio.
  47005. * 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.
  47006. * @returns a number indicating the current hardware scaling level
  47007. */
  47008. getHardwareScalingLevel(): number;
  47009. constructor(options?: NullEngineOptions);
  47010. /**
  47011. * Creates a vertex buffer
  47012. * @param vertices the data for the vertex buffer
  47013. * @returns the new WebGL static buffer
  47014. */
  47015. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47016. /**
  47017. * Creates a new index buffer
  47018. * @param indices defines the content of the index buffer
  47019. * @param updatable defines if the index buffer must be updatable
  47020. * @returns a new webGL buffer
  47021. */
  47022. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47023. /**
  47024. * Clear the current render buffer or the current render target (if any is set up)
  47025. * @param color defines the color to use
  47026. * @param backBuffer defines if the back buffer must be cleared
  47027. * @param depth defines if the depth buffer must be cleared
  47028. * @param stencil defines if the stencil buffer must be cleared
  47029. */
  47030. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47031. /**
  47032. * Gets the current render width
  47033. * @param useScreen defines if screen size must be used (or the current render target if any)
  47034. * @returns a number defining the current render width
  47035. */
  47036. getRenderWidth(useScreen?: boolean): number;
  47037. /**
  47038. * Gets the current render height
  47039. * @param useScreen defines if screen size must be used (or the current render target if any)
  47040. * @returns a number defining the current render height
  47041. */
  47042. getRenderHeight(useScreen?: boolean): number;
  47043. /**
  47044. * Set the WebGL's viewport
  47045. * @param viewport defines the viewport element to be used
  47046. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47047. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47048. */
  47049. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47050. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47051. /**
  47052. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47053. * @param pipelineContext defines the pipeline context to use
  47054. * @param uniformsNames defines the list of uniform names
  47055. * @returns an array of webGL uniform locations
  47056. */
  47057. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47058. /**
  47059. * Gets the lsit of active attributes for a given webGL program
  47060. * @param pipelineContext defines the pipeline context to use
  47061. * @param attributesNames defines the list of attribute names to get
  47062. * @returns an array of indices indicating the offset of each attribute
  47063. */
  47064. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47065. /**
  47066. * Binds an effect to the webGL context
  47067. * @param effect defines the effect to bind
  47068. */
  47069. bindSamplers(effect: Effect): void;
  47070. /**
  47071. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47072. * @param effect defines the effect to activate
  47073. */
  47074. enableEffect(effect: Effect): void;
  47075. /**
  47076. * Set various states to the webGL context
  47077. * @param culling defines backface culling state
  47078. * @param zOffset defines the value to apply to zOffset (0 by default)
  47079. * @param force defines if states must be applied even if cache is up to date
  47080. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47081. */
  47082. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47083. /**
  47084. * Set the value of an uniform to an array of int32
  47085. * @param uniform defines the webGL uniform location where to store the value
  47086. * @param array defines the array of int32 to store
  47087. */
  47088. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47089. /**
  47090. * Set the value of an uniform to an array of int32 (stored as vec2)
  47091. * @param uniform defines the webGL uniform location where to store the value
  47092. * @param array defines the array of int32 to store
  47093. */
  47094. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47095. /**
  47096. * Set the value of an uniform to an array of int32 (stored as vec3)
  47097. * @param uniform defines the webGL uniform location where to store the value
  47098. * @param array defines the array of int32 to store
  47099. */
  47100. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47101. /**
  47102. * Set the value of an uniform to an array of int32 (stored as vec4)
  47103. * @param uniform defines the webGL uniform location where to store the value
  47104. * @param array defines the array of int32 to store
  47105. */
  47106. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47107. /**
  47108. * Set the value of an uniform to an array of float32
  47109. * @param uniform defines the webGL uniform location where to store the value
  47110. * @param array defines the array of float32 to store
  47111. */
  47112. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47113. /**
  47114. * Set the value of an uniform to an array of float32 (stored as vec2)
  47115. * @param uniform defines the webGL uniform location where to store the value
  47116. * @param array defines the array of float32 to store
  47117. */
  47118. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47119. /**
  47120. * Set the value of an uniform to an array of float32 (stored as vec3)
  47121. * @param uniform defines the webGL uniform location where to store the value
  47122. * @param array defines the array of float32 to store
  47123. */
  47124. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47125. /**
  47126. * Set the value of an uniform to an array of float32 (stored as vec4)
  47127. * @param uniform defines the webGL uniform location where to store the value
  47128. * @param array defines the array of float32 to store
  47129. */
  47130. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47131. /**
  47132. * Set the value of an uniform to an array of number
  47133. * @param uniform defines the webGL uniform location where to store the value
  47134. * @param array defines the array of number to store
  47135. */
  47136. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47137. /**
  47138. * Set the value of an uniform to an array of number (stored as vec2)
  47139. * @param uniform defines the webGL uniform location where to store the value
  47140. * @param array defines the array of number to store
  47141. */
  47142. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47143. /**
  47144. * Set the value of an uniform to an array of number (stored as vec3)
  47145. * @param uniform defines the webGL uniform location where to store the value
  47146. * @param array defines the array of number to store
  47147. */
  47148. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47149. /**
  47150. * Set the value of an uniform to an array of number (stored as vec4)
  47151. * @param uniform defines the webGL uniform location where to store the value
  47152. * @param array defines the array of number to store
  47153. */
  47154. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47155. /**
  47156. * Set the value of an uniform to an array of float32 (stored as matrices)
  47157. * @param uniform defines the webGL uniform location where to store the value
  47158. * @param matrices defines the array of float32 to store
  47159. */
  47160. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47161. /**
  47162. * Set the value of an uniform to a matrix (3x3)
  47163. * @param uniform defines the webGL uniform location where to store the value
  47164. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47165. */
  47166. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47167. /**
  47168. * Set the value of an uniform to a matrix (2x2)
  47169. * @param uniform defines the webGL uniform location where to store the value
  47170. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47171. */
  47172. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47173. /**
  47174. * Set the value of an uniform to a number (float)
  47175. * @param uniform defines the webGL uniform location where to store the value
  47176. * @param value defines the float number to store
  47177. */
  47178. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47179. /**
  47180. * Set the value of an uniform to a vec2
  47181. * @param uniform defines the webGL uniform location where to store the value
  47182. * @param x defines the 1st component of the value
  47183. * @param y defines the 2nd component of the value
  47184. */
  47185. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47186. /**
  47187. * Set the value of an uniform to a vec3
  47188. * @param uniform defines the webGL uniform location where to store the value
  47189. * @param x defines the 1st component of the value
  47190. * @param y defines the 2nd component of the value
  47191. * @param z defines the 3rd component of the value
  47192. */
  47193. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47194. /**
  47195. * Set the value of an uniform to a boolean
  47196. * @param uniform defines the webGL uniform location where to store the value
  47197. * @param bool defines the boolean to store
  47198. */
  47199. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47200. /**
  47201. * Set the value of an uniform to a vec4
  47202. * @param uniform defines the webGL uniform location where to store the value
  47203. * @param x defines the 1st component of the value
  47204. * @param y defines the 2nd component of the value
  47205. * @param z defines the 3rd component of the value
  47206. * @param w defines the 4th component of the value
  47207. */
  47208. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47209. /**
  47210. * Sets the current alpha mode
  47211. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47212. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47213. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47214. */
  47215. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47216. /**
  47217. * Bind webGl buffers directly to the webGL context
  47218. * @param vertexBuffers defines the vertex buffer to bind
  47219. * @param indexBuffer defines the index buffer to bind
  47220. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47221. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47222. * @param effect defines the effect associated with the vertex buffer
  47223. */
  47224. bindBuffers(vertexBuffers: {
  47225. [key: string]: VertexBuffer;
  47226. }, indexBuffer: DataBuffer, effect: Effect): void;
  47227. /**
  47228. * Force the entire cache to be cleared
  47229. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47230. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47231. */
  47232. wipeCaches(bruteForce?: boolean): void;
  47233. /**
  47234. * Send a draw order
  47235. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47236. * @param indexStart defines the starting index
  47237. * @param indexCount defines the number of index to draw
  47238. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47239. */
  47240. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47241. /**
  47242. * Draw a list of indexed primitives
  47243. * @param fillMode defines the primitive to use
  47244. * @param indexStart defines the starting index
  47245. * @param indexCount defines the number of index to draw
  47246. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47247. */
  47248. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47249. /**
  47250. * Draw a list of unindexed primitives
  47251. * @param fillMode defines the primitive to use
  47252. * @param verticesStart defines the index of first vertex to draw
  47253. * @param verticesCount defines the count of vertices to draw
  47254. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47255. */
  47256. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47257. /** @hidden */
  47258. _createTexture(): WebGLTexture;
  47259. /** @hidden */
  47260. _releaseTexture(texture: InternalTexture): void;
  47261. /**
  47262. * Usually called from Texture.ts.
  47263. * Passed information to create a WebGLTexture
  47264. * @param urlArg defines a value which contains one of the following:
  47265. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47266. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47267. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47268. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47269. * @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)
  47270. * @param scene needed for loading to the correct scene
  47271. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47272. * @param onLoad optional callback to be called upon successful completion
  47273. * @param onError optional callback to be called upon failure
  47274. * @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
  47275. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47276. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47277. * @param forcedExtension defines the extension to use to pick the right loader
  47278. * @param mimeType defines an optional mime type
  47279. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47280. */
  47281. 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;
  47282. /**
  47283. * Creates a new render target texture
  47284. * @param size defines the size of the texture
  47285. * @param options defines the options used to create the texture
  47286. * @returns a new render target texture stored in an InternalTexture
  47287. */
  47288. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47289. /**
  47290. * Update the sampling mode of a given texture
  47291. * @param samplingMode defines the required sampling mode
  47292. * @param texture defines the texture to update
  47293. */
  47294. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47295. /**
  47296. * Binds the frame buffer to the specified texture.
  47297. * @param texture The texture to render to or null for the default canvas
  47298. * @param faceIndex The face of the texture to render to in case of cube texture
  47299. * @param requiredWidth The width of the target to render to
  47300. * @param requiredHeight The height of the target to render to
  47301. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47302. * @param lodLevel defines le lod level to bind to the frame buffer
  47303. */
  47304. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47305. /**
  47306. * Unbind the current render target texture from the webGL context
  47307. * @param texture defines the render target texture to unbind
  47308. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47309. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47310. */
  47311. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47312. /**
  47313. * Creates a dynamic vertex buffer
  47314. * @param vertices the data for the dynamic vertex buffer
  47315. * @returns the new WebGL dynamic buffer
  47316. */
  47317. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47318. /**
  47319. * Update the content of a dynamic texture
  47320. * @param texture defines the texture to update
  47321. * @param canvas defines the canvas containing the source
  47322. * @param invertY defines if data must be stored with Y axis inverted
  47323. * @param premulAlpha defines if alpha is stored as premultiplied
  47324. * @param format defines the format of the data
  47325. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47326. */
  47327. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47328. /**
  47329. * Gets a boolean indicating if all created effects are ready
  47330. * @returns true if all effects are ready
  47331. */
  47332. areAllEffectsReady(): boolean;
  47333. /**
  47334. * @hidden
  47335. * Get the current error code of the webGL context
  47336. * @returns the error code
  47337. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47338. */
  47339. getError(): number;
  47340. /** @hidden */
  47341. _getUnpackAlignement(): number;
  47342. /** @hidden */
  47343. _unpackFlipY(value: boolean): void;
  47344. /**
  47345. * Update a dynamic index buffer
  47346. * @param indexBuffer defines the target index buffer
  47347. * @param indices defines the data to update
  47348. * @param offset defines the offset in the target index buffer where update should start
  47349. */
  47350. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47351. /**
  47352. * Updates a dynamic vertex buffer.
  47353. * @param vertexBuffer the vertex buffer to update
  47354. * @param vertices the data used to update the vertex buffer
  47355. * @param byteOffset the byte offset of the data (optional)
  47356. * @param byteLength the byte length of the data (optional)
  47357. */
  47358. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47359. /** @hidden */
  47360. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47361. /** @hidden */
  47362. _bindTexture(channel: number, texture: InternalTexture): void;
  47363. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47364. /**
  47365. * 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
  47366. */
  47367. releaseEffects(): void;
  47368. displayLoadingUI(): void;
  47369. hideLoadingUI(): void;
  47370. /** @hidden */
  47371. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47372. /** @hidden */
  47373. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47374. /** @hidden */
  47375. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47376. /** @hidden */
  47377. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47378. }
  47379. }
  47380. declare module BABYLON {
  47381. /**
  47382. * @hidden
  47383. **/
  47384. export class _TimeToken {
  47385. _startTimeQuery: Nullable<WebGLQuery>;
  47386. _endTimeQuery: Nullable<WebGLQuery>;
  47387. _timeElapsedQuery: Nullable<WebGLQuery>;
  47388. _timeElapsedQueryEnded: boolean;
  47389. }
  47390. }
  47391. declare module BABYLON {
  47392. /** @hidden */
  47393. export class _OcclusionDataStorage {
  47394. /** @hidden */
  47395. occlusionInternalRetryCounter: number;
  47396. /** @hidden */
  47397. isOcclusionQueryInProgress: boolean;
  47398. /** @hidden */
  47399. isOccluded: boolean;
  47400. /** @hidden */
  47401. occlusionRetryCount: number;
  47402. /** @hidden */
  47403. occlusionType: number;
  47404. /** @hidden */
  47405. occlusionQueryAlgorithmType: number;
  47406. }
  47407. interface Engine {
  47408. /**
  47409. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47410. * @return the new query
  47411. */
  47412. createQuery(): WebGLQuery;
  47413. /**
  47414. * Delete and release a webGL query
  47415. * @param query defines the query to delete
  47416. * @return the current engine
  47417. */
  47418. deleteQuery(query: WebGLQuery): Engine;
  47419. /**
  47420. * Check if a given query has resolved and got its value
  47421. * @param query defines the query to check
  47422. * @returns true if the query got its value
  47423. */
  47424. isQueryResultAvailable(query: WebGLQuery): boolean;
  47425. /**
  47426. * Gets the value of a given query
  47427. * @param query defines the query to check
  47428. * @returns the value of the query
  47429. */
  47430. getQueryResult(query: WebGLQuery): number;
  47431. /**
  47432. * Initiates an occlusion query
  47433. * @param algorithmType defines the algorithm to use
  47434. * @param query defines the query to use
  47435. * @returns the current engine
  47436. * @see http://doc.babylonjs.com/features/occlusionquery
  47437. */
  47438. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47439. /**
  47440. * Ends an occlusion query
  47441. * @see http://doc.babylonjs.com/features/occlusionquery
  47442. * @param algorithmType defines the algorithm to use
  47443. * @returns the current engine
  47444. */
  47445. endOcclusionQuery(algorithmType: number): Engine;
  47446. /**
  47447. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47448. * Please note that only one query can be issued at a time
  47449. * @returns a time token used to track the time span
  47450. */
  47451. startTimeQuery(): Nullable<_TimeToken>;
  47452. /**
  47453. * Ends a time query
  47454. * @param token defines the token used to measure the time span
  47455. * @returns the time spent (in ns)
  47456. */
  47457. endTimeQuery(token: _TimeToken): int;
  47458. /** @hidden */
  47459. _currentNonTimestampToken: Nullable<_TimeToken>;
  47460. /** @hidden */
  47461. _createTimeQuery(): WebGLQuery;
  47462. /** @hidden */
  47463. _deleteTimeQuery(query: WebGLQuery): void;
  47464. /** @hidden */
  47465. _getGlAlgorithmType(algorithmType: number): number;
  47466. /** @hidden */
  47467. _getTimeQueryResult(query: WebGLQuery): any;
  47468. /** @hidden */
  47469. _getTimeQueryAvailability(query: WebGLQuery): any;
  47470. }
  47471. interface AbstractMesh {
  47472. /**
  47473. * Backing filed
  47474. * @hidden
  47475. */
  47476. __occlusionDataStorage: _OcclusionDataStorage;
  47477. /**
  47478. * Access property
  47479. * @hidden
  47480. */
  47481. _occlusionDataStorage: _OcclusionDataStorage;
  47482. /**
  47483. * 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.
  47484. * The default value is -1 which means don't break the query and wait till the result
  47485. * @see http://doc.babylonjs.com/features/occlusionquery
  47486. */
  47487. occlusionRetryCount: number;
  47488. /**
  47489. * 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:
  47490. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47491. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47492. * * 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.
  47493. * @see http://doc.babylonjs.com/features/occlusionquery
  47494. */
  47495. occlusionType: number;
  47496. /**
  47497. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47498. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47499. * * 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.
  47500. * @see http://doc.babylonjs.com/features/occlusionquery
  47501. */
  47502. occlusionQueryAlgorithmType: number;
  47503. /**
  47504. * 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
  47505. * @see http://doc.babylonjs.com/features/occlusionquery
  47506. */
  47507. isOccluded: boolean;
  47508. /**
  47509. * Flag to check the progress status of the query
  47510. * @see http://doc.babylonjs.com/features/occlusionquery
  47511. */
  47512. isOcclusionQueryInProgress: boolean;
  47513. }
  47514. }
  47515. declare module BABYLON {
  47516. /** @hidden */
  47517. export var _forceTransformFeedbackToBundle: boolean;
  47518. interface Engine {
  47519. /**
  47520. * Creates a webGL transform feedback object
  47521. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47522. * @returns the webGL transform feedback object
  47523. */
  47524. createTransformFeedback(): WebGLTransformFeedback;
  47525. /**
  47526. * Delete a webGL transform feedback object
  47527. * @param value defines the webGL transform feedback object to delete
  47528. */
  47529. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47530. /**
  47531. * Bind a webGL transform feedback object to the webgl context
  47532. * @param value defines the webGL transform feedback object to bind
  47533. */
  47534. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47535. /**
  47536. * Begins a transform feedback operation
  47537. * @param usePoints defines if points or triangles must be used
  47538. */
  47539. beginTransformFeedback(usePoints: boolean): void;
  47540. /**
  47541. * Ends a transform feedback operation
  47542. */
  47543. endTransformFeedback(): void;
  47544. /**
  47545. * Specify the varyings to use with transform feedback
  47546. * @param program defines the associated webGL program
  47547. * @param value defines the list of strings representing the varying names
  47548. */
  47549. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47550. /**
  47551. * Bind a webGL buffer for a transform feedback operation
  47552. * @param value defines the webGL buffer to bind
  47553. */
  47554. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47555. }
  47556. }
  47557. declare module BABYLON {
  47558. /**
  47559. * Creation options of the multi render target texture.
  47560. */
  47561. export interface IMultiRenderTargetOptions {
  47562. /**
  47563. * Define if the texture needs to create mip maps after render.
  47564. */
  47565. generateMipMaps?: boolean;
  47566. /**
  47567. * Define the types of all the draw buffers we want to create
  47568. */
  47569. types?: number[];
  47570. /**
  47571. * Define the sampling modes of all the draw buffers we want to create
  47572. */
  47573. samplingModes?: number[];
  47574. /**
  47575. * Define if a depth buffer is required
  47576. */
  47577. generateDepthBuffer?: boolean;
  47578. /**
  47579. * Define if a stencil buffer is required
  47580. */
  47581. generateStencilBuffer?: boolean;
  47582. /**
  47583. * Define if a depth texture is required instead of a depth buffer
  47584. */
  47585. generateDepthTexture?: boolean;
  47586. /**
  47587. * Define the number of desired draw buffers
  47588. */
  47589. textureCount?: number;
  47590. /**
  47591. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47592. */
  47593. doNotChangeAspectRatio?: boolean;
  47594. /**
  47595. * Define the default type of the buffers we are creating
  47596. */
  47597. defaultType?: number;
  47598. }
  47599. /**
  47600. * A multi render target, like a render target provides the ability to render to a texture.
  47601. * Unlike the render target, it can render to several draw buffers in one draw.
  47602. * This is specially interesting in deferred rendering or for any effects requiring more than
  47603. * just one color from a single pass.
  47604. */
  47605. export class MultiRenderTarget extends RenderTargetTexture {
  47606. private _internalTextures;
  47607. private _textures;
  47608. private _multiRenderTargetOptions;
  47609. /**
  47610. * Get if draw buffers are currently supported by the used hardware and browser.
  47611. */
  47612. get isSupported(): boolean;
  47613. /**
  47614. * Get the list of textures generated by the multi render target.
  47615. */
  47616. get textures(): Texture[];
  47617. /**
  47618. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47619. */
  47620. get depthTexture(): Texture;
  47621. /**
  47622. * Set the wrapping mode on U of all the textures we are rendering to.
  47623. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47624. */
  47625. set wrapU(wrap: number);
  47626. /**
  47627. * Set the wrapping mode on V of all the textures we are rendering to.
  47628. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47629. */
  47630. set wrapV(wrap: number);
  47631. /**
  47632. * Instantiate a new multi render target texture.
  47633. * A multi render target, like a render target provides the ability to render to a texture.
  47634. * Unlike the render target, it can render to several draw buffers in one draw.
  47635. * This is specially interesting in deferred rendering or for any effects requiring more than
  47636. * just one color from a single pass.
  47637. * @param name Define the name of the texture
  47638. * @param size Define the size of the buffers to render to
  47639. * @param count Define the number of target we are rendering into
  47640. * @param scene Define the scene the texture belongs to
  47641. * @param options Define the options used to create the multi render target
  47642. */
  47643. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47644. /** @hidden */
  47645. _rebuild(): void;
  47646. private _createInternalTextures;
  47647. private _createTextures;
  47648. /**
  47649. * Define the number of samples used if MSAA is enabled.
  47650. */
  47651. get samples(): number;
  47652. set samples(value: number);
  47653. /**
  47654. * Resize all the textures in the multi render target.
  47655. * Be carrefull as it will recreate all the data in the new texture.
  47656. * @param size Define the new size
  47657. */
  47658. resize(size: any): void;
  47659. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47660. /**
  47661. * Dispose the render targets and their associated resources
  47662. */
  47663. dispose(): void;
  47664. /**
  47665. * Release all the underlying texture used as draw buffers.
  47666. */
  47667. releaseInternalTextures(): void;
  47668. }
  47669. }
  47670. declare module BABYLON {
  47671. interface ThinEngine {
  47672. /**
  47673. * Unbind a list of render target textures from the webGL context
  47674. * This is used only when drawBuffer extension or webGL2 are active
  47675. * @param textures defines the render target textures to unbind
  47676. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47677. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47678. */
  47679. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47680. /**
  47681. * Create a multi render target texture
  47682. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47683. * @param size defines the size of the texture
  47684. * @param options defines the creation options
  47685. * @returns the cube texture as an InternalTexture
  47686. */
  47687. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47688. /**
  47689. * Update the sample count for a given multiple render target texture
  47690. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47691. * @param textures defines the textures to update
  47692. * @param samples defines the sample count to set
  47693. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47694. */
  47695. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47696. }
  47697. }
  47698. declare module BABYLON {
  47699. /**
  47700. * Class used to define an additional view for the engine
  47701. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47702. */
  47703. export class EngineView {
  47704. /** Defines the canvas where to render the view */
  47705. target: HTMLCanvasElement;
  47706. /** Defines an optional camera used to render the view (will use active camera else) */
  47707. camera?: Camera;
  47708. }
  47709. interface Engine {
  47710. /**
  47711. * Gets or sets the HTML element to use for attaching events
  47712. */
  47713. inputElement: Nullable<HTMLElement>;
  47714. /**
  47715. * Gets the current engine view
  47716. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47717. */
  47718. activeView: Nullable<EngineView>;
  47719. /** Gets or sets the list of views */
  47720. views: EngineView[];
  47721. /**
  47722. * Register a new child canvas
  47723. * @param canvas defines the canvas to register
  47724. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47725. * @returns the associated view
  47726. */
  47727. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47728. /**
  47729. * Remove a registered child canvas
  47730. * @param canvas defines the canvas to remove
  47731. * @returns the current engine
  47732. */
  47733. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47734. }
  47735. }
  47736. declare module BABYLON {
  47737. interface Engine {
  47738. /** @hidden */
  47739. _excludedCompressedTextures: string[];
  47740. /** @hidden */
  47741. _textureFormatInUse: string;
  47742. /**
  47743. * Gets the list of texture formats supported
  47744. */
  47745. readonly texturesSupported: Array<string>;
  47746. /**
  47747. * Gets the texture format in use
  47748. */
  47749. readonly textureFormatInUse: Nullable<string>;
  47750. /**
  47751. * Set the compressed texture extensions or file names to skip.
  47752. *
  47753. * @param skippedFiles defines the list of those texture files you want to skip
  47754. * Example: [".dds", ".env", "myfile.png"]
  47755. */
  47756. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47757. /**
  47758. * Set the compressed texture format to use, based on the formats you have, and the formats
  47759. * supported by the hardware / browser.
  47760. *
  47761. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47762. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47763. * to API arguments needed to compressed textures. This puts the burden on the container
  47764. * generator to house the arcane code for determining these for current & future formats.
  47765. *
  47766. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47767. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47768. *
  47769. * Note: The result of this call is not taken into account when a texture is base64.
  47770. *
  47771. * @param formatsAvailable defines the list of those format families you have created
  47772. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47773. *
  47774. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47775. * @returns The extension selected.
  47776. */
  47777. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47778. }
  47779. }
  47780. declare module BABYLON {
  47781. /**
  47782. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47783. */
  47784. export interface CubeMapInfo {
  47785. /**
  47786. * The pixel array for the front face.
  47787. * This is stored in format, left to right, up to down format.
  47788. */
  47789. front: Nullable<ArrayBufferView>;
  47790. /**
  47791. * The pixel array for the back face.
  47792. * This is stored in format, left to right, up to down format.
  47793. */
  47794. back: Nullable<ArrayBufferView>;
  47795. /**
  47796. * The pixel array for the left face.
  47797. * This is stored in format, left to right, up to down format.
  47798. */
  47799. left: Nullable<ArrayBufferView>;
  47800. /**
  47801. * The pixel array for the right face.
  47802. * This is stored in format, left to right, up to down format.
  47803. */
  47804. right: Nullable<ArrayBufferView>;
  47805. /**
  47806. * The pixel array for the up face.
  47807. * This is stored in format, left to right, up to down format.
  47808. */
  47809. up: Nullable<ArrayBufferView>;
  47810. /**
  47811. * The pixel array for the down face.
  47812. * This is stored in format, left to right, up to down format.
  47813. */
  47814. down: Nullable<ArrayBufferView>;
  47815. /**
  47816. * The size of the cubemap stored.
  47817. *
  47818. * Each faces will be size * size pixels.
  47819. */
  47820. size: number;
  47821. /**
  47822. * The format of the texture.
  47823. *
  47824. * RGBA, RGB.
  47825. */
  47826. format: number;
  47827. /**
  47828. * The type of the texture data.
  47829. *
  47830. * UNSIGNED_INT, FLOAT.
  47831. */
  47832. type: number;
  47833. /**
  47834. * Specifies whether the texture is in gamma space.
  47835. */
  47836. gammaSpace: boolean;
  47837. }
  47838. /**
  47839. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47840. */
  47841. export class PanoramaToCubeMapTools {
  47842. private static FACE_FRONT;
  47843. private static FACE_BACK;
  47844. private static FACE_RIGHT;
  47845. private static FACE_LEFT;
  47846. private static FACE_DOWN;
  47847. private static FACE_UP;
  47848. /**
  47849. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47850. *
  47851. * @param float32Array The source data.
  47852. * @param inputWidth The width of the input panorama.
  47853. * @param inputHeight The height of the input panorama.
  47854. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47855. * @return The cubemap data
  47856. */
  47857. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47858. private static CreateCubemapTexture;
  47859. private static CalcProjectionSpherical;
  47860. }
  47861. }
  47862. declare module BABYLON {
  47863. /**
  47864. * Helper class dealing with the extraction of spherical polynomial dataArray
  47865. * from a cube map.
  47866. */
  47867. export class CubeMapToSphericalPolynomialTools {
  47868. private static FileFaces;
  47869. /**
  47870. * Converts a texture to the according Spherical Polynomial data.
  47871. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47872. *
  47873. * @param texture The texture to extract the information from.
  47874. * @return The Spherical Polynomial data.
  47875. */
  47876. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47877. /**
  47878. * Converts a cubemap to the according Spherical Polynomial data.
  47879. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47880. *
  47881. * @param cubeInfo The Cube map to extract the information from.
  47882. * @return The Spherical Polynomial data.
  47883. */
  47884. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47885. }
  47886. }
  47887. declare module BABYLON {
  47888. interface BaseTexture {
  47889. /**
  47890. * Get the polynomial representation of the texture data.
  47891. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47892. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47893. */
  47894. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47895. }
  47896. }
  47897. declare module BABYLON {
  47898. /** @hidden */
  47899. export var rgbdEncodePixelShader: {
  47900. name: string;
  47901. shader: string;
  47902. };
  47903. }
  47904. declare module BABYLON {
  47905. /** @hidden */
  47906. export var rgbdDecodePixelShader: {
  47907. name: string;
  47908. shader: string;
  47909. };
  47910. }
  47911. declare module BABYLON {
  47912. /**
  47913. * Raw texture data and descriptor sufficient for WebGL texture upload
  47914. */
  47915. export interface EnvironmentTextureInfo {
  47916. /**
  47917. * Version of the environment map
  47918. */
  47919. version: number;
  47920. /**
  47921. * Width of image
  47922. */
  47923. width: number;
  47924. /**
  47925. * Irradiance information stored in the file.
  47926. */
  47927. irradiance: any;
  47928. /**
  47929. * Specular information stored in the file.
  47930. */
  47931. specular: any;
  47932. }
  47933. /**
  47934. * Defines One Image in the file. It requires only the position in the file
  47935. * as well as the length.
  47936. */
  47937. interface BufferImageData {
  47938. /**
  47939. * Length of the image data.
  47940. */
  47941. length: number;
  47942. /**
  47943. * Position of the data from the null terminator delimiting the end of the JSON.
  47944. */
  47945. position: number;
  47946. }
  47947. /**
  47948. * Defines the specular data enclosed in the file.
  47949. * This corresponds to the version 1 of the data.
  47950. */
  47951. export interface EnvironmentTextureSpecularInfoV1 {
  47952. /**
  47953. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47954. */
  47955. specularDataPosition?: number;
  47956. /**
  47957. * This contains all the images data needed to reconstruct the cubemap.
  47958. */
  47959. mipmaps: Array<BufferImageData>;
  47960. /**
  47961. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47962. */
  47963. lodGenerationScale: number;
  47964. }
  47965. /**
  47966. * Sets of helpers addressing the serialization and deserialization of environment texture
  47967. * stored in a BabylonJS env file.
  47968. * Those files are usually stored as .env files.
  47969. */
  47970. export class EnvironmentTextureTools {
  47971. /**
  47972. * Magic number identifying the env file.
  47973. */
  47974. private static _MagicBytes;
  47975. /**
  47976. * Gets the environment info from an env file.
  47977. * @param data The array buffer containing the .env bytes.
  47978. * @returns the environment file info (the json header) if successfully parsed.
  47979. */
  47980. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47981. /**
  47982. * Creates an environment texture from a loaded cube texture.
  47983. * @param texture defines the cube texture to convert in env file
  47984. * @return a promise containing the environment data if succesfull.
  47985. */
  47986. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47987. /**
  47988. * Creates a JSON representation of the spherical data.
  47989. * @param texture defines the texture containing the polynomials
  47990. * @return the JSON representation of the spherical info
  47991. */
  47992. private static _CreateEnvTextureIrradiance;
  47993. /**
  47994. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47995. * @param data the image data
  47996. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47997. * @return the views described by info providing access to the underlying buffer
  47998. */
  47999. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48000. /**
  48001. * Uploads the texture info contained in the env file to the GPU.
  48002. * @param texture defines the internal texture to upload to
  48003. * @param data defines the data to load
  48004. * @param info defines the texture info retrieved through the GetEnvInfo method
  48005. * @returns a promise
  48006. */
  48007. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48008. private static _OnImageReadyAsync;
  48009. /**
  48010. * Uploads the levels of image data to the GPU.
  48011. * @param texture defines the internal texture to upload to
  48012. * @param imageData defines the array buffer views of image data [mipmap][face]
  48013. * @returns a promise
  48014. */
  48015. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48016. /**
  48017. * Uploads spherical polynomials information to the texture.
  48018. * @param texture defines the texture we are trying to upload the information to
  48019. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48020. */
  48021. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48022. /** @hidden */
  48023. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48024. }
  48025. }
  48026. declare module BABYLON {
  48027. /**
  48028. * Contains position and normal vectors for a vertex
  48029. */
  48030. export class PositionNormalVertex {
  48031. /** the position of the vertex (defaut: 0,0,0) */
  48032. position: Vector3;
  48033. /** the normal of the vertex (defaut: 0,1,0) */
  48034. normal: Vector3;
  48035. /**
  48036. * Creates a PositionNormalVertex
  48037. * @param position the position of the vertex (defaut: 0,0,0)
  48038. * @param normal the normal of the vertex (defaut: 0,1,0)
  48039. */
  48040. constructor(
  48041. /** the position of the vertex (defaut: 0,0,0) */
  48042. position?: Vector3,
  48043. /** the normal of the vertex (defaut: 0,1,0) */
  48044. normal?: Vector3);
  48045. /**
  48046. * Clones the PositionNormalVertex
  48047. * @returns the cloned PositionNormalVertex
  48048. */
  48049. clone(): PositionNormalVertex;
  48050. }
  48051. /**
  48052. * Contains position, normal and uv vectors for a vertex
  48053. */
  48054. export class PositionNormalTextureVertex {
  48055. /** the position of the vertex (defaut: 0,0,0) */
  48056. position: Vector3;
  48057. /** the normal of the vertex (defaut: 0,1,0) */
  48058. normal: Vector3;
  48059. /** the uv of the vertex (default: 0,0) */
  48060. uv: Vector2;
  48061. /**
  48062. * Creates a PositionNormalTextureVertex
  48063. * @param position the position of the vertex (defaut: 0,0,0)
  48064. * @param normal the normal of the vertex (defaut: 0,1,0)
  48065. * @param uv the uv of the vertex (default: 0,0)
  48066. */
  48067. constructor(
  48068. /** the position of the vertex (defaut: 0,0,0) */
  48069. position?: Vector3,
  48070. /** the normal of the vertex (defaut: 0,1,0) */
  48071. normal?: Vector3,
  48072. /** the uv of the vertex (default: 0,0) */
  48073. uv?: Vector2);
  48074. /**
  48075. * Clones the PositionNormalTextureVertex
  48076. * @returns the cloned PositionNormalTextureVertex
  48077. */
  48078. clone(): PositionNormalTextureVertex;
  48079. }
  48080. }
  48081. declare module BABYLON {
  48082. /** @hidden */
  48083. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48084. private _genericAttributeLocation;
  48085. private _varyingLocationCount;
  48086. private _varyingLocationMap;
  48087. private _replacements;
  48088. private _textureCount;
  48089. private _uniforms;
  48090. lineProcessor(line: string): string;
  48091. attributeProcessor(attribute: string): string;
  48092. varyingProcessor(varying: string, isFragment: boolean): string;
  48093. uniformProcessor(uniform: string): string;
  48094. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48095. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48096. }
  48097. }
  48098. declare module BABYLON {
  48099. /**
  48100. * Container for accessors for natively-stored mesh data buffers.
  48101. */
  48102. class NativeDataBuffer extends DataBuffer {
  48103. /**
  48104. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48105. */
  48106. nativeIndexBuffer?: any;
  48107. /**
  48108. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48109. */
  48110. nativeVertexBuffer?: any;
  48111. }
  48112. /** @hidden */
  48113. class NativeTexture extends InternalTexture {
  48114. getInternalTexture(): InternalTexture;
  48115. getViewCount(): number;
  48116. }
  48117. /** @hidden */
  48118. export class NativeEngine extends Engine {
  48119. private readonly _native;
  48120. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48121. private readonly INVALID_HANDLE;
  48122. getHardwareScalingLevel(): number;
  48123. constructor();
  48124. dispose(): void;
  48125. /**
  48126. * Can be used to override the current requestAnimationFrame requester.
  48127. * @hidden
  48128. */
  48129. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48130. /**
  48131. * Override default engine behavior.
  48132. * @param color
  48133. * @param backBuffer
  48134. * @param depth
  48135. * @param stencil
  48136. */
  48137. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48138. /**
  48139. * Gets host document
  48140. * @returns the host document object
  48141. */
  48142. getHostDocument(): Nullable<Document>;
  48143. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48144. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48145. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48146. recordVertexArrayObject(vertexBuffers: {
  48147. [key: string]: VertexBuffer;
  48148. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48149. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48150. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48151. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48152. /**
  48153. * Draw a list of indexed primitives
  48154. * @param fillMode defines the primitive to use
  48155. * @param indexStart defines the starting index
  48156. * @param indexCount defines the number of index to draw
  48157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48158. */
  48159. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48160. /**
  48161. * Draw a list of unindexed primitives
  48162. * @param fillMode defines the primitive to use
  48163. * @param verticesStart defines the index of first vertex to draw
  48164. * @param verticesCount defines the count of vertices to draw
  48165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48166. */
  48167. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48168. createPipelineContext(): IPipelineContext;
  48169. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48170. /** @hidden */
  48171. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48172. /** @hidden */
  48173. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48174. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48175. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48176. protected _setProgram(program: WebGLProgram): void;
  48177. _releaseEffect(effect: Effect): void;
  48178. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48179. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48180. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48181. bindSamplers(effect: Effect): void;
  48182. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48183. getRenderWidth(useScreen?: boolean): number;
  48184. getRenderHeight(useScreen?: boolean): number;
  48185. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48186. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48187. /**
  48188. * Set the z offset to apply to current rendering
  48189. * @param value defines the offset to apply
  48190. */
  48191. setZOffset(value: number): void;
  48192. /**
  48193. * Gets the current value of the zOffset
  48194. * @returns the current zOffset state
  48195. */
  48196. getZOffset(): number;
  48197. /**
  48198. * Enable or disable depth buffering
  48199. * @param enable defines the state to set
  48200. */
  48201. setDepthBuffer(enable: boolean): void;
  48202. /**
  48203. * Gets a boolean indicating if depth writing is enabled
  48204. * @returns the current depth writing state
  48205. */
  48206. getDepthWrite(): boolean;
  48207. /**
  48208. * Enable or disable depth writing
  48209. * @param enable defines the state to set
  48210. */
  48211. setDepthWrite(enable: boolean): void;
  48212. /**
  48213. * Enable or disable color writing
  48214. * @param enable defines the state to set
  48215. */
  48216. setColorWrite(enable: boolean): void;
  48217. /**
  48218. * Gets a boolean indicating if color writing is enabled
  48219. * @returns the current color writing state
  48220. */
  48221. getColorWrite(): boolean;
  48222. /**
  48223. * Sets alpha constants used by some alpha blending modes
  48224. * @param r defines the red component
  48225. * @param g defines the green component
  48226. * @param b defines the blue component
  48227. * @param a defines the alpha component
  48228. */
  48229. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48230. /**
  48231. * Sets the current alpha mode
  48232. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48233. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48234. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48235. */
  48236. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48237. /**
  48238. * Gets the current alpha mode
  48239. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48240. * @returns the current alpha mode
  48241. */
  48242. getAlphaMode(): number;
  48243. setInt(uniform: WebGLUniformLocation, int: number): void;
  48244. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48245. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48246. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48247. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48248. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48249. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48250. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48251. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48252. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48253. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48254. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48255. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48256. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48257. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48258. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48259. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48260. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48261. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48262. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48263. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48264. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48265. wipeCaches(bruteForce?: boolean): void;
  48266. _createTexture(): WebGLTexture;
  48267. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48268. /**
  48269. * Usually called from Texture.ts.
  48270. * Passed information to create a WebGLTexture
  48271. * @param url defines a value which contains one of the following:
  48272. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48273. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48274. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48275. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48276. * @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)
  48277. * @param scene needed for loading to the correct scene
  48278. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48279. * @param onLoad optional callback to be called upon successful completion
  48280. * @param onError optional callback to be called upon failure
  48281. * @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
  48282. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48283. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48284. * @param forcedExtension defines the extension to use to pick the right loader
  48285. * @param mimeType defines an optional mime type
  48286. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48287. */
  48288. 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;
  48289. /**
  48290. * Creates a cube texture
  48291. * @param rootUrl defines the url where the files to load is located
  48292. * @param scene defines the current scene
  48293. * @param files defines the list of files to load (1 per face)
  48294. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48295. * @param onLoad defines an optional callback raised when the texture is loaded
  48296. * @param onError defines an optional callback raised if there is an issue to load the texture
  48297. * @param format defines the format of the data
  48298. * @param forcedExtension defines the extension to use to pick the right loader
  48299. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48300. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48301. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48302. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48303. * @returns the cube texture as an InternalTexture
  48304. */
  48305. 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;
  48306. private _getSamplingFilter;
  48307. private static _GetNativeTextureFormat;
  48308. createRenderTargetTexture(size: number | {
  48309. width: number;
  48310. height: number;
  48311. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48312. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48313. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48314. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48315. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48316. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48317. /**
  48318. * Updates a dynamic vertex buffer.
  48319. * @param vertexBuffer the vertex buffer to update
  48320. * @param data the data used to update the vertex buffer
  48321. * @param byteOffset the byte offset of the data (optional)
  48322. * @param byteLength the byte length of the data (optional)
  48323. */
  48324. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48325. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48326. private _updateAnisotropicLevel;
  48327. private _getAddressMode;
  48328. /** @hidden */
  48329. _bindTexture(channel: number, texture: InternalTexture): void;
  48330. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48331. releaseEffects(): void;
  48332. /** @hidden */
  48333. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48334. /** @hidden */
  48335. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48336. /** @hidden */
  48337. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48338. /** @hidden */
  48339. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48340. }
  48341. }
  48342. declare module BABYLON {
  48343. /**
  48344. * Gather the list of clipboard event types as constants.
  48345. */
  48346. export class ClipboardEventTypes {
  48347. /**
  48348. * The clipboard event is fired when a copy command is active (pressed).
  48349. */
  48350. static readonly COPY: number;
  48351. /**
  48352. * The clipboard event is fired when a cut command is active (pressed).
  48353. */
  48354. static readonly CUT: number;
  48355. /**
  48356. * The clipboard event is fired when a paste command is active (pressed).
  48357. */
  48358. static readonly PASTE: number;
  48359. }
  48360. /**
  48361. * This class is used to store clipboard related info for the onClipboardObservable event.
  48362. */
  48363. export class ClipboardInfo {
  48364. /**
  48365. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48366. */
  48367. type: number;
  48368. /**
  48369. * Defines the related dom event
  48370. */
  48371. event: ClipboardEvent;
  48372. /**
  48373. *Creates an instance of ClipboardInfo.
  48374. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48375. * @param event Defines the related dom event
  48376. */
  48377. constructor(
  48378. /**
  48379. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48380. */
  48381. type: number,
  48382. /**
  48383. * Defines the related dom event
  48384. */
  48385. event: ClipboardEvent);
  48386. /**
  48387. * Get the clipboard event's type from the keycode.
  48388. * @param keyCode Defines the keyCode for the current keyboard event.
  48389. * @return {number}
  48390. */
  48391. static GetTypeFromCharacter(keyCode: number): number;
  48392. }
  48393. }
  48394. declare module BABYLON {
  48395. /**
  48396. * Google Daydream controller
  48397. */
  48398. export class DaydreamController extends WebVRController {
  48399. /**
  48400. * Base Url for the controller model.
  48401. */
  48402. static MODEL_BASE_URL: string;
  48403. /**
  48404. * File name for the controller model.
  48405. */
  48406. static MODEL_FILENAME: string;
  48407. /**
  48408. * Gamepad Id prefix used to identify Daydream Controller.
  48409. */
  48410. static readonly GAMEPAD_ID_PREFIX: string;
  48411. /**
  48412. * Creates a new DaydreamController from a gamepad
  48413. * @param vrGamepad the gamepad that the controller should be created from
  48414. */
  48415. constructor(vrGamepad: any);
  48416. /**
  48417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48418. * @param scene scene in which to add meshes
  48419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48420. */
  48421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48422. /**
  48423. * Called once for each button that changed state since the last frame
  48424. * @param buttonIdx Which button index changed
  48425. * @param state New state of the button
  48426. * @param changes Which properties on the state changed since last frame
  48427. */
  48428. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48429. }
  48430. }
  48431. declare module BABYLON {
  48432. /**
  48433. * Gear VR Controller
  48434. */
  48435. export class GearVRController extends WebVRController {
  48436. /**
  48437. * Base Url for the controller model.
  48438. */
  48439. static MODEL_BASE_URL: string;
  48440. /**
  48441. * File name for the controller model.
  48442. */
  48443. static MODEL_FILENAME: string;
  48444. /**
  48445. * Gamepad Id prefix used to identify this controller.
  48446. */
  48447. static readonly GAMEPAD_ID_PREFIX: string;
  48448. private readonly _buttonIndexToObservableNameMap;
  48449. /**
  48450. * Creates a new GearVRController from a gamepad
  48451. * @param vrGamepad the gamepad that the controller should be created from
  48452. */
  48453. constructor(vrGamepad: any);
  48454. /**
  48455. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48456. * @param scene scene in which to add meshes
  48457. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48458. */
  48459. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48460. /**
  48461. * Called once for each button that changed state since the last frame
  48462. * @param buttonIdx Which button index changed
  48463. * @param state New state of the button
  48464. * @param changes Which properties on the state changed since last frame
  48465. */
  48466. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /**
  48471. * Generic Controller
  48472. */
  48473. export class GenericController extends WebVRController {
  48474. /**
  48475. * Base Url for the controller model.
  48476. */
  48477. static readonly MODEL_BASE_URL: string;
  48478. /**
  48479. * File name for the controller model.
  48480. */
  48481. static readonly MODEL_FILENAME: string;
  48482. /**
  48483. * Creates a new GenericController from a gamepad
  48484. * @param vrGamepad the gamepad that the controller should be created from
  48485. */
  48486. constructor(vrGamepad: any);
  48487. /**
  48488. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48489. * @param scene scene in which to add meshes
  48490. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48491. */
  48492. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48493. /**
  48494. * Called once for each button that changed state since the last frame
  48495. * @param buttonIdx Which button index changed
  48496. * @param state New state of the button
  48497. * @param changes Which properties on the state changed since last frame
  48498. */
  48499. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48500. }
  48501. }
  48502. declare module BABYLON {
  48503. /**
  48504. * Oculus Touch Controller
  48505. */
  48506. export class OculusTouchController extends WebVRController {
  48507. /**
  48508. * Base Url for the controller model.
  48509. */
  48510. static MODEL_BASE_URL: string;
  48511. /**
  48512. * File name for the left controller model.
  48513. */
  48514. static MODEL_LEFT_FILENAME: string;
  48515. /**
  48516. * File name for the right controller model.
  48517. */
  48518. static MODEL_RIGHT_FILENAME: string;
  48519. /**
  48520. * Base Url for the Quest controller model.
  48521. */
  48522. static QUEST_MODEL_BASE_URL: string;
  48523. /**
  48524. * @hidden
  48525. * If the controllers are running on a device that needs the updated Quest controller models
  48526. */
  48527. static _IsQuest: boolean;
  48528. /**
  48529. * Fired when the secondary trigger on this controller is modified
  48530. */
  48531. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48532. /**
  48533. * Fired when the thumb rest on this controller is modified
  48534. */
  48535. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48536. /**
  48537. * Creates a new OculusTouchController from a gamepad
  48538. * @param vrGamepad the gamepad that the controller should be created from
  48539. */
  48540. constructor(vrGamepad: any);
  48541. /**
  48542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48543. * @param scene scene in which to add meshes
  48544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48545. */
  48546. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48547. /**
  48548. * Fired when the A button on this controller is modified
  48549. */
  48550. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48551. /**
  48552. * Fired when the B button on this controller is modified
  48553. */
  48554. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48555. /**
  48556. * Fired when the X button on this controller is modified
  48557. */
  48558. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48559. /**
  48560. * Fired when the Y button on this controller is modified
  48561. */
  48562. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48563. /**
  48564. * Called once for each button that changed state since the last frame
  48565. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48566. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48567. * 2) secondary trigger (same)
  48568. * 3) A (right) X (left), touch, pressed = value
  48569. * 4) B / Y
  48570. * 5) thumb rest
  48571. * @param buttonIdx Which button index changed
  48572. * @param state New state of the button
  48573. * @param changes Which properties on the state changed since last frame
  48574. */
  48575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48576. }
  48577. }
  48578. declare module BABYLON {
  48579. /**
  48580. * Vive Controller
  48581. */
  48582. export class ViveController extends WebVRController {
  48583. /**
  48584. * Base Url for the controller model.
  48585. */
  48586. static MODEL_BASE_URL: string;
  48587. /**
  48588. * File name for the controller model.
  48589. */
  48590. static MODEL_FILENAME: string;
  48591. /**
  48592. * Creates a new ViveController from a gamepad
  48593. * @param vrGamepad the gamepad that the controller should be created from
  48594. */
  48595. constructor(vrGamepad: any);
  48596. /**
  48597. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48598. * @param scene scene in which to add meshes
  48599. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48600. */
  48601. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48602. /**
  48603. * Fired when the left button on this controller is modified
  48604. */
  48605. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48606. /**
  48607. * Fired when the right button on this controller is modified
  48608. */
  48609. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48610. /**
  48611. * Fired when the menu button on this controller is modified
  48612. */
  48613. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48614. /**
  48615. * Called once for each button that changed state since the last frame
  48616. * Vive mapping:
  48617. * 0: touchpad
  48618. * 1: trigger
  48619. * 2: left AND right buttons
  48620. * 3: menu button
  48621. * @param buttonIdx Which button index changed
  48622. * @param state New state of the button
  48623. * @param changes Which properties on the state changed since last frame
  48624. */
  48625. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48626. }
  48627. }
  48628. declare module BABYLON {
  48629. /**
  48630. * Defines the WindowsMotionController object that the state of the windows motion controller
  48631. */
  48632. export class WindowsMotionController extends WebVRController {
  48633. /**
  48634. * The base url used to load the left and right controller models
  48635. */
  48636. static MODEL_BASE_URL: string;
  48637. /**
  48638. * The name of the left controller model file
  48639. */
  48640. static MODEL_LEFT_FILENAME: string;
  48641. /**
  48642. * The name of the right controller model file
  48643. */
  48644. static MODEL_RIGHT_FILENAME: string;
  48645. /**
  48646. * The controller name prefix for this controller type
  48647. */
  48648. static readonly GAMEPAD_ID_PREFIX: string;
  48649. /**
  48650. * The controller id pattern for this controller type
  48651. */
  48652. private static readonly GAMEPAD_ID_PATTERN;
  48653. private _loadedMeshInfo;
  48654. protected readonly _mapping: {
  48655. buttons: string[];
  48656. buttonMeshNames: {
  48657. trigger: string;
  48658. menu: string;
  48659. grip: string;
  48660. thumbstick: string;
  48661. trackpad: string;
  48662. };
  48663. buttonObservableNames: {
  48664. trigger: string;
  48665. menu: string;
  48666. grip: string;
  48667. thumbstick: string;
  48668. trackpad: string;
  48669. };
  48670. axisMeshNames: string[];
  48671. pointingPoseMeshName: string;
  48672. };
  48673. /**
  48674. * Fired when the trackpad on this controller is clicked
  48675. */
  48676. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48677. /**
  48678. * Fired when the trackpad on this controller is modified
  48679. */
  48680. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48681. /**
  48682. * The current x and y values of this controller's trackpad
  48683. */
  48684. trackpad: StickValues;
  48685. /**
  48686. * Creates a new WindowsMotionController from a gamepad
  48687. * @param vrGamepad the gamepad that the controller should be created from
  48688. */
  48689. constructor(vrGamepad: any);
  48690. /**
  48691. * Fired when the trigger on this controller is modified
  48692. */
  48693. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48694. /**
  48695. * Fired when the menu button on this controller is modified
  48696. */
  48697. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48698. /**
  48699. * Fired when the grip button on this controller is modified
  48700. */
  48701. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48702. /**
  48703. * Fired when the thumbstick button on this controller is modified
  48704. */
  48705. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48706. /**
  48707. * Fired when the touchpad button on this controller is modified
  48708. */
  48709. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48710. /**
  48711. * Fired when the touchpad values on this controller are modified
  48712. */
  48713. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48714. protected _updateTrackpad(): void;
  48715. /**
  48716. * Called once per frame by the engine.
  48717. */
  48718. update(): void;
  48719. /**
  48720. * Called once for each button that changed state since the last frame
  48721. * @param buttonIdx Which button index changed
  48722. * @param state New state of the button
  48723. * @param changes Which properties on the state changed since last frame
  48724. */
  48725. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48726. /**
  48727. * Moves the buttons on the controller mesh based on their current state
  48728. * @param buttonName the name of the button to move
  48729. * @param buttonValue the value of the button which determines the buttons new position
  48730. */
  48731. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48732. /**
  48733. * Moves the axis on the controller mesh based on its current state
  48734. * @param axis the index of the axis
  48735. * @param axisValue the value of the axis which determines the meshes new position
  48736. * @hidden
  48737. */
  48738. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48739. /**
  48740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48741. * @param scene scene in which to add meshes
  48742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48743. */
  48744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48745. /**
  48746. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48747. * can be transformed by button presses and axes values, based on this._mapping.
  48748. *
  48749. * @param scene scene in which the meshes exist
  48750. * @param meshes list of meshes that make up the controller model to process
  48751. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48752. */
  48753. private processModel;
  48754. private createMeshInfo;
  48755. /**
  48756. * Gets the ray of the controller in the direction the controller is pointing
  48757. * @param length the length the resulting ray should be
  48758. * @returns a ray in the direction the controller is pointing
  48759. */
  48760. getForwardRay(length?: number): Ray;
  48761. /**
  48762. * Disposes of the controller
  48763. */
  48764. dispose(): void;
  48765. }
  48766. /**
  48767. * This class represents a new windows motion controller in XR.
  48768. */
  48769. export class XRWindowsMotionController extends WindowsMotionController {
  48770. /**
  48771. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48772. */
  48773. protected readonly _mapping: {
  48774. buttons: string[];
  48775. buttonMeshNames: {
  48776. trigger: string;
  48777. menu: string;
  48778. grip: string;
  48779. thumbstick: string;
  48780. trackpad: string;
  48781. };
  48782. buttonObservableNames: {
  48783. trigger: string;
  48784. menu: string;
  48785. grip: string;
  48786. thumbstick: string;
  48787. trackpad: string;
  48788. };
  48789. axisMeshNames: string[];
  48790. pointingPoseMeshName: string;
  48791. };
  48792. /**
  48793. * Construct a new XR-Based windows motion controller
  48794. *
  48795. * @param gamepadInfo the gamepad object from the browser
  48796. */
  48797. constructor(gamepadInfo: any);
  48798. /**
  48799. * holds the thumbstick values (X,Y)
  48800. */
  48801. thumbstickValues: StickValues;
  48802. /**
  48803. * Fired when the thumbstick on this controller is clicked
  48804. */
  48805. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48806. /**
  48807. * Fired when the thumbstick on this controller is modified
  48808. */
  48809. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48810. /**
  48811. * Fired when the touchpad button on this controller is modified
  48812. */
  48813. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48814. /**
  48815. * Fired when the touchpad values on this controller are modified
  48816. */
  48817. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48818. /**
  48819. * Fired when the thumbstick button on this controller is modified
  48820. * here to prevent breaking changes
  48821. */
  48822. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48823. /**
  48824. * updating the thumbstick(!) and not the trackpad.
  48825. * This is named this way due to the difference between WebVR and XR and to avoid
  48826. * changing the parent class.
  48827. */
  48828. protected _updateTrackpad(): void;
  48829. /**
  48830. * Disposes the class with joy
  48831. */
  48832. dispose(): void;
  48833. }
  48834. }
  48835. declare module BABYLON {
  48836. /**
  48837. * Class containing static functions to help procedurally build meshes
  48838. */
  48839. export class PolyhedronBuilder {
  48840. /**
  48841. * Creates a polyhedron mesh
  48842. * * 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
  48843. * * The parameter `size` (positive float, default 1) sets the polygon size
  48844. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48845. * * 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`
  48846. * * 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
  48847. * * 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)`)
  48848. * * 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
  48849. * * 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
  48850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48851. * * 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
  48852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48853. * @param name defines the name of the mesh
  48854. * @param options defines the options used to create the mesh
  48855. * @param scene defines the hosting scene
  48856. * @returns the polyhedron mesh
  48857. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48858. */
  48859. static CreatePolyhedron(name: string, options: {
  48860. type?: number;
  48861. size?: number;
  48862. sizeX?: number;
  48863. sizeY?: number;
  48864. sizeZ?: number;
  48865. custom?: any;
  48866. faceUV?: Vector4[];
  48867. faceColors?: Color4[];
  48868. flat?: boolean;
  48869. updatable?: boolean;
  48870. sideOrientation?: number;
  48871. frontUVs?: Vector4;
  48872. backUVs?: Vector4;
  48873. }, scene?: Nullable<Scene>): Mesh;
  48874. }
  48875. }
  48876. declare module BABYLON {
  48877. /**
  48878. * Gizmo that enables scaling a mesh along 3 axis
  48879. */
  48880. export class ScaleGizmo extends Gizmo {
  48881. /**
  48882. * Internal gizmo used for interactions on the x axis
  48883. */
  48884. xGizmo: AxisScaleGizmo;
  48885. /**
  48886. * Internal gizmo used for interactions on the y axis
  48887. */
  48888. yGizmo: AxisScaleGizmo;
  48889. /**
  48890. * Internal gizmo used for interactions on the z axis
  48891. */
  48892. zGizmo: AxisScaleGizmo;
  48893. /**
  48894. * Internal gizmo used to scale all axis equally
  48895. */
  48896. uniformScaleGizmo: AxisScaleGizmo;
  48897. private _meshAttached;
  48898. private _updateGizmoRotationToMatchAttachedMesh;
  48899. private _snapDistance;
  48900. private _scaleRatio;
  48901. private _uniformScalingMesh;
  48902. private _octahedron;
  48903. private _sensitivity;
  48904. /** Fires an event when any of it's sub gizmos are dragged */
  48905. onDragStartObservable: Observable<unknown>;
  48906. /** Fires an event when any of it's sub gizmos are released from dragging */
  48907. onDragEndObservable: Observable<unknown>;
  48908. get attachedMesh(): Nullable<AbstractMesh>;
  48909. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48910. /**
  48911. * Creates a ScaleGizmo
  48912. * @param gizmoLayer The utility layer the gizmo will be added to
  48913. */
  48914. constructor(gizmoLayer?: UtilityLayerRenderer);
  48915. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48916. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48917. /**
  48918. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48919. */
  48920. set snapDistance(value: number);
  48921. get snapDistance(): number;
  48922. /**
  48923. * Ratio for the scale of the gizmo (Default: 1)
  48924. */
  48925. set scaleRatio(value: number);
  48926. get scaleRatio(): number;
  48927. /**
  48928. * Sensitivity factor for dragging (Default: 1)
  48929. */
  48930. set sensitivity(value: number);
  48931. get sensitivity(): number;
  48932. /**
  48933. * Disposes of the gizmo
  48934. */
  48935. dispose(): void;
  48936. }
  48937. }
  48938. declare module BABYLON {
  48939. /**
  48940. * Single axis scale gizmo
  48941. */
  48942. export class AxisScaleGizmo extends Gizmo {
  48943. /**
  48944. * Drag behavior responsible for the gizmos dragging interactions
  48945. */
  48946. dragBehavior: PointerDragBehavior;
  48947. private _pointerObserver;
  48948. /**
  48949. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48950. */
  48951. snapDistance: number;
  48952. /**
  48953. * Event that fires each time the gizmo snaps to a new location.
  48954. * * snapDistance is the the change in distance
  48955. */
  48956. onSnapObservable: Observable<{
  48957. snapDistance: number;
  48958. }>;
  48959. /**
  48960. * If the scaling operation should be done on all axis (default: false)
  48961. */
  48962. uniformScaling: boolean;
  48963. /**
  48964. * Custom sensitivity value for the drag strength
  48965. */
  48966. sensitivity: number;
  48967. private _isEnabled;
  48968. private _parent;
  48969. private _arrow;
  48970. private _coloredMaterial;
  48971. private _hoverMaterial;
  48972. /**
  48973. * Creates an AxisScaleGizmo
  48974. * @param gizmoLayer The utility layer the gizmo will be added to
  48975. * @param dragAxis The axis which the gizmo will be able to scale on
  48976. * @param color The color of the gizmo
  48977. */
  48978. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48979. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48980. /**
  48981. * If the gizmo is enabled
  48982. */
  48983. set isEnabled(value: boolean);
  48984. get isEnabled(): boolean;
  48985. /**
  48986. * Disposes of the gizmo
  48987. */
  48988. dispose(): void;
  48989. /**
  48990. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48991. * @param mesh The mesh to replace the default mesh of the gizmo
  48992. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48993. */
  48994. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48995. }
  48996. }
  48997. declare module BABYLON {
  48998. /**
  48999. * Bounding box gizmo
  49000. */
  49001. export class BoundingBoxGizmo extends Gizmo {
  49002. private _lineBoundingBox;
  49003. private _rotateSpheresParent;
  49004. private _scaleBoxesParent;
  49005. private _boundingDimensions;
  49006. private _renderObserver;
  49007. private _pointerObserver;
  49008. private _scaleDragSpeed;
  49009. private _tmpQuaternion;
  49010. private _tmpVector;
  49011. private _tmpRotationMatrix;
  49012. /**
  49013. * 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)
  49014. */
  49015. ignoreChildren: boolean;
  49016. /**
  49017. * 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)
  49018. */
  49019. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49020. /**
  49021. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49022. */
  49023. rotationSphereSize: number;
  49024. /**
  49025. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49026. */
  49027. scaleBoxSize: number;
  49028. /**
  49029. * 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)
  49030. */
  49031. fixedDragMeshScreenSize: boolean;
  49032. /**
  49033. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49034. */
  49035. fixedDragMeshScreenSizeDistanceFactor: number;
  49036. /**
  49037. * Fired when a rotation sphere or scale box is dragged
  49038. */
  49039. onDragStartObservable: Observable<{}>;
  49040. /**
  49041. * Fired when a scale box is dragged
  49042. */
  49043. onScaleBoxDragObservable: Observable<{}>;
  49044. /**
  49045. * Fired when a scale box drag is ended
  49046. */
  49047. onScaleBoxDragEndObservable: Observable<{}>;
  49048. /**
  49049. * Fired when a rotation sphere is dragged
  49050. */
  49051. onRotationSphereDragObservable: Observable<{}>;
  49052. /**
  49053. * Fired when a rotation sphere drag is ended
  49054. */
  49055. onRotationSphereDragEndObservable: Observable<{}>;
  49056. /**
  49057. * 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)
  49058. */
  49059. scalePivot: Nullable<Vector3>;
  49060. /**
  49061. * Mesh used as a pivot to rotate the attached mesh
  49062. */
  49063. private _anchorMesh;
  49064. private _existingMeshScale;
  49065. private _dragMesh;
  49066. private pointerDragBehavior;
  49067. private coloredMaterial;
  49068. private hoverColoredMaterial;
  49069. /**
  49070. * Sets the color of the bounding box gizmo
  49071. * @param color the color to set
  49072. */
  49073. setColor(color: Color3): void;
  49074. /**
  49075. * Creates an BoundingBoxGizmo
  49076. * @param gizmoLayer The utility layer the gizmo will be added to
  49077. * @param color The color of the gizmo
  49078. */
  49079. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49080. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49081. private _selectNode;
  49082. /**
  49083. * Updates the bounding box information for the Gizmo
  49084. */
  49085. updateBoundingBox(): void;
  49086. private _updateRotationSpheres;
  49087. private _updateScaleBoxes;
  49088. /**
  49089. * Enables rotation on the specified axis and disables rotation on the others
  49090. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49091. */
  49092. setEnabledRotationAxis(axis: string): void;
  49093. /**
  49094. * Enables/disables scaling
  49095. * @param enable if scaling should be enabled
  49096. * @param homogeneousScaling defines if scaling should only be homogeneous
  49097. */
  49098. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49099. private _updateDummy;
  49100. /**
  49101. * Enables a pointer drag behavior on the bounding box of the gizmo
  49102. */
  49103. enableDragBehavior(): void;
  49104. /**
  49105. * Disposes of the gizmo
  49106. */
  49107. dispose(): void;
  49108. /**
  49109. * 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)
  49110. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49111. * @returns the bounding box mesh with the passed in mesh as a child
  49112. */
  49113. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49114. /**
  49115. * CustomMeshes are not supported by this gizmo
  49116. * @param mesh The mesh to replace the default mesh of the gizmo
  49117. */
  49118. setCustomMesh(mesh: Mesh): void;
  49119. }
  49120. }
  49121. declare module BABYLON {
  49122. /**
  49123. * Single plane rotation gizmo
  49124. */
  49125. export class PlaneRotationGizmo extends Gizmo {
  49126. /**
  49127. * Drag behavior responsible for the gizmos dragging interactions
  49128. */
  49129. dragBehavior: PointerDragBehavior;
  49130. private _pointerObserver;
  49131. /**
  49132. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49133. */
  49134. snapDistance: number;
  49135. /**
  49136. * Event that fires each time the gizmo snaps to a new location.
  49137. * * snapDistance is the the change in distance
  49138. */
  49139. onSnapObservable: Observable<{
  49140. snapDistance: number;
  49141. }>;
  49142. private _isEnabled;
  49143. private _parent;
  49144. /**
  49145. * Creates a PlaneRotationGizmo
  49146. * @param gizmoLayer The utility layer the gizmo will be added to
  49147. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49148. * @param color The color of the gizmo
  49149. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49150. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49151. */
  49152. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49153. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49154. /**
  49155. * If the gizmo is enabled
  49156. */
  49157. set isEnabled(value: boolean);
  49158. get isEnabled(): boolean;
  49159. /**
  49160. * Disposes of the gizmo
  49161. */
  49162. dispose(): void;
  49163. }
  49164. }
  49165. declare module BABYLON {
  49166. /**
  49167. * Gizmo that enables rotating a mesh along 3 axis
  49168. */
  49169. export class RotationGizmo extends Gizmo {
  49170. /**
  49171. * Internal gizmo used for interactions on the x axis
  49172. */
  49173. xGizmo: PlaneRotationGizmo;
  49174. /**
  49175. * Internal gizmo used for interactions on the y axis
  49176. */
  49177. yGizmo: PlaneRotationGizmo;
  49178. /**
  49179. * Internal gizmo used for interactions on the z axis
  49180. */
  49181. zGizmo: PlaneRotationGizmo;
  49182. /** Fires an event when any of it's sub gizmos are dragged */
  49183. onDragStartObservable: Observable<unknown>;
  49184. /** Fires an event when any of it's sub gizmos are released from dragging */
  49185. onDragEndObservable: Observable<unknown>;
  49186. private _meshAttached;
  49187. get attachedMesh(): Nullable<AbstractMesh>;
  49188. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49189. /**
  49190. * Creates a RotationGizmo
  49191. * @param gizmoLayer The utility layer the gizmo will be added to
  49192. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49193. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49194. */
  49195. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49196. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49197. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49198. /**
  49199. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49200. */
  49201. set snapDistance(value: number);
  49202. get snapDistance(): number;
  49203. /**
  49204. * Ratio for the scale of the gizmo (Default: 1)
  49205. */
  49206. set scaleRatio(value: number);
  49207. get scaleRatio(): number;
  49208. /**
  49209. * Disposes of the gizmo
  49210. */
  49211. dispose(): void;
  49212. /**
  49213. * CustomMeshes are not supported by this gizmo
  49214. * @param mesh The mesh to replace the default mesh of the gizmo
  49215. */
  49216. setCustomMesh(mesh: Mesh): void;
  49217. }
  49218. }
  49219. declare module BABYLON {
  49220. /**
  49221. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49222. */
  49223. export class GizmoManager implements IDisposable {
  49224. private scene;
  49225. /**
  49226. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49227. */
  49228. gizmos: {
  49229. positionGizmo: Nullable<PositionGizmo>;
  49230. rotationGizmo: Nullable<RotationGizmo>;
  49231. scaleGizmo: Nullable<ScaleGizmo>;
  49232. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49233. };
  49234. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49235. clearGizmoOnEmptyPointerEvent: boolean;
  49236. /** Fires an event when the manager is attached to a mesh */
  49237. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49238. private _gizmosEnabled;
  49239. private _pointerObserver;
  49240. private _attachedMesh;
  49241. private _boundingBoxColor;
  49242. private _defaultUtilityLayer;
  49243. private _defaultKeepDepthUtilityLayer;
  49244. /**
  49245. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49246. */
  49247. boundingBoxDragBehavior: SixDofDragBehavior;
  49248. /**
  49249. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49250. */
  49251. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49252. /**
  49253. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49254. */
  49255. usePointerToAttachGizmos: boolean;
  49256. /**
  49257. * Utility layer that the bounding box gizmo belongs to
  49258. */
  49259. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49260. /**
  49261. * Utility layer that all gizmos besides bounding box belong to
  49262. */
  49263. get utilityLayer(): UtilityLayerRenderer;
  49264. /**
  49265. * Instatiates a gizmo manager
  49266. * @param scene the scene to overlay the gizmos on top of
  49267. */
  49268. constructor(scene: Scene);
  49269. /**
  49270. * Attaches a set of gizmos to the specified mesh
  49271. * @param mesh The mesh the gizmo's should be attached to
  49272. */
  49273. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49274. /**
  49275. * If the position gizmo is enabled
  49276. */
  49277. set positionGizmoEnabled(value: boolean);
  49278. get positionGizmoEnabled(): boolean;
  49279. /**
  49280. * If the rotation gizmo is enabled
  49281. */
  49282. set rotationGizmoEnabled(value: boolean);
  49283. get rotationGizmoEnabled(): boolean;
  49284. /**
  49285. * If the scale gizmo is enabled
  49286. */
  49287. set scaleGizmoEnabled(value: boolean);
  49288. get scaleGizmoEnabled(): boolean;
  49289. /**
  49290. * If the boundingBox gizmo is enabled
  49291. */
  49292. set boundingBoxGizmoEnabled(value: boolean);
  49293. get boundingBoxGizmoEnabled(): boolean;
  49294. /**
  49295. * Disposes of the gizmo manager
  49296. */
  49297. dispose(): void;
  49298. }
  49299. }
  49300. declare module BABYLON {
  49301. /**
  49302. * A directional light is defined by a direction (what a surprise!).
  49303. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49304. * 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.
  49305. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49306. */
  49307. export class DirectionalLight extends ShadowLight {
  49308. private _shadowFrustumSize;
  49309. /**
  49310. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49311. */
  49312. get shadowFrustumSize(): number;
  49313. /**
  49314. * Specifies a fix frustum size for the shadow generation.
  49315. */
  49316. set shadowFrustumSize(value: number);
  49317. private _shadowOrthoScale;
  49318. /**
  49319. * Gets the shadow projection scale against the optimal computed one.
  49320. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49321. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49322. */
  49323. get shadowOrthoScale(): number;
  49324. /**
  49325. * Sets the shadow projection scale against the optimal computed one.
  49326. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49327. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49328. */
  49329. set shadowOrthoScale(value: number);
  49330. /**
  49331. * Automatically compute the projection matrix to best fit (including all the casters)
  49332. * on each frame.
  49333. */
  49334. autoUpdateExtends: boolean;
  49335. /**
  49336. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49337. * on each frame. autoUpdateExtends must be set to true for this to work
  49338. */
  49339. autoCalcShadowZBounds: boolean;
  49340. private _orthoLeft;
  49341. private _orthoRight;
  49342. private _orthoTop;
  49343. private _orthoBottom;
  49344. /**
  49345. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49346. * The directional light is emitted from everywhere in the given direction.
  49347. * It can cast shadows.
  49348. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49349. * @param name The friendly name of the light
  49350. * @param direction The direction of the light
  49351. * @param scene The scene the light belongs to
  49352. */
  49353. constructor(name: string, direction: Vector3, scene: Scene);
  49354. /**
  49355. * Returns the string "DirectionalLight".
  49356. * @return The class name
  49357. */
  49358. getClassName(): string;
  49359. /**
  49360. * Returns the integer 1.
  49361. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49362. */
  49363. getTypeID(): number;
  49364. /**
  49365. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49366. * Returns the DirectionalLight Shadow projection matrix.
  49367. */
  49368. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49369. /**
  49370. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49371. * Returns the DirectionalLight Shadow projection matrix.
  49372. */
  49373. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49374. /**
  49375. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49376. * Returns the DirectionalLight Shadow projection matrix.
  49377. */
  49378. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49379. protected _buildUniformLayout(): void;
  49380. /**
  49381. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49382. * @param effect The effect to update
  49383. * @param lightIndex The index of the light in the effect to update
  49384. * @returns The directional light
  49385. */
  49386. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49387. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49388. /**
  49389. * Gets the minZ used for shadow according to both the scene and the light.
  49390. *
  49391. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49392. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49393. * @param activeCamera The camera we are returning the min for
  49394. * @returns the depth min z
  49395. */
  49396. getDepthMinZ(activeCamera: Camera): number;
  49397. /**
  49398. * Gets the maxZ used for shadow according to both the scene and the light.
  49399. *
  49400. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49401. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49402. * @param activeCamera The camera we are returning the max for
  49403. * @returns the depth max z
  49404. */
  49405. getDepthMaxZ(activeCamera: Camera): number;
  49406. /**
  49407. * Prepares the list of defines specific to the light type.
  49408. * @param defines the list of defines
  49409. * @param lightIndex defines the index of the light for the effect
  49410. */
  49411. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49412. }
  49413. }
  49414. declare module BABYLON {
  49415. /**
  49416. * Class containing static functions to help procedurally build meshes
  49417. */
  49418. export class HemisphereBuilder {
  49419. /**
  49420. * Creates a hemisphere mesh
  49421. * @param name defines the name of the mesh
  49422. * @param options defines the options used to create the mesh
  49423. * @param scene defines the hosting scene
  49424. * @returns the hemisphere mesh
  49425. */
  49426. static CreateHemisphere(name: string, options: {
  49427. segments?: number;
  49428. diameter?: number;
  49429. sideOrientation?: number;
  49430. }, scene: any): Mesh;
  49431. }
  49432. }
  49433. declare module BABYLON {
  49434. /**
  49435. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49436. * These values define a cone of light starting from the position, emitting toward the direction.
  49437. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49438. * and the exponent defines the speed of the decay of the light with distance (reach).
  49439. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49440. */
  49441. export class SpotLight extends ShadowLight {
  49442. private _angle;
  49443. private _innerAngle;
  49444. private _cosHalfAngle;
  49445. private _lightAngleScale;
  49446. private _lightAngleOffset;
  49447. /**
  49448. * Gets the cone angle of the spot light in Radians.
  49449. */
  49450. get angle(): number;
  49451. /**
  49452. * Sets the cone angle of the spot light in Radians.
  49453. */
  49454. set angle(value: number);
  49455. /**
  49456. * Only used in gltf falloff mode, this defines the angle where
  49457. * the directional falloff will start before cutting at angle which could be seen
  49458. * as outer angle.
  49459. */
  49460. get innerAngle(): number;
  49461. /**
  49462. * Only used in gltf falloff mode, this defines the angle where
  49463. * the directional falloff will start before cutting at angle which could be seen
  49464. * as outer angle.
  49465. */
  49466. set innerAngle(value: number);
  49467. private _shadowAngleScale;
  49468. /**
  49469. * Allows scaling the angle of the light for shadow generation only.
  49470. */
  49471. get shadowAngleScale(): number;
  49472. /**
  49473. * Allows scaling the angle of the light for shadow generation only.
  49474. */
  49475. set shadowAngleScale(value: number);
  49476. /**
  49477. * The light decay speed with the distance from the emission spot.
  49478. */
  49479. exponent: number;
  49480. private _projectionTextureMatrix;
  49481. /**
  49482. * Allows reading the projecton texture
  49483. */
  49484. get projectionTextureMatrix(): Matrix;
  49485. protected _projectionTextureLightNear: number;
  49486. /**
  49487. * Gets the near clip of the Spotlight for texture projection.
  49488. */
  49489. get projectionTextureLightNear(): number;
  49490. /**
  49491. * Sets the near clip of the Spotlight for texture projection.
  49492. */
  49493. set projectionTextureLightNear(value: number);
  49494. protected _projectionTextureLightFar: number;
  49495. /**
  49496. * Gets the far clip of the Spotlight for texture projection.
  49497. */
  49498. get projectionTextureLightFar(): number;
  49499. /**
  49500. * Sets the far clip of the Spotlight for texture projection.
  49501. */
  49502. set projectionTextureLightFar(value: number);
  49503. protected _projectionTextureUpDirection: Vector3;
  49504. /**
  49505. * Gets the Up vector of the Spotlight for texture projection.
  49506. */
  49507. get projectionTextureUpDirection(): Vector3;
  49508. /**
  49509. * Sets the Up vector of the Spotlight for texture projection.
  49510. */
  49511. set projectionTextureUpDirection(value: Vector3);
  49512. private _projectionTexture;
  49513. /**
  49514. * Gets the projection texture of the light.
  49515. */
  49516. get projectionTexture(): Nullable<BaseTexture>;
  49517. /**
  49518. * Sets the projection texture of the light.
  49519. */
  49520. set projectionTexture(value: Nullable<BaseTexture>);
  49521. private _projectionTextureViewLightDirty;
  49522. private _projectionTextureProjectionLightDirty;
  49523. private _projectionTextureDirty;
  49524. private _projectionTextureViewTargetVector;
  49525. private _projectionTextureViewLightMatrix;
  49526. private _projectionTextureProjectionLightMatrix;
  49527. private _projectionTextureScalingMatrix;
  49528. /**
  49529. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49530. * It can cast shadows.
  49531. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49532. * @param name The light friendly name
  49533. * @param position The position of the spot light in the scene
  49534. * @param direction The direction of the light in the scene
  49535. * @param angle The cone angle of the light in Radians
  49536. * @param exponent The light decay speed with the distance from the emission spot
  49537. * @param scene The scene the lights belongs to
  49538. */
  49539. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49540. /**
  49541. * Returns the string "SpotLight".
  49542. * @returns the class name
  49543. */
  49544. getClassName(): string;
  49545. /**
  49546. * Returns the integer 2.
  49547. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49548. */
  49549. getTypeID(): number;
  49550. /**
  49551. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49552. */
  49553. protected _setDirection(value: Vector3): void;
  49554. /**
  49555. * Overrides the position setter to recompute the projection texture view light Matrix.
  49556. */
  49557. protected _setPosition(value: Vector3): void;
  49558. /**
  49559. * 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.
  49560. * Returns the SpotLight.
  49561. */
  49562. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49563. protected _computeProjectionTextureViewLightMatrix(): void;
  49564. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49565. /**
  49566. * Main function for light texture projection matrix computing.
  49567. */
  49568. protected _computeProjectionTextureMatrix(): void;
  49569. protected _buildUniformLayout(): void;
  49570. private _computeAngleValues;
  49571. /**
  49572. * Sets the passed Effect "effect" with the Light textures.
  49573. * @param effect The effect to update
  49574. * @param lightIndex The index of the light in the effect to update
  49575. * @returns The light
  49576. */
  49577. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49578. /**
  49579. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49580. * @param effect The effect to update
  49581. * @param lightIndex The index of the light in the effect to update
  49582. * @returns The spot light
  49583. */
  49584. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49585. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49586. /**
  49587. * Disposes the light and the associated resources.
  49588. */
  49589. dispose(): void;
  49590. /**
  49591. * Prepares the list of defines specific to the light type.
  49592. * @param defines the list of defines
  49593. * @param lightIndex defines the index of the light for the effect
  49594. */
  49595. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49596. }
  49597. }
  49598. declare module BABYLON {
  49599. /**
  49600. * Gizmo that enables viewing a light
  49601. */
  49602. export class LightGizmo extends Gizmo {
  49603. private _lightMesh;
  49604. private _material;
  49605. private _cachedPosition;
  49606. private _cachedForward;
  49607. private _attachedMeshParent;
  49608. /**
  49609. * Creates a LightGizmo
  49610. * @param gizmoLayer The utility layer the gizmo will be added to
  49611. */
  49612. constructor(gizmoLayer?: UtilityLayerRenderer);
  49613. private _light;
  49614. /**
  49615. * The light that the gizmo is attached to
  49616. */
  49617. set light(light: Nullable<Light>);
  49618. get light(): Nullable<Light>;
  49619. /**
  49620. * Gets the material used to render the light gizmo
  49621. */
  49622. get material(): StandardMaterial;
  49623. /**
  49624. * @hidden
  49625. * Updates the gizmo to match the attached mesh's position/rotation
  49626. */
  49627. protected _update(): void;
  49628. private static _Scale;
  49629. /**
  49630. * Creates the lines for a light mesh
  49631. */
  49632. private static _CreateLightLines;
  49633. /**
  49634. * Disposes of the light gizmo
  49635. */
  49636. dispose(): void;
  49637. private static _CreateHemisphericLightMesh;
  49638. private static _CreatePointLightMesh;
  49639. private static _CreateSpotLightMesh;
  49640. private static _CreateDirectionalLightMesh;
  49641. }
  49642. }
  49643. declare module BABYLON {
  49644. /** @hidden */
  49645. export var backgroundFragmentDeclaration: {
  49646. name: string;
  49647. shader: string;
  49648. };
  49649. }
  49650. declare module BABYLON {
  49651. /** @hidden */
  49652. export var backgroundUboDeclaration: {
  49653. name: string;
  49654. shader: string;
  49655. };
  49656. }
  49657. declare module BABYLON {
  49658. /** @hidden */
  49659. export var backgroundPixelShader: {
  49660. name: string;
  49661. shader: string;
  49662. };
  49663. }
  49664. declare module BABYLON {
  49665. /** @hidden */
  49666. export var backgroundVertexDeclaration: {
  49667. name: string;
  49668. shader: string;
  49669. };
  49670. }
  49671. declare module BABYLON {
  49672. /** @hidden */
  49673. export var backgroundVertexShader: {
  49674. name: string;
  49675. shader: string;
  49676. };
  49677. }
  49678. declare module BABYLON {
  49679. /**
  49680. * Background material used to create an efficient environement around your scene.
  49681. */
  49682. export class BackgroundMaterial extends PushMaterial {
  49683. /**
  49684. * Standard reflectance value at parallel view angle.
  49685. */
  49686. static StandardReflectance0: number;
  49687. /**
  49688. * Standard reflectance value at grazing angle.
  49689. */
  49690. static StandardReflectance90: number;
  49691. protected _primaryColor: Color3;
  49692. /**
  49693. * Key light Color (multiply against the environement texture)
  49694. */
  49695. primaryColor: Color3;
  49696. protected __perceptualColor: Nullable<Color3>;
  49697. /**
  49698. * Experimental Internal Use Only.
  49699. *
  49700. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49701. * This acts as a helper to set the primary color to a more "human friendly" value.
  49702. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49703. * output color as close as possible from the chosen value.
  49704. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49705. * part of lighting setup.)
  49706. */
  49707. get _perceptualColor(): Nullable<Color3>;
  49708. set _perceptualColor(value: Nullable<Color3>);
  49709. protected _primaryColorShadowLevel: float;
  49710. /**
  49711. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49712. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49713. */
  49714. get primaryColorShadowLevel(): float;
  49715. set primaryColorShadowLevel(value: float);
  49716. protected _primaryColorHighlightLevel: float;
  49717. /**
  49718. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49719. * The primary color is used at the level chosen to define what the white area would look.
  49720. */
  49721. get primaryColorHighlightLevel(): float;
  49722. set primaryColorHighlightLevel(value: float);
  49723. protected _reflectionTexture: Nullable<BaseTexture>;
  49724. /**
  49725. * Reflection Texture used in the material.
  49726. * Should be author in a specific way for the best result (refer to the documentation).
  49727. */
  49728. reflectionTexture: Nullable<BaseTexture>;
  49729. protected _reflectionBlur: float;
  49730. /**
  49731. * Reflection Texture level of blur.
  49732. *
  49733. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49734. * texture twice.
  49735. */
  49736. reflectionBlur: float;
  49737. protected _diffuseTexture: Nullable<BaseTexture>;
  49738. /**
  49739. * Diffuse Texture used in the material.
  49740. * Should be author in a specific way for the best result (refer to the documentation).
  49741. */
  49742. diffuseTexture: Nullable<BaseTexture>;
  49743. protected _shadowLights: Nullable<IShadowLight[]>;
  49744. /**
  49745. * Specify the list of lights casting shadow on the material.
  49746. * All scene shadow lights will be included if null.
  49747. */
  49748. shadowLights: Nullable<IShadowLight[]>;
  49749. protected _shadowLevel: float;
  49750. /**
  49751. * Helps adjusting the shadow to a softer level if required.
  49752. * 0 means black shadows and 1 means no shadows.
  49753. */
  49754. shadowLevel: float;
  49755. protected _sceneCenter: Vector3;
  49756. /**
  49757. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49758. * It is usually zero but might be interesting to modify according to your setup.
  49759. */
  49760. sceneCenter: Vector3;
  49761. protected _opacityFresnel: boolean;
  49762. /**
  49763. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49764. * This helps ensuring a nice transition when the camera goes under the ground.
  49765. */
  49766. opacityFresnel: boolean;
  49767. protected _reflectionFresnel: boolean;
  49768. /**
  49769. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49770. * This helps adding a mirror texture on the ground.
  49771. */
  49772. reflectionFresnel: boolean;
  49773. protected _reflectionFalloffDistance: number;
  49774. /**
  49775. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49776. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49777. */
  49778. reflectionFalloffDistance: number;
  49779. protected _reflectionAmount: number;
  49780. /**
  49781. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49782. */
  49783. reflectionAmount: number;
  49784. protected _reflectionReflectance0: number;
  49785. /**
  49786. * This specifies the weight of the reflection at grazing angle.
  49787. */
  49788. reflectionReflectance0: number;
  49789. protected _reflectionReflectance90: number;
  49790. /**
  49791. * This specifies the weight of the reflection at a perpendicular point of view.
  49792. */
  49793. reflectionReflectance90: number;
  49794. /**
  49795. * Sets the reflection reflectance fresnel values according to the default standard
  49796. * empirically know to work well :-)
  49797. */
  49798. set reflectionStandardFresnelWeight(value: number);
  49799. protected _useRGBColor: boolean;
  49800. /**
  49801. * Helps to directly use the maps channels instead of their level.
  49802. */
  49803. useRGBColor: boolean;
  49804. protected _enableNoise: boolean;
  49805. /**
  49806. * This helps reducing the banding effect that could occur on the background.
  49807. */
  49808. enableNoise: boolean;
  49809. /**
  49810. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49811. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49812. * Recommended to be keep at 1.0 except for special cases.
  49813. */
  49814. get fovMultiplier(): number;
  49815. set fovMultiplier(value: number);
  49816. private _fovMultiplier;
  49817. /**
  49818. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49819. */
  49820. useEquirectangularFOV: boolean;
  49821. private _maxSimultaneousLights;
  49822. /**
  49823. * Number of Simultaneous lights allowed on the material.
  49824. */
  49825. maxSimultaneousLights: int;
  49826. /**
  49827. * Default configuration related to image processing available in the Background Material.
  49828. */
  49829. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49830. /**
  49831. * Keep track of the image processing observer to allow dispose and replace.
  49832. */
  49833. private _imageProcessingObserver;
  49834. /**
  49835. * Attaches a new image processing configuration to the PBR Material.
  49836. * @param configuration (if null the scene configuration will be use)
  49837. */
  49838. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49839. /**
  49840. * Gets the image processing configuration used either in this material.
  49841. */
  49842. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49843. /**
  49844. * Sets the Default image processing configuration used either in the this material.
  49845. *
  49846. * If sets to null, the scene one is in use.
  49847. */
  49848. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49849. /**
  49850. * Gets wether the color curves effect is enabled.
  49851. */
  49852. get cameraColorCurvesEnabled(): boolean;
  49853. /**
  49854. * Sets wether the color curves effect is enabled.
  49855. */
  49856. set cameraColorCurvesEnabled(value: boolean);
  49857. /**
  49858. * Gets wether the color grading effect is enabled.
  49859. */
  49860. get cameraColorGradingEnabled(): boolean;
  49861. /**
  49862. * Gets wether the color grading effect is enabled.
  49863. */
  49864. set cameraColorGradingEnabled(value: boolean);
  49865. /**
  49866. * Gets wether tonemapping is enabled or not.
  49867. */
  49868. get cameraToneMappingEnabled(): boolean;
  49869. /**
  49870. * Sets wether tonemapping is enabled or not
  49871. */
  49872. set cameraToneMappingEnabled(value: boolean);
  49873. /**
  49874. * The camera exposure used on this material.
  49875. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49876. * This corresponds to a photographic exposure.
  49877. */
  49878. get cameraExposure(): float;
  49879. /**
  49880. * The camera exposure used on this material.
  49881. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49882. * This corresponds to a photographic exposure.
  49883. */
  49884. set cameraExposure(value: float);
  49885. /**
  49886. * Gets The camera contrast used on this material.
  49887. */
  49888. get cameraContrast(): float;
  49889. /**
  49890. * Sets The camera contrast used on this material.
  49891. */
  49892. set cameraContrast(value: float);
  49893. /**
  49894. * Gets the Color Grading 2D Lookup Texture.
  49895. */
  49896. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49897. /**
  49898. * Sets the Color Grading 2D Lookup Texture.
  49899. */
  49900. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49901. /**
  49902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49904. * 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;
  49905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49906. */
  49907. get cameraColorCurves(): Nullable<ColorCurves>;
  49908. /**
  49909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49911. * 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;
  49912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49913. */
  49914. set cameraColorCurves(value: Nullable<ColorCurves>);
  49915. /**
  49916. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49917. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49918. */
  49919. switchToBGR: boolean;
  49920. private _renderTargets;
  49921. private _reflectionControls;
  49922. private _white;
  49923. private _primaryShadowColor;
  49924. private _primaryHighlightColor;
  49925. /**
  49926. * Instantiates a Background Material in the given scene
  49927. * @param name The friendly name of the material
  49928. * @param scene The scene to add the material to
  49929. */
  49930. constructor(name: string, scene: Scene);
  49931. /**
  49932. * Gets a boolean indicating that current material needs to register RTT
  49933. */
  49934. get hasRenderTargetTextures(): boolean;
  49935. /**
  49936. * The entire material has been created in order to prevent overdraw.
  49937. * @returns false
  49938. */
  49939. needAlphaTesting(): boolean;
  49940. /**
  49941. * The entire material has been created in order to prevent overdraw.
  49942. * @returns true if blending is enable
  49943. */
  49944. needAlphaBlending(): boolean;
  49945. /**
  49946. * Checks wether the material is ready to be rendered for a given mesh.
  49947. * @param mesh The mesh to render
  49948. * @param subMesh The submesh to check against
  49949. * @param useInstances Specify wether or not the material is used with instances
  49950. * @returns true if all the dependencies are ready (Textures, Effects...)
  49951. */
  49952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49953. /**
  49954. * Compute the primary color according to the chosen perceptual color.
  49955. */
  49956. private _computePrimaryColorFromPerceptualColor;
  49957. /**
  49958. * Compute the highlights and shadow colors according to their chosen levels.
  49959. */
  49960. private _computePrimaryColors;
  49961. /**
  49962. * Build the uniform buffer used in the material.
  49963. */
  49964. buildUniformLayout(): void;
  49965. /**
  49966. * Unbind the material.
  49967. */
  49968. unbind(): void;
  49969. /**
  49970. * Bind only the world matrix to the material.
  49971. * @param world The world matrix to bind.
  49972. */
  49973. bindOnlyWorldMatrix(world: Matrix): void;
  49974. /**
  49975. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49976. * @param world The world matrix to bind.
  49977. * @param subMesh The submesh to bind for.
  49978. */
  49979. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49980. /**
  49981. * Checks to see if a texture is used in the material.
  49982. * @param texture - Base texture to use.
  49983. * @returns - Boolean specifying if a texture is used in the material.
  49984. */
  49985. hasTexture(texture: BaseTexture): boolean;
  49986. /**
  49987. * Dispose the material.
  49988. * @param forceDisposeEffect Force disposal of the associated effect.
  49989. * @param forceDisposeTextures Force disposal of the associated textures.
  49990. */
  49991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49992. /**
  49993. * Clones the material.
  49994. * @param name The cloned name.
  49995. * @returns The cloned material.
  49996. */
  49997. clone(name: string): BackgroundMaterial;
  49998. /**
  49999. * Serializes the current material to its JSON representation.
  50000. * @returns The JSON representation.
  50001. */
  50002. serialize(): any;
  50003. /**
  50004. * Gets the class name of the material
  50005. * @returns "BackgroundMaterial"
  50006. */
  50007. getClassName(): string;
  50008. /**
  50009. * Parse a JSON input to create back a background material.
  50010. * @param source The JSON data to parse
  50011. * @param scene The scene to create the parsed material in
  50012. * @param rootUrl The root url of the assets the material depends upon
  50013. * @returns the instantiated BackgroundMaterial.
  50014. */
  50015. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50016. }
  50017. }
  50018. declare module BABYLON {
  50019. /**
  50020. * Represents the different options available during the creation of
  50021. * a Environment helper.
  50022. *
  50023. * This can control the default ground, skybox and image processing setup of your scene.
  50024. */
  50025. export interface IEnvironmentHelperOptions {
  50026. /**
  50027. * Specifies whether or not to create a ground.
  50028. * True by default.
  50029. */
  50030. createGround: boolean;
  50031. /**
  50032. * Specifies the ground size.
  50033. * 15 by default.
  50034. */
  50035. groundSize: number;
  50036. /**
  50037. * The texture used on the ground for the main color.
  50038. * Comes from the BabylonJS CDN by default.
  50039. *
  50040. * Remarks: Can be either a texture or a url.
  50041. */
  50042. groundTexture: string | BaseTexture;
  50043. /**
  50044. * The color mixed in the ground texture by default.
  50045. * BabylonJS clearColor by default.
  50046. */
  50047. groundColor: Color3;
  50048. /**
  50049. * Specifies the ground opacity.
  50050. * 1 by default.
  50051. */
  50052. groundOpacity: number;
  50053. /**
  50054. * Enables the ground to receive shadows.
  50055. * True by default.
  50056. */
  50057. enableGroundShadow: boolean;
  50058. /**
  50059. * Helps preventing the shadow to be fully black on the ground.
  50060. * 0.5 by default.
  50061. */
  50062. groundShadowLevel: number;
  50063. /**
  50064. * Creates a mirror texture attach to the ground.
  50065. * false by default.
  50066. */
  50067. enableGroundMirror: boolean;
  50068. /**
  50069. * Specifies the ground mirror size ratio.
  50070. * 0.3 by default as the default kernel is 64.
  50071. */
  50072. groundMirrorSizeRatio: number;
  50073. /**
  50074. * Specifies the ground mirror blur kernel size.
  50075. * 64 by default.
  50076. */
  50077. groundMirrorBlurKernel: number;
  50078. /**
  50079. * Specifies the ground mirror visibility amount.
  50080. * 1 by default
  50081. */
  50082. groundMirrorAmount: number;
  50083. /**
  50084. * Specifies the ground mirror reflectance weight.
  50085. * This uses the standard weight of the background material to setup the fresnel effect
  50086. * of the mirror.
  50087. * 1 by default.
  50088. */
  50089. groundMirrorFresnelWeight: number;
  50090. /**
  50091. * Specifies the ground mirror Falloff distance.
  50092. * This can helps reducing the size of the reflection.
  50093. * 0 by Default.
  50094. */
  50095. groundMirrorFallOffDistance: number;
  50096. /**
  50097. * Specifies the ground mirror texture type.
  50098. * Unsigned Int by Default.
  50099. */
  50100. groundMirrorTextureType: number;
  50101. /**
  50102. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50103. * the shown objects.
  50104. */
  50105. groundYBias: number;
  50106. /**
  50107. * Specifies whether or not to create a skybox.
  50108. * True by default.
  50109. */
  50110. createSkybox: boolean;
  50111. /**
  50112. * Specifies the skybox size.
  50113. * 20 by default.
  50114. */
  50115. skyboxSize: number;
  50116. /**
  50117. * The texture used on the skybox for the main color.
  50118. * Comes from the BabylonJS CDN by default.
  50119. *
  50120. * Remarks: Can be either a texture or a url.
  50121. */
  50122. skyboxTexture: string | BaseTexture;
  50123. /**
  50124. * The color mixed in the skybox texture by default.
  50125. * BabylonJS clearColor by default.
  50126. */
  50127. skyboxColor: Color3;
  50128. /**
  50129. * The background rotation around the Y axis of the scene.
  50130. * This helps aligning the key lights of your scene with the background.
  50131. * 0 by default.
  50132. */
  50133. backgroundYRotation: number;
  50134. /**
  50135. * Compute automatically the size of the elements to best fit with the scene.
  50136. */
  50137. sizeAuto: boolean;
  50138. /**
  50139. * Default position of the rootMesh if autoSize is not true.
  50140. */
  50141. rootPosition: Vector3;
  50142. /**
  50143. * Sets up the image processing in the scene.
  50144. * true by default.
  50145. */
  50146. setupImageProcessing: boolean;
  50147. /**
  50148. * The texture used as your environment texture in the scene.
  50149. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50150. *
  50151. * Remarks: Can be either a texture or a url.
  50152. */
  50153. environmentTexture: string | BaseTexture;
  50154. /**
  50155. * The value of the exposure to apply to the scene.
  50156. * 0.6 by default if setupImageProcessing is true.
  50157. */
  50158. cameraExposure: number;
  50159. /**
  50160. * The value of the contrast to apply to the scene.
  50161. * 1.6 by default if setupImageProcessing is true.
  50162. */
  50163. cameraContrast: number;
  50164. /**
  50165. * Specifies whether or not tonemapping should be enabled in the scene.
  50166. * true by default if setupImageProcessing is true.
  50167. */
  50168. toneMappingEnabled: boolean;
  50169. }
  50170. /**
  50171. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50172. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50173. * It also helps with the default setup of your imageProcessing configuration.
  50174. */
  50175. export class EnvironmentHelper {
  50176. /**
  50177. * Default ground texture URL.
  50178. */
  50179. private static _groundTextureCDNUrl;
  50180. /**
  50181. * Default skybox texture URL.
  50182. */
  50183. private static _skyboxTextureCDNUrl;
  50184. /**
  50185. * Default environment texture URL.
  50186. */
  50187. private static _environmentTextureCDNUrl;
  50188. /**
  50189. * Creates the default options for the helper.
  50190. */
  50191. private static _getDefaultOptions;
  50192. private _rootMesh;
  50193. /**
  50194. * Gets the root mesh created by the helper.
  50195. */
  50196. get rootMesh(): Mesh;
  50197. private _skybox;
  50198. /**
  50199. * Gets the skybox created by the helper.
  50200. */
  50201. get skybox(): Nullable<Mesh>;
  50202. private _skyboxTexture;
  50203. /**
  50204. * Gets the skybox texture created by the helper.
  50205. */
  50206. get skyboxTexture(): Nullable<BaseTexture>;
  50207. private _skyboxMaterial;
  50208. /**
  50209. * Gets the skybox material created by the helper.
  50210. */
  50211. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50212. private _ground;
  50213. /**
  50214. * Gets the ground mesh created by the helper.
  50215. */
  50216. get ground(): Nullable<Mesh>;
  50217. private _groundTexture;
  50218. /**
  50219. * Gets the ground texture created by the helper.
  50220. */
  50221. get groundTexture(): Nullable<BaseTexture>;
  50222. private _groundMirror;
  50223. /**
  50224. * Gets the ground mirror created by the helper.
  50225. */
  50226. get groundMirror(): Nullable<MirrorTexture>;
  50227. /**
  50228. * Gets the ground mirror render list to helps pushing the meshes
  50229. * you wish in the ground reflection.
  50230. */
  50231. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50232. private _groundMaterial;
  50233. /**
  50234. * Gets the ground material created by the helper.
  50235. */
  50236. get groundMaterial(): Nullable<BackgroundMaterial>;
  50237. /**
  50238. * Stores the creation options.
  50239. */
  50240. private readonly _scene;
  50241. private _options;
  50242. /**
  50243. * This observable will be notified with any error during the creation of the environment,
  50244. * mainly texture creation errors.
  50245. */
  50246. onErrorObservable: Observable<{
  50247. message?: string;
  50248. exception?: any;
  50249. }>;
  50250. /**
  50251. * constructor
  50252. * @param options Defines the options we want to customize the helper
  50253. * @param scene The scene to add the material to
  50254. */
  50255. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50256. /**
  50257. * Updates the background according to the new options
  50258. * @param options
  50259. */
  50260. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50261. /**
  50262. * Sets the primary color of all the available elements.
  50263. * @param color the main color to affect to the ground and the background
  50264. */
  50265. setMainColor(color: Color3): void;
  50266. /**
  50267. * Setup the image processing according to the specified options.
  50268. */
  50269. private _setupImageProcessing;
  50270. /**
  50271. * Setup the environment texture according to the specified options.
  50272. */
  50273. private _setupEnvironmentTexture;
  50274. /**
  50275. * Setup the background according to the specified options.
  50276. */
  50277. private _setupBackground;
  50278. /**
  50279. * Get the scene sizes according to the setup.
  50280. */
  50281. private _getSceneSize;
  50282. /**
  50283. * Setup the ground according to the specified options.
  50284. */
  50285. private _setupGround;
  50286. /**
  50287. * Setup the ground material according to the specified options.
  50288. */
  50289. private _setupGroundMaterial;
  50290. /**
  50291. * Setup the ground diffuse texture according to the specified options.
  50292. */
  50293. private _setupGroundDiffuseTexture;
  50294. /**
  50295. * Setup the ground mirror texture according to the specified options.
  50296. */
  50297. private _setupGroundMirrorTexture;
  50298. /**
  50299. * Setup the ground to receive the mirror texture.
  50300. */
  50301. private _setupMirrorInGroundMaterial;
  50302. /**
  50303. * Setup the skybox according to the specified options.
  50304. */
  50305. private _setupSkybox;
  50306. /**
  50307. * Setup the skybox material according to the specified options.
  50308. */
  50309. private _setupSkyboxMaterial;
  50310. /**
  50311. * Setup the skybox reflection texture according to the specified options.
  50312. */
  50313. private _setupSkyboxReflectionTexture;
  50314. private _errorHandler;
  50315. /**
  50316. * Dispose all the elements created by the Helper.
  50317. */
  50318. dispose(): void;
  50319. }
  50320. }
  50321. declare module BABYLON {
  50322. /**
  50323. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50324. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50325. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50326. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50327. */
  50328. export class PhotoDome extends TransformNode {
  50329. /**
  50330. * Define the image as a Monoscopic panoramic 360 image.
  50331. */
  50332. static readonly MODE_MONOSCOPIC: number;
  50333. /**
  50334. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50335. */
  50336. static readonly MODE_TOPBOTTOM: number;
  50337. /**
  50338. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50339. */
  50340. static readonly MODE_SIDEBYSIDE: number;
  50341. private _useDirectMapping;
  50342. /**
  50343. * The texture being displayed on the sphere
  50344. */
  50345. protected _photoTexture: Texture;
  50346. /**
  50347. * Gets or sets the texture being displayed on the sphere
  50348. */
  50349. get photoTexture(): Texture;
  50350. set photoTexture(value: Texture);
  50351. /**
  50352. * Observable raised when an error occured while loading the 360 image
  50353. */
  50354. onLoadErrorObservable: Observable<string>;
  50355. /**
  50356. * The skybox material
  50357. */
  50358. protected _material: BackgroundMaterial;
  50359. /**
  50360. * The surface used for the skybox
  50361. */
  50362. protected _mesh: Mesh;
  50363. /**
  50364. * Gets the mesh used for the skybox.
  50365. */
  50366. get mesh(): Mesh;
  50367. /**
  50368. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50369. * Also see the options.resolution property.
  50370. */
  50371. get fovMultiplier(): number;
  50372. set fovMultiplier(value: number);
  50373. private _imageMode;
  50374. /**
  50375. * Gets or set the current video mode for the video. It can be:
  50376. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50377. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50378. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50379. */
  50380. get imageMode(): number;
  50381. set imageMode(value: number);
  50382. /**
  50383. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50384. * @param name Element's name, child elements will append suffixes for their own names.
  50385. * @param urlsOfPhoto defines the url of the photo to display
  50386. * @param options defines an object containing optional or exposed sub element properties
  50387. * @param onError defines a callback called when an error occured while loading the texture
  50388. */
  50389. constructor(name: string, urlOfPhoto: string, options: {
  50390. resolution?: number;
  50391. size?: number;
  50392. useDirectMapping?: boolean;
  50393. faceForward?: boolean;
  50394. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50395. private _onBeforeCameraRenderObserver;
  50396. private _changeImageMode;
  50397. /**
  50398. * Releases resources associated with this node.
  50399. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50400. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50401. */
  50402. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50403. }
  50404. }
  50405. declare module BABYLON {
  50406. /**
  50407. * Class used to host RGBD texture specific utilities
  50408. */
  50409. export class RGBDTextureTools {
  50410. /**
  50411. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50412. * @param texture the texture to expand.
  50413. */
  50414. static ExpandRGBDTexture(texture: Texture): void;
  50415. }
  50416. }
  50417. declare module BABYLON {
  50418. /**
  50419. * Class used to host texture specific utilities
  50420. */
  50421. export class BRDFTextureTools {
  50422. /**
  50423. * Prevents texture cache collision
  50424. */
  50425. private static _instanceNumber;
  50426. /**
  50427. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50428. * @param scene defines the hosting scene
  50429. * @returns the environment BRDF texture
  50430. */
  50431. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50432. private static _environmentBRDFBase64Texture;
  50433. }
  50434. }
  50435. declare module BABYLON {
  50436. /**
  50437. * @hidden
  50438. */
  50439. export interface IMaterialClearCoatDefines {
  50440. CLEARCOAT: boolean;
  50441. CLEARCOAT_DEFAULTIOR: boolean;
  50442. CLEARCOAT_TEXTURE: boolean;
  50443. CLEARCOAT_TEXTUREDIRECTUV: number;
  50444. CLEARCOAT_BUMP: boolean;
  50445. CLEARCOAT_BUMPDIRECTUV: number;
  50446. CLEARCOAT_TINT: boolean;
  50447. CLEARCOAT_TINT_TEXTURE: boolean;
  50448. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50449. /** @hidden */
  50450. _areTexturesDirty: boolean;
  50451. }
  50452. /**
  50453. * Define the code related to the clear coat parameters of the pbr material.
  50454. */
  50455. export class PBRClearCoatConfiguration {
  50456. /**
  50457. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50458. * The default fits with a polyurethane material.
  50459. */
  50460. private static readonly _DefaultIndexOfRefraction;
  50461. private _isEnabled;
  50462. /**
  50463. * Defines if the clear coat is enabled in the material.
  50464. */
  50465. isEnabled: boolean;
  50466. /**
  50467. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50468. */
  50469. intensity: number;
  50470. /**
  50471. * Defines the clear coat layer roughness.
  50472. */
  50473. roughness: number;
  50474. private _indexOfRefraction;
  50475. /**
  50476. * Defines the index of refraction of the clear coat.
  50477. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50478. * The default fits with a polyurethane material.
  50479. * Changing the default value is more performance intensive.
  50480. */
  50481. indexOfRefraction: number;
  50482. private _texture;
  50483. /**
  50484. * Stores the clear coat values in a texture.
  50485. */
  50486. texture: Nullable<BaseTexture>;
  50487. private _bumpTexture;
  50488. /**
  50489. * Define the clear coat specific bump texture.
  50490. */
  50491. bumpTexture: Nullable<BaseTexture>;
  50492. private _isTintEnabled;
  50493. /**
  50494. * Defines if the clear coat tint is enabled in the material.
  50495. */
  50496. isTintEnabled: boolean;
  50497. /**
  50498. * Defines the clear coat tint of the material.
  50499. * This is only use if tint is enabled
  50500. */
  50501. tintColor: Color3;
  50502. /**
  50503. * Defines the distance at which the tint color should be found in the
  50504. * clear coat media.
  50505. * This is only use if tint is enabled
  50506. */
  50507. tintColorAtDistance: number;
  50508. /**
  50509. * Defines the clear coat layer thickness.
  50510. * This is only use if tint is enabled
  50511. */
  50512. tintThickness: number;
  50513. private _tintTexture;
  50514. /**
  50515. * Stores the clear tint values in a texture.
  50516. * rgb is tint
  50517. * a is a thickness factor
  50518. */
  50519. tintTexture: Nullable<BaseTexture>;
  50520. /** @hidden */
  50521. private _internalMarkAllSubMeshesAsTexturesDirty;
  50522. /** @hidden */
  50523. _markAllSubMeshesAsTexturesDirty(): void;
  50524. /**
  50525. * Instantiate a new istance of clear coat configuration.
  50526. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50527. */
  50528. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50529. /**
  50530. * Gets wehter the submesh is ready to be used or not.
  50531. * @param defines the list of "defines" to update.
  50532. * @param scene defines the scene the material belongs to.
  50533. * @param engine defines the engine the material belongs to.
  50534. * @param disableBumpMap defines wether the material disables bump or not.
  50535. * @returns - boolean indicating that the submesh is ready or not.
  50536. */
  50537. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50538. /**
  50539. * Checks to see if a texture is used in the material.
  50540. * @param defines the list of "defines" to update.
  50541. * @param scene defines the scene to the material belongs to.
  50542. */
  50543. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50544. /**
  50545. * Binds the material data.
  50546. * @param uniformBuffer defines the Uniform buffer to fill in.
  50547. * @param scene defines the scene the material belongs to.
  50548. * @param engine defines the engine the material belongs to.
  50549. * @param disableBumpMap defines wether the material disables bump or not.
  50550. * @param isFrozen defines wether the material is frozen or not.
  50551. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50552. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50553. */
  50554. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50555. /**
  50556. * Checks to see if a texture is used in the material.
  50557. * @param texture - Base texture to use.
  50558. * @returns - Boolean specifying if a texture is used in the material.
  50559. */
  50560. hasTexture(texture: BaseTexture): boolean;
  50561. /**
  50562. * Returns an array of the actively used textures.
  50563. * @param activeTextures Array of BaseTextures
  50564. */
  50565. getActiveTextures(activeTextures: BaseTexture[]): void;
  50566. /**
  50567. * Returns the animatable textures.
  50568. * @param animatables Array of animatable textures.
  50569. */
  50570. getAnimatables(animatables: IAnimatable[]): void;
  50571. /**
  50572. * Disposes the resources of the material.
  50573. * @param forceDisposeTextures - Forces the disposal of all textures.
  50574. */
  50575. dispose(forceDisposeTextures?: boolean): void;
  50576. /**
  50577. * Get the current class name of the texture useful for serialization or dynamic coding.
  50578. * @returns "PBRClearCoatConfiguration"
  50579. */
  50580. getClassName(): string;
  50581. /**
  50582. * Add fallbacks to the effect fallbacks list.
  50583. * @param defines defines the Base texture to use.
  50584. * @param fallbacks defines the current fallback list.
  50585. * @param currentRank defines the current fallback rank.
  50586. * @returns the new fallback rank.
  50587. */
  50588. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50589. /**
  50590. * Add the required uniforms to the current list.
  50591. * @param uniforms defines the current uniform list.
  50592. */
  50593. static AddUniforms(uniforms: string[]): void;
  50594. /**
  50595. * Add the required samplers to the current list.
  50596. * @param samplers defines the current sampler list.
  50597. */
  50598. static AddSamplers(samplers: string[]): void;
  50599. /**
  50600. * Add the required uniforms to the current buffer.
  50601. * @param uniformBuffer defines the current uniform buffer.
  50602. */
  50603. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50604. /**
  50605. * Makes a duplicate of the current configuration into another one.
  50606. * @param clearCoatConfiguration define the config where to copy the info
  50607. */
  50608. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50609. /**
  50610. * Serializes this clear coat configuration.
  50611. * @returns - An object with the serialized config.
  50612. */
  50613. serialize(): any;
  50614. /**
  50615. * Parses a anisotropy Configuration from a serialized object.
  50616. * @param source - Serialized object.
  50617. * @param scene Defines the scene we are parsing for
  50618. * @param rootUrl Defines the rootUrl to load from
  50619. */
  50620. parse(source: any, scene: Scene, rootUrl: string): void;
  50621. }
  50622. }
  50623. declare module BABYLON {
  50624. /**
  50625. * @hidden
  50626. */
  50627. export interface IMaterialAnisotropicDefines {
  50628. ANISOTROPIC: boolean;
  50629. ANISOTROPIC_TEXTURE: boolean;
  50630. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50631. MAINUV1: boolean;
  50632. _areTexturesDirty: boolean;
  50633. _needUVs: boolean;
  50634. }
  50635. /**
  50636. * Define the code related to the anisotropic parameters of the pbr material.
  50637. */
  50638. export class PBRAnisotropicConfiguration {
  50639. private _isEnabled;
  50640. /**
  50641. * Defines if the anisotropy is enabled in the material.
  50642. */
  50643. isEnabled: boolean;
  50644. /**
  50645. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50646. */
  50647. intensity: number;
  50648. /**
  50649. * Defines if the effect is along the tangents, bitangents or in between.
  50650. * By default, the effect is "strectching" the highlights along the tangents.
  50651. */
  50652. direction: Vector2;
  50653. private _texture;
  50654. /**
  50655. * Stores the anisotropy values in a texture.
  50656. * rg is direction (like normal from -1 to 1)
  50657. * b is a intensity
  50658. */
  50659. texture: Nullable<BaseTexture>;
  50660. /** @hidden */
  50661. private _internalMarkAllSubMeshesAsTexturesDirty;
  50662. /** @hidden */
  50663. _markAllSubMeshesAsTexturesDirty(): void;
  50664. /**
  50665. * Instantiate a new istance of anisotropy configuration.
  50666. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50667. */
  50668. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50669. /**
  50670. * Specifies that the submesh is ready to be used.
  50671. * @param defines the list of "defines" to update.
  50672. * @param scene defines the scene the material belongs to.
  50673. * @returns - boolean indicating that the submesh is ready or not.
  50674. */
  50675. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50676. /**
  50677. * Checks to see if a texture is used in the material.
  50678. * @param defines the list of "defines" to update.
  50679. * @param mesh the mesh we are preparing the defines for.
  50680. * @param scene defines the scene the material belongs to.
  50681. */
  50682. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50683. /**
  50684. * Binds the material data.
  50685. * @param uniformBuffer defines the Uniform buffer to fill in.
  50686. * @param scene defines the scene the material belongs to.
  50687. * @param isFrozen defines wether the material is frozen or not.
  50688. */
  50689. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50690. /**
  50691. * Checks to see if a texture is used in the material.
  50692. * @param texture - Base texture to use.
  50693. * @returns - Boolean specifying if a texture is used in the material.
  50694. */
  50695. hasTexture(texture: BaseTexture): boolean;
  50696. /**
  50697. * Returns an array of the actively used textures.
  50698. * @param activeTextures Array of BaseTextures
  50699. */
  50700. getActiveTextures(activeTextures: BaseTexture[]): void;
  50701. /**
  50702. * Returns the animatable textures.
  50703. * @param animatables Array of animatable textures.
  50704. */
  50705. getAnimatables(animatables: IAnimatable[]): void;
  50706. /**
  50707. * Disposes the resources of the material.
  50708. * @param forceDisposeTextures - Forces the disposal of all textures.
  50709. */
  50710. dispose(forceDisposeTextures?: boolean): void;
  50711. /**
  50712. * Get the current class name of the texture useful for serialization or dynamic coding.
  50713. * @returns "PBRAnisotropicConfiguration"
  50714. */
  50715. getClassName(): string;
  50716. /**
  50717. * Add fallbacks to the effect fallbacks list.
  50718. * @param defines defines the Base texture to use.
  50719. * @param fallbacks defines the current fallback list.
  50720. * @param currentRank defines the current fallback rank.
  50721. * @returns the new fallback rank.
  50722. */
  50723. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50724. /**
  50725. * Add the required uniforms to the current list.
  50726. * @param uniforms defines the current uniform list.
  50727. */
  50728. static AddUniforms(uniforms: string[]): void;
  50729. /**
  50730. * Add the required uniforms to the current buffer.
  50731. * @param uniformBuffer defines the current uniform buffer.
  50732. */
  50733. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50734. /**
  50735. * Add the required samplers to the current list.
  50736. * @param samplers defines the current sampler list.
  50737. */
  50738. static AddSamplers(samplers: string[]): void;
  50739. /**
  50740. * Makes a duplicate of the current configuration into another one.
  50741. * @param anisotropicConfiguration define the config where to copy the info
  50742. */
  50743. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50744. /**
  50745. * Serializes this anisotropy configuration.
  50746. * @returns - An object with the serialized config.
  50747. */
  50748. serialize(): any;
  50749. /**
  50750. * Parses a anisotropy Configuration from a serialized object.
  50751. * @param source - Serialized object.
  50752. * @param scene Defines the scene we are parsing for
  50753. * @param rootUrl Defines the rootUrl to load from
  50754. */
  50755. parse(source: any, scene: Scene, rootUrl: string): void;
  50756. }
  50757. }
  50758. declare module BABYLON {
  50759. /**
  50760. * @hidden
  50761. */
  50762. export interface IMaterialBRDFDefines {
  50763. BRDF_V_HEIGHT_CORRELATED: boolean;
  50764. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50765. SPHERICAL_HARMONICS: boolean;
  50766. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50767. /** @hidden */
  50768. _areMiscDirty: boolean;
  50769. }
  50770. /**
  50771. * Define the code related to the BRDF parameters of the pbr material.
  50772. */
  50773. export class PBRBRDFConfiguration {
  50774. /**
  50775. * Default value used for the energy conservation.
  50776. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50777. */
  50778. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50779. /**
  50780. * Default value used for the Smith Visibility Height Correlated mode.
  50781. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50782. */
  50783. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50784. /**
  50785. * Default value used for the IBL diffuse part.
  50786. * This can help switching back to the polynomials mode globally which is a tiny bit
  50787. * less GPU intensive at the drawback of a lower quality.
  50788. */
  50789. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50790. /**
  50791. * Default value used for activating energy conservation for the specular workflow.
  50792. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50793. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50794. */
  50795. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50796. private _useEnergyConservation;
  50797. /**
  50798. * Defines if the material uses energy conservation.
  50799. */
  50800. useEnergyConservation: boolean;
  50801. private _useSmithVisibilityHeightCorrelated;
  50802. /**
  50803. * LEGACY Mode set to false
  50804. * Defines if the material uses height smith correlated visibility term.
  50805. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50806. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50807. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50808. * Not relying on height correlated will also disable energy conservation.
  50809. */
  50810. useSmithVisibilityHeightCorrelated: boolean;
  50811. private _useSphericalHarmonics;
  50812. /**
  50813. * LEGACY Mode set to false
  50814. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50815. * diffuse part of the IBL.
  50816. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50817. * to the ground truth.
  50818. */
  50819. useSphericalHarmonics: boolean;
  50820. private _useSpecularGlossinessInputEnergyConservation;
  50821. /**
  50822. * Defines if the material uses energy conservation, when the specular workflow is active.
  50823. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50824. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50825. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50826. */
  50827. useSpecularGlossinessInputEnergyConservation: boolean;
  50828. /** @hidden */
  50829. private _internalMarkAllSubMeshesAsMiscDirty;
  50830. /** @hidden */
  50831. _markAllSubMeshesAsMiscDirty(): void;
  50832. /**
  50833. * Instantiate a new istance of clear coat configuration.
  50834. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50835. */
  50836. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50837. /**
  50838. * Checks to see if a texture is used in the material.
  50839. * @param defines the list of "defines" to update.
  50840. */
  50841. prepareDefines(defines: IMaterialBRDFDefines): void;
  50842. /**
  50843. * Get the current class name of the texture useful for serialization or dynamic coding.
  50844. * @returns "PBRClearCoatConfiguration"
  50845. */
  50846. getClassName(): string;
  50847. /**
  50848. * Makes a duplicate of the current configuration into another one.
  50849. * @param brdfConfiguration define the config where to copy the info
  50850. */
  50851. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50852. /**
  50853. * Serializes this BRDF configuration.
  50854. * @returns - An object with the serialized config.
  50855. */
  50856. serialize(): any;
  50857. /**
  50858. * Parses a anisotropy Configuration from a serialized object.
  50859. * @param source - Serialized object.
  50860. * @param scene Defines the scene we are parsing for
  50861. * @param rootUrl Defines the rootUrl to load from
  50862. */
  50863. parse(source: any, scene: Scene, rootUrl: string): void;
  50864. }
  50865. }
  50866. declare module BABYLON {
  50867. /**
  50868. * @hidden
  50869. */
  50870. export interface IMaterialSheenDefines {
  50871. SHEEN: boolean;
  50872. SHEEN_TEXTURE: boolean;
  50873. SHEEN_TEXTUREDIRECTUV: number;
  50874. SHEEN_LINKWITHALBEDO: boolean;
  50875. SHEEN_ROUGHNESS: boolean;
  50876. SHEEN_ALBEDOSCALING: boolean;
  50877. /** @hidden */
  50878. _areTexturesDirty: boolean;
  50879. }
  50880. /**
  50881. * Define the code related to the Sheen parameters of the pbr material.
  50882. */
  50883. export class PBRSheenConfiguration {
  50884. private _isEnabled;
  50885. /**
  50886. * Defines if the material uses sheen.
  50887. */
  50888. isEnabled: boolean;
  50889. private _linkSheenWithAlbedo;
  50890. /**
  50891. * Defines if the sheen is linked to the sheen color.
  50892. */
  50893. linkSheenWithAlbedo: boolean;
  50894. /**
  50895. * Defines the sheen intensity.
  50896. */
  50897. intensity: number;
  50898. /**
  50899. * Defines the sheen color.
  50900. */
  50901. color: Color3;
  50902. private _texture;
  50903. /**
  50904. * Stores the sheen tint values in a texture.
  50905. * rgb is tint
  50906. * a is a intensity
  50907. */
  50908. texture: Nullable<BaseTexture>;
  50909. private _roughness;
  50910. /**
  50911. * Defines the sheen roughness.
  50912. * It is not taken into account if linkSheenWithAlbedo is true.
  50913. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50914. */
  50915. roughness: Nullable<number>;
  50916. private _albedoScaling;
  50917. /**
  50918. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50919. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50920. * making it easier to setup and tweak the effect
  50921. */
  50922. albedoScaling: boolean;
  50923. /** @hidden */
  50924. private _internalMarkAllSubMeshesAsTexturesDirty;
  50925. /** @hidden */
  50926. _markAllSubMeshesAsTexturesDirty(): void;
  50927. /**
  50928. * Instantiate a new istance of clear coat configuration.
  50929. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50930. */
  50931. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50932. /**
  50933. * Specifies that the submesh is ready to be used.
  50934. * @param defines the list of "defines" to update.
  50935. * @param scene defines the scene the material belongs to.
  50936. * @returns - boolean indicating that the submesh is ready or not.
  50937. */
  50938. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50939. /**
  50940. * Checks to see if a texture is used in the material.
  50941. * @param defines the list of "defines" to update.
  50942. * @param scene defines the scene the material belongs to.
  50943. */
  50944. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50945. /**
  50946. * Binds the material data.
  50947. * @param uniformBuffer defines the Uniform buffer to fill in.
  50948. * @param scene defines the scene the material belongs to.
  50949. * @param isFrozen defines wether the material is frozen or not.
  50950. */
  50951. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50952. /**
  50953. * Checks to see if a texture is used in the material.
  50954. * @param texture - Base texture to use.
  50955. * @returns - Boolean specifying if a texture is used in the material.
  50956. */
  50957. hasTexture(texture: BaseTexture): boolean;
  50958. /**
  50959. * Returns an array of the actively used textures.
  50960. * @param activeTextures Array of BaseTextures
  50961. */
  50962. getActiveTextures(activeTextures: BaseTexture[]): void;
  50963. /**
  50964. * Returns the animatable textures.
  50965. * @param animatables Array of animatable textures.
  50966. */
  50967. getAnimatables(animatables: IAnimatable[]): void;
  50968. /**
  50969. * Disposes the resources of the material.
  50970. * @param forceDisposeTextures - Forces the disposal of all textures.
  50971. */
  50972. dispose(forceDisposeTextures?: boolean): void;
  50973. /**
  50974. * Get the current class name of the texture useful for serialization or dynamic coding.
  50975. * @returns "PBRSheenConfiguration"
  50976. */
  50977. getClassName(): string;
  50978. /**
  50979. * Add fallbacks to the effect fallbacks list.
  50980. * @param defines defines the Base texture to use.
  50981. * @param fallbacks defines the current fallback list.
  50982. * @param currentRank defines the current fallback rank.
  50983. * @returns the new fallback rank.
  50984. */
  50985. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50986. /**
  50987. * Add the required uniforms to the current list.
  50988. * @param uniforms defines the current uniform list.
  50989. */
  50990. static AddUniforms(uniforms: string[]): void;
  50991. /**
  50992. * Add the required uniforms to the current buffer.
  50993. * @param uniformBuffer defines the current uniform buffer.
  50994. */
  50995. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50996. /**
  50997. * Add the required samplers to the current list.
  50998. * @param samplers defines the current sampler list.
  50999. */
  51000. static AddSamplers(samplers: string[]): void;
  51001. /**
  51002. * Makes a duplicate of the current configuration into another one.
  51003. * @param sheenConfiguration define the config where to copy the info
  51004. */
  51005. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51006. /**
  51007. * Serializes this BRDF configuration.
  51008. * @returns - An object with the serialized config.
  51009. */
  51010. serialize(): any;
  51011. /**
  51012. * Parses a anisotropy Configuration from a serialized object.
  51013. * @param source - Serialized object.
  51014. * @param scene Defines the scene we are parsing for
  51015. * @param rootUrl Defines the rootUrl to load from
  51016. */
  51017. parse(source: any, scene: Scene, rootUrl: string): void;
  51018. }
  51019. }
  51020. declare module BABYLON {
  51021. /**
  51022. * @hidden
  51023. */
  51024. export interface IMaterialSubSurfaceDefines {
  51025. SUBSURFACE: boolean;
  51026. SS_REFRACTION: boolean;
  51027. SS_TRANSLUCENCY: boolean;
  51028. SS_SCATERRING: boolean;
  51029. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51030. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51031. SS_REFRACTIONMAP_3D: boolean;
  51032. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51033. SS_LODINREFRACTIONALPHA: boolean;
  51034. SS_GAMMAREFRACTION: boolean;
  51035. SS_RGBDREFRACTION: boolean;
  51036. SS_LINEARSPECULARREFRACTION: boolean;
  51037. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51038. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51039. /** @hidden */
  51040. _areTexturesDirty: boolean;
  51041. }
  51042. /**
  51043. * Define the code related to the sub surface parameters of the pbr material.
  51044. */
  51045. export class PBRSubSurfaceConfiguration {
  51046. private _isRefractionEnabled;
  51047. /**
  51048. * Defines if the refraction is enabled in the material.
  51049. */
  51050. isRefractionEnabled: boolean;
  51051. private _isTranslucencyEnabled;
  51052. /**
  51053. * Defines if the translucency is enabled in the material.
  51054. */
  51055. isTranslucencyEnabled: boolean;
  51056. private _isScatteringEnabled;
  51057. /**
  51058. * Defines the refraction intensity of the material.
  51059. * The refraction when enabled replaces the Diffuse part of the material.
  51060. * The intensity helps transitionning between diffuse and refraction.
  51061. */
  51062. refractionIntensity: number;
  51063. /**
  51064. * Defines the translucency intensity of the material.
  51065. * When translucency has been enabled, this defines how much of the "translucency"
  51066. * is addded to the diffuse part of the material.
  51067. */
  51068. translucencyIntensity: number;
  51069. /**
  51070. * Defines the scattering intensity of the material.
  51071. * When scattering has been enabled, this defines how much of the "scattered light"
  51072. * is addded to the diffuse part of the material.
  51073. */
  51074. scatteringIntensity: number;
  51075. private _thicknessTexture;
  51076. /**
  51077. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51078. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51079. * 0 would mean minimumThickness
  51080. * 1 would mean maximumThickness
  51081. * The other channels might be use as a mask to vary the different effects intensity.
  51082. */
  51083. thicknessTexture: Nullable<BaseTexture>;
  51084. private _refractionTexture;
  51085. /**
  51086. * Defines the texture to use for refraction.
  51087. */
  51088. refractionTexture: Nullable<BaseTexture>;
  51089. private _indexOfRefraction;
  51090. /**
  51091. * Defines the index of refraction used in the material.
  51092. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51093. */
  51094. indexOfRefraction: number;
  51095. private _invertRefractionY;
  51096. /**
  51097. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51098. */
  51099. invertRefractionY: boolean;
  51100. private _linkRefractionWithTransparency;
  51101. /**
  51102. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51103. * Materials half opaque for instance using refraction could benefit from this control.
  51104. */
  51105. linkRefractionWithTransparency: boolean;
  51106. /**
  51107. * Defines the minimum thickness stored in the thickness map.
  51108. * If no thickness map is defined, this value will be used to simulate thickness.
  51109. */
  51110. minimumThickness: number;
  51111. /**
  51112. * Defines the maximum thickness stored in the thickness map.
  51113. */
  51114. maximumThickness: number;
  51115. /**
  51116. * Defines the volume tint of the material.
  51117. * This is used for both translucency and scattering.
  51118. */
  51119. tintColor: Color3;
  51120. /**
  51121. * Defines the distance at which the tint color should be found in the media.
  51122. * This is used for refraction only.
  51123. */
  51124. tintColorAtDistance: number;
  51125. /**
  51126. * Defines how far each channel transmit through the media.
  51127. * It is defined as a color to simplify it selection.
  51128. */
  51129. diffusionDistance: Color3;
  51130. private _useMaskFromThicknessTexture;
  51131. /**
  51132. * Stores the intensity of the different subsurface effects in the thickness texture.
  51133. * * the green channel is the translucency intensity.
  51134. * * the blue channel is the scattering intensity.
  51135. * * the alpha channel is the refraction intensity.
  51136. */
  51137. useMaskFromThicknessTexture: boolean;
  51138. /** @hidden */
  51139. private _internalMarkAllSubMeshesAsTexturesDirty;
  51140. /** @hidden */
  51141. _markAllSubMeshesAsTexturesDirty(): void;
  51142. /**
  51143. * Instantiate a new istance of sub surface configuration.
  51144. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51145. */
  51146. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51147. /**
  51148. * Gets wehter the submesh is ready to be used or not.
  51149. * @param defines the list of "defines" to update.
  51150. * @param scene defines the scene the material belongs to.
  51151. * @returns - boolean indicating that the submesh is ready or not.
  51152. */
  51153. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51154. /**
  51155. * Checks to see if a texture is used in the material.
  51156. * @param defines the list of "defines" to update.
  51157. * @param scene defines the scene to the material belongs to.
  51158. */
  51159. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51160. /**
  51161. * Binds the material data.
  51162. * @param uniformBuffer defines the Uniform buffer to fill in.
  51163. * @param scene defines the scene the material belongs to.
  51164. * @param engine defines the engine the material belongs to.
  51165. * @param isFrozen defines wether the material is frozen or not.
  51166. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51167. */
  51168. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51169. /**
  51170. * Unbinds the material from the mesh.
  51171. * @param activeEffect defines the effect that should be unbound from.
  51172. * @returns true if unbound, otherwise false
  51173. */
  51174. unbind(activeEffect: Effect): boolean;
  51175. /**
  51176. * Returns the texture used for refraction or null if none is used.
  51177. * @param scene defines the scene the material belongs to.
  51178. * @returns - Refraction texture if present. If no refraction texture and refraction
  51179. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51180. */
  51181. private _getRefractionTexture;
  51182. /**
  51183. * Returns true if alpha blending should be disabled.
  51184. */
  51185. get disableAlphaBlending(): boolean;
  51186. /**
  51187. * Fills the list of render target textures.
  51188. * @param renderTargets the list of render targets to update
  51189. */
  51190. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51191. /**
  51192. * Checks to see if a texture is used in the material.
  51193. * @param texture - Base texture to use.
  51194. * @returns - Boolean specifying if a texture is used in the material.
  51195. */
  51196. hasTexture(texture: BaseTexture): boolean;
  51197. /**
  51198. * Gets a boolean indicating that current material needs to register RTT
  51199. * @returns true if this uses a render target otherwise false.
  51200. */
  51201. hasRenderTargetTextures(): boolean;
  51202. /**
  51203. * Returns an array of the actively used textures.
  51204. * @param activeTextures Array of BaseTextures
  51205. */
  51206. getActiveTextures(activeTextures: BaseTexture[]): void;
  51207. /**
  51208. * Returns the animatable textures.
  51209. * @param animatables Array of animatable textures.
  51210. */
  51211. getAnimatables(animatables: IAnimatable[]): void;
  51212. /**
  51213. * Disposes the resources of the material.
  51214. * @param forceDisposeTextures - Forces the disposal of all textures.
  51215. */
  51216. dispose(forceDisposeTextures?: boolean): void;
  51217. /**
  51218. * Get the current class name of the texture useful for serialization or dynamic coding.
  51219. * @returns "PBRSubSurfaceConfiguration"
  51220. */
  51221. getClassName(): string;
  51222. /**
  51223. * Add fallbacks to the effect fallbacks list.
  51224. * @param defines defines the Base texture to use.
  51225. * @param fallbacks defines the current fallback list.
  51226. * @param currentRank defines the current fallback rank.
  51227. * @returns the new fallback rank.
  51228. */
  51229. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51230. /**
  51231. * Add the required uniforms to the current list.
  51232. * @param uniforms defines the current uniform list.
  51233. */
  51234. static AddUniforms(uniforms: string[]): void;
  51235. /**
  51236. * Add the required samplers to the current list.
  51237. * @param samplers defines the current sampler list.
  51238. */
  51239. static AddSamplers(samplers: string[]): void;
  51240. /**
  51241. * Add the required uniforms to the current buffer.
  51242. * @param uniformBuffer defines the current uniform buffer.
  51243. */
  51244. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51245. /**
  51246. * Makes a duplicate of the current configuration into another one.
  51247. * @param configuration define the config where to copy the info
  51248. */
  51249. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51250. /**
  51251. * Serializes this Sub Surface configuration.
  51252. * @returns - An object with the serialized config.
  51253. */
  51254. serialize(): any;
  51255. /**
  51256. * Parses a anisotropy Configuration from a serialized object.
  51257. * @param source - Serialized object.
  51258. * @param scene Defines the scene we are parsing for
  51259. * @param rootUrl Defines the rootUrl to load from
  51260. */
  51261. parse(source: any, scene: Scene, rootUrl: string): void;
  51262. }
  51263. }
  51264. declare module BABYLON {
  51265. /** @hidden */
  51266. export var pbrFragmentDeclaration: {
  51267. name: string;
  51268. shader: string;
  51269. };
  51270. }
  51271. declare module BABYLON {
  51272. /** @hidden */
  51273. export var pbrUboDeclaration: {
  51274. name: string;
  51275. shader: string;
  51276. };
  51277. }
  51278. declare module BABYLON {
  51279. /** @hidden */
  51280. export var pbrFragmentExtraDeclaration: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module BABYLON {
  51286. /** @hidden */
  51287. export var pbrFragmentSamplersDeclaration: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module BABYLON {
  51293. /** @hidden */
  51294. export var pbrHelperFunctions: {
  51295. name: string;
  51296. shader: string;
  51297. };
  51298. }
  51299. declare module BABYLON {
  51300. /** @hidden */
  51301. export var harmonicsFunctions: {
  51302. name: string;
  51303. shader: string;
  51304. };
  51305. }
  51306. declare module BABYLON {
  51307. /** @hidden */
  51308. export var pbrDirectLightingSetupFunctions: {
  51309. name: string;
  51310. shader: string;
  51311. };
  51312. }
  51313. declare module BABYLON {
  51314. /** @hidden */
  51315. export var pbrDirectLightingFalloffFunctions: {
  51316. name: string;
  51317. shader: string;
  51318. };
  51319. }
  51320. declare module BABYLON {
  51321. /** @hidden */
  51322. export var pbrBRDFFunctions: {
  51323. name: string;
  51324. shader: string;
  51325. };
  51326. }
  51327. declare module BABYLON {
  51328. /** @hidden */
  51329. export var pbrDirectLightingFunctions: {
  51330. name: string;
  51331. shader: string;
  51332. };
  51333. }
  51334. declare module BABYLON {
  51335. /** @hidden */
  51336. export var pbrIBLFunctions: {
  51337. name: string;
  51338. shader: string;
  51339. };
  51340. }
  51341. declare module BABYLON {
  51342. /** @hidden */
  51343. export var pbrBlockAlbedoOpacity: {
  51344. name: string;
  51345. shader: string;
  51346. };
  51347. }
  51348. declare module BABYLON {
  51349. /** @hidden */
  51350. export var pbrBlockReflectivity: {
  51351. name: string;
  51352. shader: string;
  51353. };
  51354. }
  51355. declare module BABYLON {
  51356. /** @hidden */
  51357. export var pbrBlockAmbientOcclusion: {
  51358. name: string;
  51359. shader: string;
  51360. };
  51361. }
  51362. declare module BABYLON {
  51363. /** @hidden */
  51364. export var pbrBlockAlphaFresnel: {
  51365. name: string;
  51366. shader: string;
  51367. };
  51368. }
  51369. declare module BABYLON {
  51370. /** @hidden */
  51371. export var pbrBlockAnisotropic: {
  51372. name: string;
  51373. shader: string;
  51374. };
  51375. }
  51376. declare module BABYLON {
  51377. /** @hidden */
  51378. export var pbrBlockReflection: {
  51379. name: string;
  51380. shader: string;
  51381. };
  51382. }
  51383. declare module BABYLON {
  51384. /** @hidden */
  51385. export var pbrBlockSheen: {
  51386. name: string;
  51387. shader: string;
  51388. };
  51389. }
  51390. declare module BABYLON {
  51391. /** @hidden */
  51392. export var pbrBlockClearcoat: {
  51393. name: string;
  51394. shader: string;
  51395. };
  51396. }
  51397. declare module BABYLON {
  51398. /** @hidden */
  51399. export var pbrBlockSubSurface: {
  51400. name: string;
  51401. shader: string;
  51402. };
  51403. }
  51404. declare module BABYLON {
  51405. /** @hidden */
  51406. export var pbrBlockNormalGeometric: {
  51407. name: string;
  51408. shader: string;
  51409. };
  51410. }
  51411. declare module BABYLON {
  51412. /** @hidden */
  51413. export var pbrBlockNormalFinal: {
  51414. name: string;
  51415. shader: string;
  51416. };
  51417. }
  51418. declare module BABYLON {
  51419. /** @hidden */
  51420. export var pbrBlockGeometryInfo: {
  51421. name: string;
  51422. shader: string;
  51423. };
  51424. }
  51425. declare module BABYLON {
  51426. /** @hidden */
  51427. export var pbrBlockReflectance0: {
  51428. name: string;
  51429. shader: string;
  51430. };
  51431. }
  51432. declare module BABYLON {
  51433. /** @hidden */
  51434. export var pbrBlockReflectance: {
  51435. name: string;
  51436. shader: string;
  51437. };
  51438. }
  51439. declare module BABYLON {
  51440. /** @hidden */
  51441. export var pbrBlockDirectLighting: {
  51442. name: string;
  51443. shader: string;
  51444. };
  51445. }
  51446. declare module BABYLON {
  51447. /** @hidden */
  51448. export var pbrBlockFinalLitComponents: {
  51449. name: string;
  51450. shader: string;
  51451. };
  51452. }
  51453. declare module BABYLON {
  51454. /** @hidden */
  51455. export var pbrBlockFinalUnlitComponents: {
  51456. name: string;
  51457. shader: string;
  51458. };
  51459. }
  51460. declare module BABYLON {
  51461. /** @hidden */
  51462. export var pbrBlockFinalColorComposition: {
  51463. name: string;
  51464. shader: string;
  51465. };
  51466. }
  51467. declare module BABYLON {
  51468. /** @hidden */
  51469. export var pbrBlockImageProcessing: {
  51470. name: string;
  51471. shader: string;
  51472. };
  51473. }
  51474. declare module BABYLON {
  51475. /** @hidden */
  51476. export var pbrDebug: {
  51477. name: string;
  51478. shader: string;
  51479. };
  51480. }
  51481. declare module BABYLON {
  51482. /** @hidden */
  51483. export var pbrPixelShader: {
  51484. name: string;
  51485. shader: string;
  51486. };
  51487. }
  51488. declare module BABYLON {
  51489. /** @hidden */
  51490. export var pbrVertexDeclaration: {
  51491. name: string;
  51492. shader: string;
  51493. };
  51494. }
  51495. declare module BABYLON {
  51496. /** @hidden */
  51497. export var pbrVertexShader: {
  51498. name: string;
  51499. shader: string;
  51500. };
  51501. }
  51502. declare module BABYLON {
  51503. /**
  51504. * Manages the defines for the PBR Material.
  51505. * @hidden
  51506. */
  51507. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51508. PBR: boolean;
  51509. MAINUV1: boolean;
  51510. MAINUV2: boolean;
  51511. UV1: boolean;
  51512. UV2: boolean;
  51513. ALBEDO: boolean;
  51514. GAMMAALBEDO: boolean;
  51515. ALBEDODIRECTUV: number;
  51516. VERTEXCOLOR: boolean;
  51517. AMBIENT: boolean;
  51518. AMBIENTDIRECTUV: number;
  51519. AMBIENTINGRAYSCALE: boolean;
  51520. OPACITY: boolean;
  51521. VERTEXALPHA: boolean;
  51522. OPACITYDIRECTUV: number;
  51523. OPACITYRGB: boolean;
  51524. ALPHATEST: boolean;
  51525. DEPTHPREPASS: boolean;
  51526. ALPHABLEND: boolean;
  51527. ALPHAFROMALBEDO: boolean;
  51528. ALPHATESTVALUE: string;
  51529. SPECULAROVERALPHA: boolean;
  51530. RADIANCEOVERALPHA: boolean;
  51531. ALPHAFRESNEL: boolean;
  51532. LINEARALPHAFRESNEL: boolean;
  51533. PREMULTIPLYALPHA: boolean;
  51534. EMISSIVE: boolean;
  51535. EMISSIVEDIRECTUV: number;
  51536. REFLECTIVITY: boolean;
  51537. REFLECTIVITYDIRECTUV: number;
  51538. SPECULARTERM: boolean;
  51539. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51540. MICROSURFACEAUTOMATIC: boolean;
  51541. LODBASEDMICROSFURACE: boolean;
  51542. MICROSURFACEMAP: boolean;
  51543. MICROSURFACEMAPDIRECTUV: number;
  51544. METALLICWORKFLOW: boolean;
  51545. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51546. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51547. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51548. AOSTOREINMETALMAPRED: boolean;
  51549. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51550. ENVIRONMENTBRDF: boolean;
  51551. ENVIRONMENTBRDF_RGBD: boolean;
  51552. NORMAL: boolean;
  51553. TANGENT: boolean;
  51554. BUMP: boolean;
  51555. BUMPDIRECTUV: number;
  51556. OBJECTSPACE_NORMALMAP: boolean;
  51557. PARALLAX: boolean;
  51558. PARALLAXOCCLUSION: boolean;
  51559. NORMALXYSCALE: boolean;
  51560. LIGHTMAP: boolean;
  51561. LIGHTMAPDIRECTUV: number;
  51562. USELIGHTMAPASSHADOWMAP: boolean;
  51563. GAMMALIGHTMAP: boolean;
  51564. RGBDLIGHTMAP: boolean;
  51565. REFLECTION: boolean;
  51566. REFLECTIONMAP_3D: boolean;
  51567. REFLECTIONMAP_SPHERICAL: boolean;
  51568. REFLECTIONMAP_PLANAR: boolean;
  51569. REFLECTIONMAP_CUBIC: boolean;
  51570. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51571. REFLECTIONMAP_PROJECTION: boolean;
  51572. REFLECTIONMAP_SKYBOX: boolean;
  51573. REFLECTIONMAP_EXPLICIT: boolean;
  51574. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51575. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51576. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51577. INVERTCUBICMAP: boolean;
  51578. USESPHERICALFROMREFLECTIONMAP: boolean;
  51579. USEIRRADIANCEMAP: boolean;
  51580. SPHERICAL_HARMONICS: boolean;
  51581. USESPHERICALINVERTEX: boolean;
  51582. REFLECTIONMAP_OPPOSITEZ: boolean;
  51583. LODINREFLECTIONALPHA: boolean;
  51584. GAMMAREFLECTION: boolean;
  51585. RGBDREFLECTION: boolean;
  51586. LINEARSPECULARREFLECTION: boolean;
  51587. RADIANCEOCCLUSION: boolean;
  51588. HORIZONOCCLUSION: boolean;
  51589. INSTANCES: boolean;
  51590. NUM_BONE_INFLUENCERS: number;
  51591. BonesPerMesh: number;
  51592. BONETEXTURE: boolean;
  51593. NONUNIFORMSCALING: boolean;
  51594. MORPHTARGETS: boolean;
  51595. MORPHTARGETS_NORMAL: boolean;
  51596. MORPHTARGETS_TANGENT: boolean;
  51597. MORPHTARGETS_UV: boolean;
  51598. NUM_MORPH_INFLUENCERS: number;
  51599. IMAGEPROCESSING: boolean;
  51600. VIGNETTE: boolean;
  51601. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51602. VIGNETTEBLENDMODEOPAQUE: boolean;
  51603. TONEMAPPING: boolean;
  51604. TONEMAPPING_ACES: boolean;
  51605. CONTRAST: boolean;
  51606. COLORCURVES: boolean;
  51607. COLORGRADING: boolean;
  51608. COLORGRADING3D: boolean;
  51609. SAMPLER3DGREENDEPTH: boolean;
  51610. SAMPLER3DBGRMAP: boolean;
  51611. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51612. EXPOSURE: boolean;
  51613. MULTIVIEW: boolean;
  51614. USEPHYSICALLIGHTFALLOFF: boolean;
  51615. USEGLTFLIGHTFALLOFF: boolean;
  51616. TWOSIDEDLIGHTING: boolean;
  51617. SHADOWFLOAT: boolean;
  51618. CLIPPLANE: boolean;
  51619. CLIPPLANE2: boolean;
  51620. CLIPPLANE3: boolean;
  51621. CLIPPLANE4: boolean;
  51622. CLIPPLANE5: boolean;
  51623. CLIPPLANE6: boolean;
  51624. POINTSIZE: boolean;
  51625. FOG: boolean;
  51626. LOGARITHMICDEPTH: boolean;
  51627. FORCENORMALFORWARD: boolean;
  51628. SPECULARAA: boolean;
  51629. CLEARCOAT: boolean;
  51630. CLEARCOAT_DEFAULTIOR: boolean;
  51631. CLEARCOAT_TEXTURE: boolean;
  51632. CLEARCOAT_TEXTUREDIRECTUV: number;
  51633. CLEARCOAT_BUMP: boolean;
  51634. CLEARCOAT_BUMPDIRECTUV: number;
  51635. CLEARCOAT_TINT: boolean;
  51636. CLEARCOAT_TINT_TEXTURE: boolean;
  51637. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51638. ANISOTROPIC: boolean;
  51639. ANISOTROPIC_TEXTURE: boolean;
  51640. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51641. BRDF_V_HEIGHT_CORRELATED: boolean;
  51642. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51643. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51644. SHEEN: boolean;
  51645. SHEEN_TEXTURE: boolean;
  51646. SHEEN_TEXTUREDIRECTUV: number;
  51647. SHEEN_LINKWITHALBEDO: boolean;
  51648. SHEEN_ROUGHNESS: boolean;
  51649. SHEEN_ALBEDOSCALING: boolean;
  51650. SUBSURFACE: boolean;
  51651. SS_REFRACTION: boolean;
  51652. SS_TRANSLUCENCY: boolean;
  51653. SS_SCATERRING: boolean;
  51654. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51655. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51656. SS_REFRACTIONMAP_3D: boolean;
  51657. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51658. SS_LODINREFRACTIONALPHA: boolean;
  51659. SS_GAMMAREFRACTION: boolean;
  51660. SS_RGBDREFRACTION: boolean;
  51661. SS_LINEARSPECULARREFRACTION: boolean;
  51662. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51663. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51664. UNLIT: boolean;
  51665. DEBUGMODE: number;
  51666. /**
  51667. * Initializes the PBR Material defines.
  51668. */
  51669. constructor();
  51670. /**
  51671. * Resets the PBR Material defines.
  51672. */
  51673. reset(): void;
  51674. }
  51675. /**
  51676. * The Physically based material base class of BJS.
  51677. *
  51678. * This offers the main features of a standard PBR material.
  51679. * For more information, please refer to the documentation :
  51680. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51681. */
  51682. export abstract class PBRBaseMaterial extends PushMaterial {
  51683. /**
  51684. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51685. */
  51686. static readonly PBRMATERIAL_OPAQUE: number;
  51687. /**
  51688. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51689. */
  51690. static readonly PBRMATERIAL_ALPHATEST: number;
  51691. /**
  51692. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51693. */
  51694. static readonly PBRMATERIAL_ALPHABLEND: number;
  51695. /**
  51696. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51697. * They are also discarded below the alpha cutoff threshold to improve performances.
  51698. */
  51699. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51700. /**
  51701. * Defines the default value of how much AO map is occluding the analytical lights
  51702. * (point spot...).
  51703. */
  51704. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51705. /**
  51706. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51707. */
  51708. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51709. /**
  51710. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51711. * to enhance interoperability with other engines.
  51712. */
  51713. static readonly LIGHTFALLOFF_GLTF: number;
  51714. /**
  51715. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51716. * to enhance interoperability with other materials.
  51717. */
  51718. static readonly LIGHTFALLOFF_STANDARD: number;
  51719. /**
  51720. * Intensity of the direct lights e.g. the four lights available in your scene.
  51721. * This impacts both the direct diffuse and specular highlights.
  51722. */
  51723. protected _directIntensity: number;
  51724. /**
  51725. * Intensity of the emissive part of the material.
  51726. * This helps controlling the emissive effect without modifying the emissive color.
  51727. */
  51728. protected _emissiveIntensity: number;
  51729. /**
  51730. * Intensity of the environment e.g. how much the environment will light the object
  51731. * either through harmonics for rough material or through the refelction for shiny ones.
  51732. */
  51733. protected _environmentIntensity: number;
  51734. /**
  51735. * This is a special control allowing the reduction of the specular highlights coming from the
  51736. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51737. */
  51738. protected _specularIntensity: number;
  51739. /**
  51740. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51741. */
  51742. private _lightingInfos;
  51743. /**
  51744. * Debug Control allowing disabling the bump map on this material.
  51745. */
  51746. protected _disableBumpMap: boolean;
  51747. /**
  51748. * AKA Diffuse Texture in standard nomenclature.
  51749. */
  51750. protected _albedoTexture: Nullable<BaseTexture>;
  51751. /**
  51752. * AKA Occlusion Texture in other nomenclature.
  51753. */
  51754. protected _ambientTexture: Nullable<BaseTexture>;
  51755. /**
  51756. * AKA Occlusion Texture Intensity in other nomenclature.
  51757. */
  51758. protected _ambientTextureStrength: number;
  51759. /**
  51760. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51761. * 1 means it completely occludes it
  51762. * 0 mean it has no impact
  51763. */
  51764. protected _ambientTextureImpactOnAnalyticalLights: number;
  51765. /**
  51766. * Stores the alpha values in a texture.
  51767. */
  51768. protected _opacityTexture: Nullable<BaseTexture>;
  51769. /**
  51770. * Stores the reflection values in a texture.
  51771. */
  51772. protected _reflectionTexture: Nullable<BaseTexture>;
  51773. /**
  51774. * Stores the emissive values in a texture.
  51775. */
  51776. protected _emissiveTexture: Nullable<BaseTexture>;
  51777. /**
  51778. * AKA Specular texture in other nomenclature.
  51779. */
  51780. protected _reflectivityTexture: Nullable<BaseTexture>;
  51781. /**
  51782. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51783. */
  51784. protected _metallicTexture: Nullable<BaseTexture>;
  51785. /**
  51786. * Specifies the metallic scalar of the metallic/roughness workflow.
  51787. * Can also be used to scale the metalness values of the metallic texture.
  51788. */
  51789. protected _metallic: Nullable<number>;
  51790. /**
  51791. * Specifies the roughness scalar of the metallic/roughness workflow.
  51792. * Can also be used to scale the roughness values of the metallic texture.
  51793. */
  51794. protected _roughness: Nullable<number>;
  51795. /**
  51796. * Specifies the an F0 factor to help configuring the material F0.
  51797. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51798. * to 0.5 the previously hard coded value stays the same.
  51799. * Can also be used to scale the F0 values of the metallic texture.
  51800. */
  51801. protected _metallicF0Factor: number;
  51802. /**
  51803. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51804. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51805. * your expectation as it multiplies with the texture data.
  51806. */
  51807. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51808. /**
  51809. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51810. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51811. */
  51812. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51813. /**
  51814. * Stores surface normal data used to displace a mesh in a texture.
  51815. */
  51816. protected _bumpTexture: Nullable<BaseTexture>;
  51817. /**
  51818. * Stores the pre-calculated light information of a mesh in a texture.
  51819. */
  51820. protected _lightmapTexture: Nullable<BaseTexture>;
  51821. /**
  51822. * The color of a material in ambient lighting.
  51823. */
  51824. protected _ambientColor: Color3;
  51825. /**
  51826. * AKA Diffuse Color in other nomenclature.
  51827. */
  51828. protected _albedoColor: Color3;
  51829. /**
  51830. * AKA Specular Color in other nomenclature.
  51831. */
  51832. protected _reflectivityColor: Color3;
  51833. /**
  51834. * The color applied when light is reflected from a material.
  51835. */
  51836. protected _reflectionColor: Color3;
  51837. /**
  51838. * The color applied when light is emitted from a material.
  51839. */
  51840. protected _emissiveColor: Color3;
  51841. /**
  51842. * AKA Glossiness in other nomenclature.
  51843. */
  51844. protected _microSurface: number;
  51845. /**
  51846. * Specifies that the material will use the light map as a show map.
  51847. */
  51848. protected _useLightmapAsShadowmap: boolean;
  51849. /**
  51850. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51851. * makes the reflect vector face the model (under horizon).
  51852. */
  51853. protected _useHorizonOcclusion: boolean;
  51854. /**
  51855. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51856. * too much the area relying on ambient texture to define their ambient occlusion.
  51857. */
  51858. protected _useRadianceOcclusion: boolean;
  51859. /**
  51860. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51861. */
  51862. protected _useAlphaFromAlbedoTexture: boolean;
  51863. /**
  51864. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51865. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51866. */
  51867. protected _useSpecularOverAlpha: boolean;
  51868. /**
  51869. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51870. */
  51871. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51872. /**
  51873. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51874. */
  51875. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51876. /**
  51877. * Specifies if the metallic texture contains the roughness information in its green channel.
  51878. */
  51879. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51880. /**
  51881. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51882. */
  51883. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51884. /**
  51885. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51886. */
  51887. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51888. /**
  51889. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51890. */
  51891. protected _useAmbientInGrayScale: boolean;
  51892. /**
  51893. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51894. * The material will try to infer what glossiness each pixel should be.
  51895. */
  51896. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51897. /**
  51898. * Defines the falloff type used in this material.
  51899. * It by default is Physical.
  51900. */
  51901. protected _lightFalloff: number;
  51902. /**
  51903. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51904. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51905. */
  51906. protected _useRadianceOverAlpha: boolean;
  51907. /**
  51908. * Allows using an object space normal map (instead of tangent space).
  51909. */
  51910. protected _useObjectSpaceNormalMap: boolean;
  51911. /**
  51912. * Allows using the bump map in parallax mode.
  51913. */
  51914. protected _useParallax: boolean;
  51915. /**
  51916. * Allows using the bump map in parallax occlusion mode.
  51917. */
  51918. protected _useParallaxOcclusion: boolean;
  51919. /**
  51920. * Controls the scale bias of the parallax mode.
  51921. */
  51922. protected _parallaxScaleBias: number;
  51923. /**
  51924. * If sets to true, disables all the lights affecting the material.
  51925. */
  51926. protected _disableLighting: boolean;
  51927. /**
  51928. * Number of Simultaneous lights allowed on the material.
  51929. */
  51930. protected _maxSimultaneousLights: number;
  51931. /**
  51932. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51933. */
  51934. protected _invertNormalMapX: boolean;
  51935. /**
  51936. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51937. */
  51938. protected _invertNormalMapY: boolean;
  51939. /**
  51940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51941. */
  51942. protected _twoSidedLighting: boolean;
  51943. /**
  51944. * Defines the alpha limits in alpha test mode.
  51945. */
  51946. protected _alphaCutOff: number;
  51947. /**
  51948. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51949. */
  51950. protected _forceAlphaTest: boolean;
  51951. /**
  51952. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51953. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51954. */
  51955. protected _useAlphaFresnel: boolean;
  51956. /**
  51957. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51958. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51959. */
  51960. protected _useLinearAlphaFresnel: boolean;
  51961. /**
  51962. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51963. * from cos thetav and roughness:
  51964. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51965. */
  51966. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51967. /**
  51968. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51969. */
  51970. protected _forceIrradianceInFragment: boolean;
  51971. /**
  51972. * Force normal to face away from face.
  51973. */
  51974. protected _forceNormalForward: boolean;
  51975. /**
  51976. * Enables specular anti aliasing in the PBR shader.
  51977. * It will both interacts on the Geometry for analytical and IBL lighting.
  51978. * It also prefilter the roughness map based on the bump values.
  51979. */
  51980. protected _enableSpecularAntiAliasing: boolean;
  51981. /**
  51982. * Default configuration related to image processing available in the PBR Material.
  51983. */
  51984. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51985. /**
  51986. * Keep track of the image processing observer to allow dispose and replace.
  51987. */
  51988. private _imageProcessingObserver;
  51989. /**
  51990. * Attaches a new image processing configuration to the PBR Material.
  51991. * @param configuration
  51992. */
  51993. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51994. /**
  51995. * Stores the available render targets.
  51996. */
  51997. private _renderTargets;
  51998. /**
  51999. * Sets the global ambient color for the material used in lighting calculations.
  52000. */
  52001. private _globalAmbientColor;
  52002. /**
  52003. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52004. */
  52005. private _useLogarithmicDepth;
  52006. /**
  52007. * If set to true, no lighting calculations will be applied.
  52008. */
  52009. private _unlit;
  52010. private _debugMode;
  52011. /**
  52012. * @hidden
  52013. * This is reserved for the inspector.
  52014. * Defines the material debug mode.
  52015. * It helps seeing only some components of the material while troubleshooting.
  52016. */
  52017. debugMode: number;
  52018. /**
  52019. * @hidden
  52020. * This is reserved for the inspector.
  52021. * Specify from where on screen the debug mode should start.
  52022. * The value goes from -1 (full screen) to 1 (not visible)
  52023. * It helps with side by side comparison against the final render
  52024. * This defaults to -1
  52025. */
  52026. private debugLimit;
  52027. /**
  52028. * @hidden
  52029. * This is reserved for the inspector.
  52030. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52031. * You can use the factor to better multiply the final value.
  52032. */
  52033. private debugFactor;
  52034. /**
  52035. * Defines the clear coat layer parameters for the material.
  52036. */
  52037. readonly clearCoat: PBRClearCoatConfiguration;
  52038. /**
  52039. * Defines the anisotropic parameters for the material.
  52040. */
  52041. readonly anisotropy: PBRAnisotropicConfiguration;
  52042. /**
  52043. * Defines the BRDF parameters for the material.
  52044. */
  52045. readonly brdf: PBRBRDFConfiguration;
  52046. /**
  52047. * Defines the Sheen parameters for the material.
  52048. */
  52049. readonly sheen: PBRSheenConfiguration;
  52050. /**
  52051. * Defines the SubSurface parameters for the material.
  52052. */
  52053. readonly subSurface: PBRSubSurfaceConfiguration;
  52054. protected _rebuildInParallel: boolean;
  52055. /**
  52056. * Instantiates a new PBRMaterial instance.
  52057. *
  52058. * @param name The material name
  52059. * @param scene The scene the material will be use in.
  52060. */
  52061. constructor(name: string, scene: Scene);
  52062. /**
  52063. * Gets a boolean indicating that current material needs to register RTT
  52064. */
  52065. get hasRenderTargetTextures(): boolean;
  52066. /**
  52067. * Gets the name of the material class.
  52068. */
  52069. getClassName(): string;
  52070. /**
  52071. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52072. */
  52073. get useLogarithmicDepth(): boolean;
  52074. /**
  52075. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52076. */
  52077. set useLogarithmicDepth(value: boolean);
  52078. /**
  52079. * Returns true if alpha blending should be disabled.
  52080. */
  52081. protected get _disableAlphaBlending(): boolean;
  52082. /**
  52083. * Specifies whether or not this material should be rendered in alpha blend mode.
  52084. */
  52085. needAlphaBlending(): boolean;
  52086. /**
  52087. * Specifies whether or not this material should be rendered in alpha test mode.
  52088. */
  52089. needAlphaTesting(): boolean;
  52090. /**
  52091. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52092. */
  52093. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52094. /**
  52095. * Gets the texture used for the alpha test.
  52096. */
  52097. getAlphaTestTexture(): Nullable<BaseTexture>;
  52098. /**
  52099. * Specifies that the submesh is ready to be used.
  52100. * @param mesh - BJS mesh.
  52101. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52102. * @param useInstances - Specifies that instances should be used.
  52103. * @returns - boolean indicating that the submesh is ready or not.
  52104. */
  52105. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52106. /**
  52107. * Specifies if the material uses metallic roughness workflow.
  52108. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52109. */
  52110. isMetallicWorkflow(): boolean;
  52111. private _prepareEffect;
  52112. private _prepareDefines;
  52113. /**
  52114. * Force shader compilation
  52115. */
  52116. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52117. /**
  52118. * Initializes the uniform buffer layout for the shader.
  52119. */
  52120. buildUniformLayout(): void;
  52121. /**
  52122. * Unbinds the material from the mesh
  52123. */
  52124. unbind(): void;
  52125. /**
  52126. * Binds the submesh data.
  52127. * @param world - The world matrix.
  52128. * @param mesh - The BJS mesh.
  52129. * @param subMesh - A submesh of the BJS mesh.
  52130. */
  52131. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52132. /**
  52133. * Returns the animatable textures.
  52134. * @returns - Array of animatable textures.
  52135. */
  52136. getAnimatables(): IAnimatable[];
  52137. /**
  52138. * Returns the texture used for reflections.
  52139. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52140. */
  52141. private _getReflectionTexture;
  52142. /**
  52143. * Returns an array of the actively used textures.
  52144. * @returns - Array of BaseTextures
  52145. */
  52146. getActiveTextures(): BaseTexture[];
  52147. /**
  52148. * Checks to see if a texture is used in the material.
  52149. * @param texture - Base texture to use.
  52150. * @returns - Boolean specifying if a texture is used in the material.
  52151. */
  52152. hasTexture(texture: BaseTexture): boolean;
  52153. /**
  52154. * Disposes the resources of the material.
  52155. * @param forceDisposeEffect - Forces the disposal of effects.
  52156. * @param forceDisposeTextures - Forces the disposal of all textures.
  52157. */
  52158. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52159. }
  52160. }
  52161. declare module BABYLON {
  52162. /**
  52163. * The Physically based material of BJS.
  52164. *
  52165. * This offers the main features of a standard PBR material.
  52166. * For more information, please refer to the documentation :
  52167. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52168. */
  52169. export class PBRMaterial extends PBRBaseMaterial {
  52170. /**
  52171. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52172. */
  52173. static readonly PBRMATERIAL_OPAQUE: number;
  52174. /**
  52175. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52176. */
  52177. static readonly PBRMATERIAL_ALPHATEST: number;
  52178. /**
  52179. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52180. */
  52181. static readonly PBRMATERIAL_ALPHABLEND: number;
  52182. /**
  52183. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52184. * They are also discarded below the alpha cutoff threshold to improve performances.
  52185. */
  52186. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52187. /**
  52188. * Defines the default value of how much AO map is occluding the analytical lights
  52189. * (point spot...).
  52190. */
  52191. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52192. /**
  52193. * Intensity of the direct lights e.g. the four lights available in your scene.
  52194. * This impacts both the direct diffuse and specular highlights.
  52195. */
  52196. directIntensity: number;
  52197. /**
  52198. * Intensity of the emissive part of the material.
  52199. * This helps controlling the emissive effect without modifying the emissive color.
  52200. */
  52201. emissiveIntensity: number;
  52202. /**
  52203. * Intensity of the environment e.g. how much the environment will light the object
  52204. * either through harmonics for rough material or through the refelction for shiny ones.
  52205. */
  52206. environmentIntensity: number;
  52207. /**
  52208. * This is a special control allowing the reduction of the specular highlights coming from the
  52209. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52210. */
  52211. specularIntensity: number;
  52212. /**
  52213. * Debug Control allowing disabling the bump map on this material.
  52214. */
  52215. disableBumpMap: boolean;
  52216. /**
  52217. * AKA Diffuse Texture in standard nomenclature.
  52218. */
  52219. albedoTexture: BaseTexture;
  52220. /**
  52221. * AKA Occlusion Texture in other nomenclature.
  52222. */
  52223. ambientTexture: BaseTexture;
  52224. /**
  52225. * AKA Occlusion Texture Intensity in other nomenclature.
  52226. */
  52227. ambientTextureStrength: number;
  52228. /**
  52229. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52230. * 1 means it completely occludes it
  52231. * 0 mean it has no impact
  52232. */
  52233. ambientTextureImpactOnAnalyticalLights: number;
  52234. /**
  52235. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52236. */
  52237. opacityTexture: BaseTexture;
  52238. /**
  52239. * Stores the reflection values in a texture.
  52240. */
  52241. reflectionTexture: Nullable<BaseTexture>;
  52242. /**
  52243. * Stores the emissive values in a texture.
  52244. */
  52245. emissiveTexture: BaseTexture;
  52246. /**
  52247. * AKA Specular texture in other nomenclature.
  52248. */
  52249. reflectivityTexture: BaseTexture;
  52250. /**
  52251. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52252. */
  52253. metallicTexture: BaseTexture;
  52254. /**
  52255. * Specifies the metallic scalar of the metallic/roughness workflow.
  52256. * Can also be used to scale the metalness values of the metallic texture.
  52257. */
  52258. metallic: Nullable<number>;
  52259. /**
  52260. * Specifies the roughness scalar of the metallic/roughness workflow.
  52261. * Can also be used to scale the roughness values of the metallic texture.
  52262. */
  52263. roughness: Nullable<number>;
  52264. /**
  52265. * Specifies the an F0 factor to help configuring the material F0.
  52266. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52267. * to 0.5 the previously hard coded value stays the same.
  52268. * Can also be used to scale the F0 values of the metallic texture.
  52269. */
  52270. metallicF0Factor: number;
  52271. /**
  52272. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52273. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52274. * your expectation as it multiplies with the texture data.
  52275. */
  52276. useMetallicF0FactorFromMetallicTexture: boolean;
  52277. /**
  52278. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52279. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52280. */
  52281. microSurfaceTexture: BaseTexture;
  52282. /**
  52283. * Stores surface normal data used to displace a mesh in a texture.
  52284. */
  52285. bumpTexture: BaseTexture;
  52286. /**
  52287. * Stores the pre-calculated light information of a mesh in a texture.
  52288. */
  52289. lightmapTexture: BaseTexture;
  52290. /**
  52291. * Stores the refracted light information in a texture.
  52292. */
  52293. get refractionTexture(): Nullable<BaseTexture>;
  52294. set refractionTexture(value: Nullable<BaseTexture>);
  52295. /**
  52296. * The color of a material in ambient lighting.
  52297. */
  52298. ambientColor: Color3;
  52299. /**
  52300. * AKA Diffuse Color in other nomenclature.
  52301. */
  52302. albedoColor: Color3;
  52303. /**
  52304. * AKA Specular Color in other nomenclature.
  52305. */
  52306. reflectivityColor: Color3;
  52307. /**
  52308. * The color reflected from the material.
  52309. */
  52310. reflectionColor: Color3;
  52311. /**
  52312. * The color emitted from the material.
  52313. */
  52314. emissiveColor: Color3;
  52315. /**
  52316. * AKA Glossiness in other nomenclature.
  52317. */
  52318. microSurface: number;
  52319. /**
  52320. * source material index of refraction (IOR)' / 'destination material IOR.
  52321. */
  52322. get indexOfRefraction(): number;
  52323. set indexOfRefraction(value: number);
  52324. /**
  52325. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52326. */
  52327. get invertRefractionY(): boolean;
  52328. set invertRefractionY(value: boolean);
  52329. /**
  52330. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52331. * Materials half opaque for instance using refraction could benefit from this control.
  52332. */
  52333. get linkRefractionWithTransparency(): boolean;
  52334. set linkRefractionWithTransparency(value: boolean);
  52335. /**
  52336. * If true, the light map contains occlusion information instead of lighting info.
  52337. */
  52338. useLightmapAsShadowmap: boolean;
  52339. /**
  52340. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52341. */
  52342. useAlphaFromAlbedoTexture: boolean;
  52343. /**
  52344. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52345. */
  52346. forceAlphaTest: boolean;
  52347. /**
  52348. * Defines the alpha limits in alpha test mode.
  52349. */
  52350. alphaCutOff: number;
  52351. /**
  52352. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52353. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52354. */
  52355. useSpecularOverAlpha: boolean;
  52356. /**
  52357. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52358. */
  52359. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52360. /**
  52361. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52362. */
  52363. useRoughnessFromMetallicTextureAlpha: boolean;
  52364. /**
  52365. * Specifies if the metallic texture contains the roughness information in its green channel.
  52366. */
  52367. useRoughnessFromMetallicTextureGreen: boolean;
  52368. /**
  52369. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52370. */
  52371. useMetallnessFromMetallicTextureBlue: boolean;
  52372. /**
  52373. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52374. */
  52375. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52376. /**
  52377. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52378. */
  52379. useAmbientInGrayScale: boolean;
  52380. /**
  52381. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52382. * The material will try to infer what glossiness each pixel should be.
  52383. */
  52384. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52385. /**
  52386. * BJS is using an harcoded light falloff based on a manually sets up range.
  52387. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52388. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52389. */
  52390. get usePhysicalLightFalloff(): boolean;
  52391. /**
  52392. * BJS is using an harcoded light falloff based on a manually sets up range.
  52393. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52394. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52395. */
  52396. set usePhysicalLightFalloff(value: boolean);
  52397. /**
  52398. * In order to support the falloff compatibility with gltf, a special mode has been added
  52399. * to reproduce the gltf light falloff.
  52400. */
  52401. get useGLTFLightFalloff(): boolean;
  52402. /**
  52403. * In order to support the falloff compatibility with gltf, a special mode has been added
  52404. * to reproduce the gltf light falloff.
  52405. */
  52406. set useGLTFLightFalloff(value: boolean);
  52407. /**
  52408. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52409. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52410. */
  52411. useRadianceOverAlpha: boolean;
  52412. /**
  52413. * Allows using an object space normal map (instead of tangent space).
  52414. */
  52415. useObjectSpaceNormalMap: boolean;
  52416. /**
  52417. * Allows using the bump map in parallax mode.
  52418. */
  52419. useParallax: boolean;
  52420. /**
  52421. * Allows using the bump map in parallax occlusion mode.
  52422. */
  52423. useParallaxOcclusion: boolean;
  52424. /**
  52425. * Controls the scale bias of the parallax mode.
  52426. */
  52427. parallaxScaleBias: number;
  52428. /**
  52429. * If sets to true, disables all the lights affecting the material.
  52430. */
  52431. disableLighting: boolean;
  52432. /**
  52433. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52434. */
  52435. forceIrradianceInFragment: boolean;
  52436. /**
  52437. * Number of Simultaneous lights allowed on the material.
  52438. */
  52439. maxSimultaneousLights: number;
  52440. /**
  52441. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52442. */
  52443. invertNormalMapX: boolean;
  52444. /**
  52445. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52446. */
  52447. invertNormalMapY: boolean;
  52448. /**
  52449. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52450. */
  52451. twoSidedLighting: boolean;
  52452. /**
  52453. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52454. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52455. */
  52456. useAlphaFresnel: boolean;
  52457. /**
  52458. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52459. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52460. */
  52461. useLinearAlphaFresnel: boolean;
  52462. /**
  52463. * Let user defines the brdf lookup texture used for IBL.
  52464. * A default 8bit version is embedded but you could point at :
  52465. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52466. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52467. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52468. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52469. */
  52470. environmentBRDFTexture: Nullable<BaseTexture>;
  52471. /**
  52472. * Force normal to face away from face.
  52473. */
  52474. forceNormalForward: boolean;
  52475. /**
  52476. * Enables specular anti aliasing in the PBR shader.
  52477. * It will both interacts on the Geometry for analytical and IBL lighting.
  52478. * It also prefilter the roughness map based on the bump values.
  52479. */
  52480. enableSpecularAntiAliasing: boolean;
  52481. /**
  52482. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52483. * makes the reflect vector face the model (under horizon).
  52484. */
  52485. useHorizonOcclusion: boolean;
  52486. /**
  52487. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52488. * too much the area relying on ambient texture to define their ambient occlusion.
  52489. */
  52490. useRadianceOcclusion: boolean;
  52491. /**
  52492. * If set to true, no lighting calculations will be applied.
  52493. */
  52494. unlit: boolean;
  52495. /**
  52496. * Gets the image processing configuration used either in this material.
  52497. */
  52498. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52499. /**
  52500. * Sets the Default image processing configuration used either in the this material.
  52501. *
  52502. * If sets to null, the scene one is in use.
  52503. */
  52504. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52505. /**
  52506. * Gets wether the color curves effect is enabled.
  52507. */
  52508. get cameraColorCurvesEnabled(): boolean;
  52509. /**
  52510. * Sets wether the color curves effect is enabled.
  52511. */
  52512. set cameraColorCurvesEnabled(value: boolean);
  52513. /**
  52514. * Gets wether the color grading effect is enabled.
  52515. */
  52516. get cameraColorGradingEnabled(): boolean;
  52517. /**
  52518. * Gets wether the color grading effect is enabled.
  52519. */
  52520. set cameraColorGradingEnabled(value: boolean);
  52521. /**
  52522. * Gets wether tonemapping is enabled or not.
  52523. */
  52524. get cameraToneMappingEnabled(): boolean;
  52525. /**
  52526. * Sets wether tonemapping is enabled or not
  52527. */
  52528. set cameraToneMappingEnabled(value: boolean);
  52529. /**
  52530. * The camera exposure used on this material.
  52531. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52532. * This corresponds to a photographic exposure.
  52533. */
  52534. get cameraExposure(): number;
  52535. /**
  52536. * The camera exposure used on this material.
  52537. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52538. * This corresponds to a photographic exposure.
  52539. */
  52540. set cameraExposure(value: number);
  52541. /**
  52542. * Gets The camera contrast used on this material.
  52543. */
  52544. get cameraContrast(): number;
  52545. /**
  52546. * Sets The camera contrast used on this material.
  52547. */
  52548. set cameraContrast(value: number);
  52549. /**
  52550. * Gets the Color Grading 2D Lookup Texture.
  52551. */
  52552. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52553. /**
  52554. * Sets the Color Grading 2D Lookup Texture.
  52555. */
  52556. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52557. /**
  52558. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52559. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52560. * 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;
  52561. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52562. */
  52563. get cameraColorCurves(): Nullable<ColorCurves>;
  52564. /**
  52565. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52566. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52567. * 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;
  52568. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52569. */
  52570. set cameraColorCurves(value: Nullable<ColorCurves>);
  52571. /**
  52572. * Instantiates a new PBRMaterial instance.
  52573. *
  52574. * @param name The material name
  52575. * @param scene The scene the material will be use in.
  52576. */
  52577. constructor(name: string, scene: Scene);
  52578. /**
  52579. * Returns the name of this material class.
  52580. */
  52581. getClassName(): string;
  52582. /**
  52583. * Makes a duplicate of the current material.
  52584. * @param name - name to use for the new material.
  52585. */
  52586. clone(name: string): PBRMaterial;
  52587. /**
  52588. * Serializes this PBR Material.
  52589. * @returns - An object with the serialized material.
  52590. */
  52591. serialize(): any;
  52592. /**
  52593. * Parses a PBR Material from a serialized object.
  52594. * @param source - Serialized object.
  52595. * @param scene - BJS scene instance.
  52596. * @param rootUrl - url for the scene object
  52597. * @returns - PBRMaterial
  52598. */
  52599. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52600. }
  52601. }
  52602. declare module BABYLON {
  52603. /**
  52604. * Direct draw surface info
  52605. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52606. */
  52607. export interface DDSInfo {
  52608. /**
  52609. * Width of the texture
  52610. */
  52611. width: number;
  52612. /**
  52613. * Width of the texture
  52614. */
  52615. height: number;
  52616. /**
  52617. * Number of Mipmaps for the texture
  52618. * @see https://en.wikipedia.org/wiki/Mipmap
  52619. */
  52620. mipmapCount: number;
  52621. /**
  52622. * If the textures format is a known fourCC format
  52623. * @see https://www.fourcc.org/
  52624. */
  52625. isFourCC: boolean;
  52626. /**
  52627. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52628. */
  52629. isRGB: boolean;
  52630. /**
  52631. * If the texture is a lumincance format
  52632. */
  52633. isLuminance: boolean;
  52634. /**
  52635. * If this is a cube texture
  52636. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52637. */
  52638. isCube: boolean;
  52639. /**
  52640. * If the texture is a compressed format eg. FOURCC_DXT1
  52641. */
  52642. isCompressed: boolean;
  52643. /**
  52644. * The dxgiFormat of the texture
  52645. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52646. */
  52647. dxgiFormat: number;
  52648. /**
  52649. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52650. */
  52651. textureType: number;
  52652. /**
  52653. * Sphericle polynomial created for the dds texture
  52654. */
  52655. sphericalPolynomial?: SphericalPolynomial;
  52656. }
  52657. /**
  52658. * Class used to provide DDS decompression tools
  52659. */
  52660. export class DDSTools {
  52661. /**
  52662. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52663. */
  52664. static StoreLODInAlphaChannel: boolean;
  52665. /**
  52666. * Gets DDS information from an array buffer
  52667. * @param data defines the array buffer view to read data from
  52668. * @returns the DDS information
  52669. */
  52670. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52671. private static _FloatView;
  52672. private static _Int32View;
  52673. private static _ToHalfFloat;
  52674. private static _FromHalfFloat;
  52675. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52676. private static _GetHalfFloatRGBAArrayBuffer;
  52677. private static _GetFloatRGBAArrayBuffer;
  52678. private static _GetFloatAsUIntRGBAArrayBuffer;
  52679. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52680. private static _GetRGBAArrayBuffer;
  52681. private static _ExtractLongWordOrder;
  52682. private static _GetRGBArrayBuffer;
  52683. private static _GetLuminanceArrayBuffer;
  52684. /**
  52685. * Uploads DDS Levels to a Babylon Texture
  52686. * @hidden
  52687. */
  52688. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52689. }
  52690. interface ThinEngine {
  52691. /**
  52692. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52693. * @param rootUrl defines the url where the file to load is located
  52694. * @param scene defines the current scene
  52695. * @param lodScale defines scale to apply to the mip map selection
  52696. * @param lodOffset defines offset to apply to the mip map selection
  52697. * @param onLoad defines an optional callback raised when the texture is loaded
  52698. * @param onError defines an optional callback raised if there is an issue to load the texture
  52699. * @param format defines the format of the data
  52700. * @param forcedExtension defines the extension to use to pick the right loader
  52701. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52702. * @returns the cube texture as an InternalTexture
  52703. */
  52704. 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;
  52705. }
  52706. }
  52707. declare module BABYLON {
  52708. /**
  52709. * Implementation of the DDS Texture Loader.
  52710. * @hidden
  52711. */
  52712. export class _DDSTextureLoader implements IInternalTextureLoader {
  52713. /**
  52714. * Defines wether the loader supports cascade loading the different faces.
  52715. */
  52716. readonly supportCascades: boolean;
  52717. /**
  52718. * This returns if the loader support the current file information.
  52719. * @param extension defines the file extension of the file being loaded
  52720. * @returns true if the loader can load the specified file
  52721. */
  52722. canLoad(extension: string): boolean;
  52723. /**
  52724. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52725. * @param data contains the texture data
  52726. * @param texture defines the BabylonJS internal texture
  52727. * @param createPolynomials will be true if polynomials have been requested
  52728. * @param onLoad defines the callback to trigger once the texture is ready
  52729. * @param onError defines the callback to trigger in case of error
  52730. */
  52731. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52732. /**
  52733. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52734. * @param data contains the texture data
  52735. * @param texture defines the BabylonJS internal texture
  52736. * @param callback defines the method to call once ready to upload
  52737. */
  52738. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52739. }
  52740. }
  52741. declare module BABYLON {
  52742. /**
  52743. * Implementation of the ENV Texture Loader.
  52744. * @hidden
  52745. */
  52746. export class _ENVTextureLoader implements IInternalTextureLoader {
  52747. /**
  52748. * Defines wether the loader supports cascade loading the different faces.
  52749. */
  52750. readonly supportCascades: boolean;
  52751. /**
  52752. * This returns if the loader support the current file information.
  52753. * @param extension defines the file extension of the file being loaded
  52754. * @returns true if the loader can load the specified file
  52755. */
  52756. canLoad(extension: string): boolean;
  52757. /**
  52758. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52759. * @param data contains the texture data
  52760. * @param texture defines the BabylonJS internal texture
  52761. * @param createPolynomials will be true if polynomials have been requested
  52762. * @param onLoad defines the callback to trigger once the texture is ready
  52763. * @param onError defines the callback to trigger in case of error
  52764. */
  52765. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52766. /**
  52767. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52768. * @param data contains the texture data
  52769. * @param texture defines the BabylonJS internal texture
  52770. * @param callback defines the method to call once ready to upload
  52771. */
  52772. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52773. }
  52774. }
  52775. declare module BABYLON {
  52776. /**
  52777. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52778. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52779. */
  52780. export class KhronosTextureContainer {
  52781. /** contents of the KTX container file */
  52782. data: ArrayBufferView;
  52783. private static HEADER_LEN;
  52784. private static COMPRESSED_2D;
  52785. private static COMPRESSED_3D;
  52786. private static TEX_2D;
  52787. private static TEX_3D;
  52788. /**
  52789. * Gets the openGL type
  52790. */
  52791. glType: number;
  52792. /**
  52793. * Gets the openGL type size
  52794. */
  52795. glTypeSize: number;
  52796. /**
  52797. * Gets the openGL format
  52798. */
  52799. glFormat: number;
  52800. /**
  52801. * Gets the openGL internal format
  52802. */
  52803. glInternalFormat: number;
  52804. /**
  52805. * Gets the base internal format
  52806. */
  52807. glBaseInternalFormat: number;
  52808. /**
  52809. * Gets image width in pixel
  52810. */
  52811. pixelWidth: number;
  52812. /**
  52813. * Gets image height in pixel
  52814. */
  52815. pixelHeight: number;
  52816. /**
  52817. * Gets image depth in pixels
  52818. */
  52819. pixelDepth: number;
  52820. /**
  52821. * Gets the number of array elements
  52822. */
  52823. numberOfArrayElements: number;
  52824. /**
  52825. * Gets the number of faces
  52826. */
  52827. numberOfFaces: number;
  52828. /**
  52829. * Gets the number of mipmap levels
  52830. */
  52831. numberOfMipmapLevels: number;
  52832. /**
  52833. * Gets the bytes of key value data
  52834. */
  52835. bytesOfKeyValueData: number;
  52836. /**
  52837. * Gets the load type
  52838. */
  52839. loadType: number;
  52840. /**
  52841. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52842. */
  52843. isInvalid: boolean;
  52844. /**
  52845. * Creates a new KhronosTextureContainer
  52846. * @param data contents of the KTX container file
  52847. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52848. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52849. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52850. */
  52851. constructor(
  52852. /** contents of the KTX container file */
  52853. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52854. /**
  52855. * Uploads KTX content to a Babylon Texture.
  52856. * It is assumed that the texture has already been created & is currently bound
  52857. * @hidden
  52858. */
  52859. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52860. private _upload2DCompressedLevels;
  52861. /**
  52862. * Checks if the given data starts with a KTX file identifier.
  52863. * @param data the data to check
  52864. * @returns true if the data is a KTX file or false otherwise
  52865. */
  52866. static IsValid(data: ArrayBufferView): boolean;
  52867. }
  52868. }
  52869. declare module BABYLON {
  52870. /**
  52871. * Class for loading KTX2 files
  52872. * !!! Experimental Extension Subject to Changes !!!
  52873. * @hidden
  52874. */
  52875. export class KhronosTextureContainer2 {
  52876. private static _ModulePromise;
  52877. private static _TranscodeFormat;
  52878. constructor(engine: ThinEngine);
  52879. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52880. private _determineTranscodeFormat;
  52881. /**
  52882. * Checks if the given data starts with a KTX2 file identifier.
  52883. * @param data the data to check
  52884. * @returns true if the data is a KTX2 file or false otherwise
  52885. */
  52886. static IsValid(data: ArrayBufferView): boolean;
  52887. }
  52888. }
  52889. declare module BABYLON {
  52890. /**
  52891. * Implementation of the KTX Texture Loader.
  52892. * @hidden
  52893. */
  52894. export class _KTXTextureLoader implements IInternalTextureLoader {
  52895. /**
  52896. * Defines wether the loader supports cascade loading the different faces.
  52897. */
  52898. readonly supportCascades: boolean;
  52899. /**
  52900. * This returns if the loader support the current file information.
  52901. * @param extension defines the file extension of the file being loaded
  52902. * @returns true if the loader can load the specified file
  52903. */
  52904. canLoad(extension: string): boolean;
  52905. /**
  52906. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52907. * @param data contains the texture data
  52908. * @param texture defines the BabylonJS internal texture
  52909. * @param createPolynomials will be true if polynomials have been requested
  52910. * @param onLoad defines the callback to trigger once the texture is ready
  52911. * @param onError defines the callback to trigger in case of error
  52912. */
  52913. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52914. /**
  52915. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52916. * @param data contains the texture data
  52917. * @param texture defines the BabylonJS internal texture
  52918. * @param callback defines the method to call once ready to upload
  52919. */
  52920. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52921. }
  52922. }
  52923. declare module BABYLON {
  52924. /** @hidden */
  52925. export var _forceSceneHelpersToBundle: boolean;
  52926. interface Scene {
  52927. /**
  52928. * Creates a default light for the scene.
  52929. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52930. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52931. */
  52932. createDefaultLight(replace?: boolean): void;
  52933. /**
  52934. * Creates a default camera for the scene.
  52935. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52936. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52937. * @param replace has default false, when true replaces the active camera in the scene
  52938. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52939. */
  52940. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52941. /**
  52942. * Creates a default camera and a default light.
  52943. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52944. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52945. * @param replace has the default false, when true replaces the active camera/light in the scene
  52946. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52947. */
  52948. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52949. /**
  52950. * Creates a new sky box
  52951. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52952. * @param environmentTexture defines the texture to use as environment texture
  52953. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52954. * @param scale defines the overall scale of the skybox
  52955. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52956. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52957. * @returns a new mesh holding the sky box
  52958. */
  52959. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52960. /**
  52961. * Creates a new environment
  52962. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52963. * @param options defines the options you can use to configure the environment
  52964. * @returns the new EnvironmentHelper
  52965. */
  52966. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52967. /**
  52968. * Creates a new VREXperienceHelper
  52969. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52970. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52971. * @returns a new VREXperienceHelper
  52972. */
  52973. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52974. /**
  52975. * Creates a new WebXRDefaultExperience
  52976. * @see http://doc.babylonjs.com/how_to/webxr
  52977. * @param options experience options
  52978. * @returns a promise for a new WebXRDefaultExperience
  52979. */
  52980. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52981. }
  52982. }
  52983. declare module BABYLON {
  52984. /**
  52985. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52986. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52987. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52988. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52989. */
  52990. export class VideoDome extends TransformNode {
  52991. /**
  52992. * Define the video source as a Monoscopic panoramic 360 video.
  52993. */
  52994. static readonly MODE_MONOSCOPIC: number;
  52995. /**
  52996. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52997. */
  52998. static readonly MODE_TOPBOTTOM: number;
  52999. /**
  53000. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53001. */
  53002. static readonly MODE_SIDEBYSIDE: number;
  53003. private _halfDome;
  53004. private _useDirectMapping;
  53005. /**
  53006. * The video texture being displayed on the sphere
  53007. */
  53008. protected _videoTexture: VideoTexture;
  53009. /**
  53010. * Gets the video texture being displayed on the sphere
  53011. */
  53012. get videoTexture(): VideoTexture;
  53013. /**
  53014. * The skybox material
  53015. */
  53016. protected _material: BackgroundMaterial;
  53017. /**
  53018. * The surface used for the skybox
  53019. */
  53020. protected _mesh: Mesh;
  53021. /**
  53022. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53023. */
  53024. private _halfDomeMask;
  53025. /**
  53026. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53027. * Also see the options.resolution property.
  53028. */
  53029. get fovMultiplier(): number;
  53030. set fovMultiplier(value: number);
  53031. private _videoMode;
  53032. /**
  53033. * Gets or set the current video mode for the video. It can be:
  53034. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53035. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53036. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53037. */
  53038. get videoMode(): number;
  53039. set videoMode(value: number);
  53040. /**
  53041. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53042. *
  53043. */
  53044. get halfDome(): boolean;
  53045. /**
  53046. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53047. */
  53048. set halfDome(enabled: boolean);
  53049. /**
  53050. * Oberserver used in Stereoscopic VR Mode.
  53051. */
  53052. private _onBeforeCameraRenderObserver;
  53053. /**
  53054. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53055. * @param name Element's name, child elements will append suffixes for their own names.
  53056. * @param urlsOrVideo defines the url(s) or the video element to use
  53057. * @param options An object containing optional or exposed sub element properties
  53058. */
  53059. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53060. resolution?: number;
  53061. clickToPlay?: boolean;
  53062. autoPlay?: boolean;
  53063. loop?: boolean;
  53064. size?: number;
  53065. poster?: string;
  53066. faceForward?: boolean;
  53067. useDirectMapping?: boolean;
  53068. halfDomeMode?: boolean;
  53069. }, scene: Scene);
  53070. private _changeVideoMode;
  53071. /**
  53072. * Releases resources associated with this node.
  53073. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53074. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53075. */
  53076. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53077. }
  53078. }
  53079. declare module BABYLON {
  53080. /**
  53081. * This class can be used to get instrumentation data from a Babylon engine
  53082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53083. */
  53084. export class EngineInstrumentation implements IDisposable {
  53085. /**
  53086. * Define the instrumented engine.
  53087. */
  53088. engine: Engine;
  53089. private _captureGPUFrameTime;
  53090. private _gpuFrameTimeToken;
  53091. private _gpuFrameTime;
  53092. private _captureShaderCompilationTime;
  53093. private _shaderCompilationTime;
  53094. private _onBeginFrameObserver;
  53095. private _onEndFrameObserver;
  53096. private _onBeforeShaderCompilationObserver;
  53097. private _onAfterShaderCompilationObserver;
  53098. /**
  53099. * Gets the perf counter used for GPU frame time
  53100. */
  53101. get gpuFrameTimeCounter(): PerfCounter;
  53102. /**
  53103. * Gets the GPU frame time capture status
  53104. */
  53105. get captureGPUFrameTime(): boolean;
  53106. /**
  53107. * Enable or disable the GPU frame time capture
  53108. */
  53109. set captureGPUFrameTime(value: boolean);
  53110. /**
  53111. * Gets the perf counter used for shader compilation time
  53112. */
  53113. get shaderCompilationTimeCounter(): PerfCounter;
  53114. /**
  53115. * Gets the shader compilation time capture status
  53116. */
  53117. get captureShaderCompilationTime(): boolean;
  53118. /**
  53119. * Enable or disable the shader compilation time capture
  53120. */
  53121. set captureShaderCompilationTime(value: boolean);
  53122. /**
  53123. * Instantiates a new engine instrumentation.
  53124. * This class can be used to get instrumentation data from a Babylon engine
  53125. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53126. * @param engine Defines the engine to instrument
  53127. */
  53128. constructor(
  53129. /**
  53130. * Define the instrumented engine.
  53131. */
  53132. engine: Engine);
  53133. /**
  53134. * Dispose and release associated resources.
  53135. */
  53136. dispose(): void;
  53137. }
  53138. }
  53139. declare module BABYLON {
  53140. /**
  53141. * This class can be used to get instrumentation data from a Babylon engine
  53142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53143. */
  53144. export class SceneInstrumentation implements IDisposable {
  53145. /**
  53146. * Defines the scene to instrument
  53147. */
  53148. scene: Scene;
  53149. private _captureActiveMeshesEvaluationTime;
  53150. private _activeMeshesEvaluationTime;
  53151. private _captureRenderTargetsRenderTime;
  53152. private _renderTargetsRenderTime;
  53153. private _captureFrameTime;
  53154. private _frameTime;
  53155. private _captureRenderTime;
  53156. private _renderTime;
  53157. private _captureInterFrameTime;
  53158. private _interFrameTime;
  53159. private _captureParticlesRenderTime;
  53160. private _particlesRenderTime;
  53161. private _captureSpritesRenderTime;
  53162. private _spritesRenderTime;
  53163. private _capturePhysicsTime;
  53164. private _physicsTime;
  53165. private _captureAnimationsTime;
  53166. private _animationsTime;
  53167. private _captureCameraRenderTime;
  53168. private _cameraRenderTime;
  53169. private _onBeforeActiveMeshesEvaluationObserver;
  53170. private _onAfterActiveMeshesEvaluationObserver;
  53171. private _onBeforeRenderTargetsRenderObserver;
  53172. private _onAfterRenderTargetsRenderObserver;
  53173. private _onAfterRenderObserver;
  53174. private _onBeforeDrawPhaseObserver;
  53175. private _onAfterDrawPhaseObserver;
  53176. private _onBeforeAnimationsObserver;
  53177. private _onBeforeParticlesRenderingObserver;
  53178. private _onAfterParticlesRenderingObserver;
  53179. private _onBeforeSpritesRenderingObserver;
  53180. private _onAfterSpritesRenderingObserver;
  53181. private _onBeforePhysicsObserver;
  53182. private _onAfterPhysicsObserver;
  53183. private _onAfterAnimationsObserver;
  53184. private _onBeforeCameraRenderObserver;
  53185. private _onAfterCameraRenderObserver;
  53186. /**
  53187. * Gets the perf counter used for active meshes evaluation time
  53188. */
  53189. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53190. /**
  53191. * Gets the active meshes evaluation time capture status
  53192. */
  53193. get captureActiveMeshesEvaluationTime(): boolean;
  53194. /**
  53195. * Enable or disable the active meshes evaluation time capture
  53196. */
  53197. set captureActiveMeshesEvaluationTime(value: boolean);
  53198. /**
  53199. * Gets the perf counter used for render targets render time
  53200. */
  53201. get renderTargetsRenderTimeCounter(): PerfCounter;
  53202. /**
  53203. * Gets the render targets render time capture status
  53204. */
  53205. get captureRenderTargetsRenderTime(): boolean;
  53206. /**
  53207. * Enable or disable the render targets render time capture
  53208. */
  53209. set captureRenderTargetsRenderTime(value: boolean);
  53210. /**
  53211. * Gets the perf counter used for particles render time
  53212. */
  53213. get particlesRenderTimeCounter(): PerfCounter;
  53214. /**
  53215. * Gets the particles render time capture status
  53216. */
  53217. get captureParticlesRenderTime(): boolean;
  53218. /**
  53219. * Enable or disable the particles render time capture
  53220. */
  53221. set captureParticlesRenderTime(value: boolean);
  53222. /**
  53223. * Gets the perf counter used for sprites render time
  53224. */
  53225. get spritesRenderTimeCounter(): PerfCounter;
  53226. /**
  53227. * Gets the sprites render time capture status
  53228. */
  53229. get captureSpritesRenderTime(): boolean;
  53230. /**
  53231. * Enable or disable the sprites render time capture
  53232. */
  53233. set captureSpritesRenderTime(value: boolean);
  53234. /**
  53235. * Gets the perf counter used for physics time
  53236. */
  53237. get physicsTimeCounter(): PerfCounter;
  53238. /**
  53239. * Gets the physics time capture status
  53240. */
  53241. get capturePhysicsTime(): boolean;
  53242. /**
  53243. * Enable or disable the physics time capture
  53244. */
  53245. set capturePhysicsTime(value: boolean);
  53246. /**
  53247. * Gets the perf counter used for animations time
  53248. */
  53249. get animationsTimeCounter(): PerfCounter;
  53250. /**
  53251. * Gets the animations time capture status
  53252. */
  53253. get captureAnimationsTime(): boolean;
  53254. /**
  53255. * Enable or disable the animations time capture
  53256. */
  53257. set captureAnimationsTime(value: boolean);
  53258. /**
  53259. * Gets the perf counter used for frame time capture
  53260. */
  53261. get frameTimeCounter(): PerfCounter;
  53262. /**
  53263. * Gets the frame time capture status
  53264. */
  53265. get captureFrameTime(): boolean;
  53266. /**
  53267. * Enable or disable the frame time capture
  53268. */
  53269. set captureFrameTime(value: boolean);
  53270. /**
  53271. * Gets the perf counter used for inter-frames time capture
  53272. */
  53273. get interFrameTimeCounter(): PerfCounter;
  53274. /**
  53275. * Gets the inter-frames time capture status
  53276. */
  53277. get captureInterFrameTime(): boolean;
  53278. /**
  53279. * Enable or disable the inter-frames time capture
  53280. */
  53281. set captureInterFrameTime(value: boolean);
  53282. /**
  53283. * Gets the perf counter used for render time capture
  53284. */
  53285. get renderTimeCounter(): PerfCounter;
  53286. /**
  53287. * Gets the render time capture status
  53288. */
  53289. get captureRenderTime(): boolean;
  53290. /**
  53291. * Enable or disable the render time capture
  53292. */
  53293. set captureRenderTime(value: boolean);
  53294. /**
  53295. * Gets the perf counter used for camera render time capture
  53296. */
  53297. get cameraRenderTimeCounter(): PerfCounter;
  53298. /**
  53299. * Gets the camera render time capture status
  53300. */
  53301. get captureCameraRenderTime(): boolean;
  53302. /**
  53303. * Enable or disable the camera render time capture
  53304. */
  53305. set captureCameraRenderTime(value: boolean);
  53306. /**
  53307. * Gets the perf counter used for draw calls
  53308. */
  53309. get drawCallsCounter(): PerfCounter;
  53310. /**
  53311. * Instantiates a new scene instrumentation.
  53312. * This class can be used to get instrumentation data from a Babylon engine
  53313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53314. * @param scene Defines the scene to instrument
  53315. */
  53316. constructor(
  53317. /**
  53318. * Defines the scene to instrument
  53319. */
  53320. scene: Scene);
  53321. /**
  53322. * Dispose and release associated resources.
  53323. */
  53324. dispose(): void;
  53325. }
  53326. }
  53327. declare module BABYLON {
  53328. /** @hidden */
  53329. export var glowMapGenerationPixelShader: {
  53330. name: string;
  53331. shader: string;
  53332. };
  53333. }
  53334. declare module BABYLON {
  53335. /** @hidden */
  53336. export var glowMapGenerationVertexShader: {
  53337. name: string;
  53338. shader: string;
  53339. };
  53340. }
  53341. declare module BABYLON {
  53342. /**
  53343. * Effect layer options. This helps customizing the behaviour
  53344. * of the effect layer.
  53345. */
  53346. export interface IEffectLayerOptions {
  53347. /**
  53348. * Multiplication factor apply to the canvas size to compute the render target size
  53349. * used to generated the objects (the smaller the faster).
  53350. */
  53351. mainTextureRatio: number;
  53352. /**
  53353. * Enforces a fixed size texture to ensure effect stability across devices.
  53354. */
  53355. mainTextureFixedSize?: number;
  53356. /**
  53357. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53358. */
  53359. alphaBlendingMode: number;
  53360. /**
  53361. * The camera attached to the layer.
  53362. */
  53363. camera: Nullable<Camera>;
  53364. /**
  53365. * The rendering group to draw the layer in.
  53366. */
  53367. renderingGroupId: number;
  53368. }
  53369. /**
  53370. * The effect layer Helps adding post process effect blended with the main pass.
  53371. *
  53372. * This can be for instance use to generate glow or higlight effects on the scene.
  53373. *
  53374. * The effect layer class can not be used directly and is intented to inherited from to be
  53375. * customized per effects.
  53376. */
  53377. export abstract class EffectLayer {
  53378. private _vertexBuffers;
  53379. private _indexBuffer;
  53380. private _cachedDefines;
  53381. private _effectLayerMapGenerationEffect;
  53382. private _effectLayerOptions;
  53383. private _mergeEffect;
  53384. protected _scene: Scene;
  53385. protected _engine: Engine;
  53386. protected _maxSize: number;
  53387. protected _mainTextureDesiredSize: ISize;
  53388. protected _mainTexture: RenderTargetTexture;
  53389. protected _shouldRender: boolean;
  53390. protected _postProcesses: PostProcess[];
  53391. protected _textures: BaseTexture[];
  53392. protected _emissiveTextureAndColor: {
  53393. texture: Nullable<BaseTexture>;
  53394. color: Color4;
  53395. };
  53396. /**
  53397. * The name of the layer
  53398. */
  53399. name: string;
  53400. /**
  53401. * The clear color of the texture used to generate the glow map.
  53402. */
  53403. neutralColor: Color4;
  53404. /**
  53405. * Specifies whether the highlight layer is enabled or not.
  53406. */
  53407. isEnabled: boolean;
  53408. /**
  53409. * Gets the camera attached to the layer.
  53410. */
  53411. get camera(): Nullable<Camera>;
  53412. /**
  53413. * Gets the rendering group id the layer should render in.
  53414. */
  53415. get renderingGroupId(): number;
  53416. set renderingGroupId(renderingGroupId: number);
  53417. /**
  53418. * An event triggered when the effect layer has been disposed.
  53419. */
  53420. onDisposeObservable: Observable<EffectLayer>;
  53421. /**
  53422. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53423. */
  53424. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53425. /**
  53426. * An event triggered when the generated texture is being merged in the scene.
  53427. */
  53428. onBeforeComposeObservable: Observable<EffectLayer>;
  53429. /**
  53430. * An event triggered when the mesh is rendered into the effect render target.
  53431. */
  53432. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53433. /**
  53434. * An event triggered after the mesh has been rendered into the effect render target.
  53435. */
  53436. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53437. /**
  53438. * An event triggered when the generated texture has been merged in the scene.
  53439. */
  53440. onAfterComposeObservable: Observable<EffectLayer>;
  53441. /**
  53442. * An event triggered when the efffect layer changes its size.
  53443. */
  53444. onSizeChangedObservable: Observable<EffectLayer>;
  53445. /** @hidden */
  53446. static _SceneComponentInitialization: (scene: Scene) => void;
  53447. /**
  53448. * Instantiates a new effect Layer and references it in the scene.
  53449. * @param name The name of the layer
  53450. * @param scene The scene to use the layer in
  53451. */
  53452. constructor(
  53453. /** The Friendly of the effect in the scene */
  53454. name: string, scene: Scene);
  53455. /**
  53456. * Get the effect name of the layer.
  53457. * @return The effect name
  53458. */
  53459. abstract getEffectName(): string;
  53460. /**
  53461. * Checks for the readiness of the element composing the layer.
  53462. * @param subMesh the mesh to check for
  53463. * @param useInstances specify whether or not to use instances to render the mesh
  53464. * @return true if ready otherwise, false
  53465. */
  53466. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53467. /**
  53468. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53469. * @returns true if the effect requires stencil during the main canvas render pass.
  53470. */
  53471. abstract needStencil(): boolean;
  53472. /**
  53473. * Create the merge effect. This is the shader use to blit the information back
  53474. * to the main canvas at the end of the scene rendering.
  53475. * @returns The effect containing the shader used to merge the effect on the main canvas
  53476. */
  53477. protected abstract _createMergeEffect(): Effect;
  53478. /**
  53479. * Creates the render target textures and post processes used in the effect layer.
  53480. */
  53481. protected abstract _createTextureAndPostProcesses(): void;
  53482. /**
  53483. * Implementation specific of rendering the generating effect on the main canvas.
  53484. * @param effect The effect used to render through
  53485. */
  53486. protected abstract _internalRender(effect: Effect): void;
  53487. /**
  53488. * Sets the required values for both the emissive texture and and the main color.
  53489. */
  53490. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53491. /**
  53492. * Free any resources and references associated to a mesh.
  53493. * Internal use
  53494. * @param mesh The mesh to free.
  53495. */
  53496. abstract _disposeMesh(mesh: Mesh): void;
  53497. /**
  53498. * Serializes this layer (Glow or Highlight for example)
  53499. * @returns a serialized layer object
  53500. */
  53501. abstract serialize?(): any;
  53502. /**
  53503. * Initializes the effect layer with the required options.
  53504. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53505. */
  53506. protected _init(options: Partial<IEffectLayerOptions>): void;
  53507. /**
  53508. * Generates the index buffer of the full screen quad blending to the main canvas.
  53509. */
  53510. private _generateIndexBuffer;
  53511. /**
  53512. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53513. */
  53514. private _generateVertexBuffer;
  53515. /**
  53516. * Sets the main texture desired size which is the closest power of two
  53517. * of the engine canvas size.
  53518. */
  53519. private _setMainTextureSize;
  53520. /**
  53521. * Creates the main texture for the effect layer.
  53522. */
  53523. protected _createMainTexture(): void;
  53524. /**
  53525. * Adds specific effects defines.
  53526. * @param defines The defines to add specifics to.
  53527. */
  53528. protected _addCustomEffectDefines(defines: string[]): void;
  53529. /**
  53530. * Checks for the readiness of the element composing the layer.
  53531. * @param subMesh the mesh to check for
  53532. * @param useInstances specify whether or not to use instances to render the mesh
  53533. * @param emissiveTexture the associated emissive texture used to generate the glow
  53534. * @return true if ready otherwise, false
  53535. */
  53536. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53537. /**
  53538. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53539. */
  53540. render(): void;
  53541. /**
  53542. * Determine if a given mesh will be used in the current effect.
  53543. * @param mesh mesh to test
  53544. * @returns true if the mesh will be used
  53545. */
  53546. hasMesh(mesh: AbstractMesh): boolean;
  53547. /**
  53548. * Returns true if the layer contains information to display, otherwise false.
  53549. * @returns true if the glow layer should be rendered
  53550. */
  53551. shouldRender(): boolean;
  53552. /**
  53553. * Returns true if the mesh should render, otherwise false.
  53554. * @param mesh The mesh to render
  53555. * @returns true if it should render otherwise false
  53556. */
  53557. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53558. /**
  53559. * Returns true if the mesh can be rendered, otherwise false.
  53560. * @param mesh The mesh to render
  53561. * @param material The material used on the mesh
  53562. * @returns true if it can be rendered otherwise false
  53563. */
  53564. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53565. /**
  53566. * Returns true if the mesh should render, otherwise false.
  53567. * @param mesh The mesh to render
  53568. * @returns true if it should render otherwise false
  53569. */
  53570. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53571. /**
  53572. * Renders the submesh passed in parameter to the generation map.
  53573. */
  53574. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53575. /**
  53576. * Defines whether the current material of the mesh should be use to render the effect.
  53577. * @param mesh defines the current mesh to render
  53578. */
  53579. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53580. /**
  53581. * Rebuild the required buffers.
  53582. * @hidden Internal use only.
  53583. */
  53584. _rebuild(): void;
  53585. /**
  53586. * Dispose only the render target textures and post process.
  53587. */
  53588. private _disposeTextureAndPostProcesses;
  53589. /**
  53590. * Dispose the highlight layer and free resources.
  53591. */
  53592. dispose(): void;
  53593. /**
  53594. * Gets the class name of the effect layer
  53595. * @returns the string with the class name of the effect layer
  53596. */
  53597. getClassName(): string;
  53598. /**
  53599. * Creates an effect layer from parsed effect layer data
  53600. * @param parsedEffectLayer defines effect layer data
  53601. * @param scene defines the current scene
  53602. * @param rootUrl defines the root URL containing the effect layer information
  53603. * @returns a parsed effect Layer
  53604. */
  53605. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53606. }
  53607. }
  53608. declare module BABYLON {
  53609. interface AbstractScene {
  53610. /**
  53611. * The list of effect layers (highlights/glow) added to the scene
  53612. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53613. * @see http://doc.babylonjs.com/how_to/glow_layer
  53614. */
  53615. effectLayers: Array<EffectLayer>;
  53616. /**
  53617. * Removes the given effect layer from this scene.
  53618. * @param toRemove defines the effect layer to remove
  53619. * @returns the index of the removed effect layer
  53620. */
  53621. removeEffectLayer(toRemove: EffectLayer): number;
  53622. /**
  53623. * Adds the given effect layer to this scene
  53624. * @param newEffectLayer defines the effect layer to add
  53625. */
  53626. addEffectLayer(newEffectLayer: EffectLayer): void;
  53627. }
  53628. /**
  53629. * Defines the layer scene component responsible to manage any effect layers
  53630. * in a given scene.
  53631. */
  53632. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53633. /**
  53634. * The component name helpfull to identify the component in the list of scene components.
  53635. */
  53636. readonly name: string;
  53637. /**
  53638. * The scene the component belongs to.
  53639. */
  53640. scene: Scene;
  53641. private _engine;
  53642. private _renderEffects;
  53643. private _needStencil;
  53644. private _previousStencilState;
  53645. /**
  53646. * Creates a new instance of the component for the given scene
  53647. * @param scene Defines the scene to register the component in
  53648. */
  53649. constructor(scene: Scene);
  53650. /**
  53651. * Registers the component in a given scene
  53652. */
  53653. register(): void;
  53654. /**
  53655. * Rebuilds the elements related to this component in case of
  53656. * context lost for instance.
  53657. */
  53658. rebuild(): void;
  53659. /**
  53660. * Serializes the component data to the specified json object
  53661. * @param serializationObject The object to serialize to
  53662. */
  53663. serialize(serializationObject: any): void;
  53664. /**
  53665. * Adds all the elements from the container to the scene
  53666. * @param container the container holding the elements
  53667. */
  53668. addFromContainer(container: AbstractScene): void;
  53669. /**
  53670. * Removes all the elements in the container from the scene
  53671. * @param container contains the elements to remove
  53672. * @param dispose if the removed element should be disposed (default: false)
  53673. */
  53674. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53675. /**
  53676. * Disposes the component and the associated ressources.
  53677. */
  53678. dispose(): void;
  53679. private _isReadyForMesh;
  53680. private _renderMainTexture;
  53681. private _setStencil;
  53682. private _setStencilBack;
  53683. private _draw;
  53684. private _drawCamera;
  53685. private _drawRenderingGroup;
  53686. }
  53687. }
  53688. declare module BABYLON {
  53689. /** @hidden */
  53690. export var glowMapMergePixelShader: {
  53691. name: string;
  53692. shader: string;
  53693. };
  53694. }
  53695. declare module BABYLON {
  53696. /** @hidden */
  53697. export var glowMapMergeVertexShader: {
  53698. name: string;
  53699. shader: string;
  53700. };
  53701. }
  53702. declare module BABYLON {
  53703. interface AbstractScene {
  53704. /**
  53705. * Return a the first highlight layer of the scene with a given name.
  53706. * @param name The name of the highlight layer to look for.
  53707. * @return The highlight layer if found otherwise null.
  53708. */
  53709. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53710. }
  53711. /**
  53712. * Glow layer options. This helps customizing the behaviour
  53713. * of the glow layer.
  53714. */
  53715. export interface IGlowLayerOptions {
  53716. /**
  53717. * Multiplication factor apply to the canvas size to compute the render target size
  53718. * used to generated the glowing objects (the smaller the faster).
  53719. */
  53720. mainTextureRatio: number;
  53721. /**
  53722. * Enforces a fixed size texture to ensure resize independant blur.
  53723. */
  53724. mainTextureFixedSize?: number;
  53725. /**
  53726. * How big is the kernel of the blur texture.
  53727. */
  53728. blurKernelSize: number;
  53729. /**
  53730. * The camera attached to the layer.
  53731. */
  53732. camera: Nullable<Camera>;
  53733. /**
  53734. * Enable MSAA by chosing the number of samples.
  53735. */
  53736. mainTextureSamples?: number;
  53737. /**
  53738. * The rendering group to draw the layer in.
  53739. */
  53740. renderingGroupId: number;
  53741. }
  53742. /**
  53743. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53744. *
  53745. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53746. *
  53747. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53748. */
  53749. export class GlowLayer extends EffectLayer {
  53750. /**
  53751. * Effect Name of the layer.
  53752. */
  53753. static readonly EffectName: string;
  53754. /**
  53755. * The default blur kernel size used for the glow.
  53756. */
  53757. static DefaultBlurKernelSize: number;
  53758. /**
  53759. * The default texture size ratio used for the glow.
  53760. */
  53761. static DefaultTextureRatio: number;
  53762. /**
  53763. * Sets the kernel size of the blur.
  53764. */
  53765. set blurKernelSize(value: number);
  53766. /**
  53767. * Gets the kernel size of the blur.
  53768. */
  53769. get blurKernelSize(): number;
  53770. /**
  53771. * Sets the glow intensity.
  53772. */
  53773. set intensity(value: number);
  53774. /**
  53775. * Gets the glow intensity.
  53776. */
  53777. get intensity(): number;
  53778. private _options;
  53779. private _intensity;
  53780. private _horizontalBlurPostprocess1;
  53781. private _verticalBlurPostprocess1;
  53782. private _horizontalBlurPostprocess2;
  53783. private _verticalBlurPostprocess2;
  53784. private _blurTexture1;
  53785. private _blurTexture2;
  53786. private _postProcesses1;
  53787. private _postProcesses2;
  53788. private _includedOnlyMeshes;
  53789. private _excludedMeshes;
  53790. private _meshesUsingTheirOwnMaterials;
  53791. /**
  53792. * Callback used to let the user override the color selection on a per mesh basis
  53793. */
  53794. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53795. /**
  53796. * Callback used to let the user override the texture selection on a per mesh basis
  53797. */
  53798. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53799. /**
  53800. * Instantiates a new glow Layer and references it to the scene.
  53801. * @param name The name of the layer
  53802. * @param scene The scene to use the layer in
  53803. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53804. */
  53805. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53806. /**
  53807. * Get the effect name of the layer.
  53808. * @return The effect name
  53809. */
  53810. getEffectName(): string;
  53811. /**
  53812. * Create the merge effect. This is the shader use to blit the information back
  53813. * to the main canvas at the end of the scene rendering.
  53814. */
  53815. protected _createMergeEffect(): Effect;
  53816. /**
  53817. * Creates the render target textures and post processes used in the glow layer.
  53818. */
  53819. protected _createTextureAndPostProcesses(): void;
  53820. /**
  53821. * Checks for the readiness of the element composing the layer.
  53822. * @param subMesh the mesh to check for
  53823. * @param useInstances specify wether or not to use instances to render the mesh
  53824. * @param emissiveTexture the associated emissive texture used to generate the glow
  53825. * @return true if ready otherwise, false
  53826. */
  53827. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53828. /**
  53829. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53830. */
  53831. needStencil(): boolean;
  53832. /**
  53833. * Returns true if the mesh can be rendered, otherwise false.
  53834. * @param mesh The mesh to render
  53835. * @param material The material used on the mesh
  53836. * @returns true if it can be rendered otherwise false
  53837. */
  53838. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53839. /**
  53840. * Implementation specific of rendering the generating effect on the main canvas.
  53841. * @param effect The effect used to render through
  53842. */
  53843. protected _internalRender(effect: Effect): void;
  53844. /**
  53845. * Sets the required values for both the emissive texture and and the main color.
  53846. */
  53847. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53848. /**
  53849. * Returns true if the mesh should render, otherwise false.
  53850. * @param mesh The mesh to render
  53851. * @returns true if it should render otherwise false
  53852. */
  53853. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53854. /**
  53855. * Adds specific effects defines.
  53856. * @param defines The defines to add specifics to.
  53857. */
  53858. protected _addCustomEffectDefines(defines: string[]): void;
  53859. /**
  53860. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53861. * @param mesh The mesh to exclude from the glow layer
  53862. */
  53863. addExcludedMesh(mesh: Mesh): void;
  53864. /**
  53865. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53866. * @param mesh The mesh to remove
  53867. */
  53868. removeExcludedMesh(mesh: Mesh): void;
  53869. /**
  53870. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53871. * @param mesh The mesh to include in the glow layer
  53872. */
  53873. addIncludedOnlyMesh(mesh: Mesh): void;
  53874. /**
  53875. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53876. * @param mesh The mesh to remove
  53877. */
  53878. removeIncludedOnlyMesh(mesh: Mesh): void;
  53879. /**
  53880. * Determine if a given mesh will be used in the glow layer
  53881. * @param mesh The mesh to test
  53882. * @returns true if the mesh will be highlighted by the current glow layer
  53883. */
  53884. hasMesh(mesh: AbstractMesh): boolean;
  53885. /**
  53886. * Defines whether the current material of the mesh should be use to render the effect.
  53887. * @param mesh defines the current mesh to render
  53888. */
  53889. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53890. /**
  53891. * Add a mesh to be rendered through its own material and not with emissive only.
  53892. * @param mesh The mesh for which we need to use its material
  53893. */
  53894. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53895. /**
  53896. * Remove a mesh from being rendered through its own material and not with emissive only.
  53897. * @param mesh The mesh for which we need to not use its material
  53898. */
  53899. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53900. /**
  53901. * Free any resources and references associated to a mesh.
  53902. * Internal use
  53903. * @param mesh The mesh to free.
  53904. * @hidden
  53905. */
  53906. _disposeMesh(mesh: Mesh): void;
  53907. /**
  53908. * Gets the class name of the effect layer
  53909. * @returns the string with the class name of the effect layer
  53910. */
  53911. getClassName(): string;
  53912. /**
  53913. * Serializes this glow layer
  53914. * @returns a serialized glow layer object
  53915. */
  53916. serialize(): any;
  53917. /**
  53918. * Creates a Glow Layer from parsed glow layer data
  53919. * @param parsedGlowLayer defines glow layer data
  53920. * @param scene defines the current scene
  53921. * @param rootUrl defines the root URL containing the glow layer information
  53922. * @returns a parsed Glow Layer
  53923. */
  53924. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53925. }
  53926. }
  53927. declare module BABYLON {
  53928. /** @hidden */
  53929. export var glowBlurPostProcessPixelShader: {
  53930. name: string;
  53931. shader: string;
  53932. };
  53933. }
  53934. declare module BABYLON {
  53935. interface AbstractScene {
  53936. /**
  53937. * Return a the first highlight layer of the scene with a given name.
  53938. * @param name The name of the highlight layer to look for.
  53939. * @return The highlight layer if found otherwise null.
  53940. */
  53941. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53942. }
  53943. /**
  53944. * Highlight layer options. This helps customizing the behaviour
  53945. * of the highlight layer.
  53946. */
  53947. export interface IHighlightLayerOptions {
  53948. /**
  53949. * Multiplication factor apply to the canvas size to compute the render target size
  53950. * used to generated the glowing objects (the smaller the faster).
  53951. */
  53952. mainTextureRatio: number;
  53953. /**
  53954. * Enforces a fixed size texture to ensure resize independant blur.
  53955. */
  53956. mainTextureFixedSize?: number;
  53957. /**
  53958. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53959. * of the picture to blur (the smaller the faster).
  53960. */
  53961. blurTextureSizeRatio: number;
  53962. /**
  53963. * How big in texel of the blur texture is the vertical blur.
  53964. */
  53965. blurVerticalSize: number;
  53966. /**
  53967. * How big in texel of the blur texture is the horizontal blur.
  53968. */
  53969. blurHorizontalSize: number;
  53970. /**
  53971. * Alpha blending mode used to apply the blur. Default is combine.
  53972. */
  53973. alphaBlendingMode: number;
  53974. /**
  53975. * The camera attached to the layer.
  53976. */
  53977. camera: Nullable<Camera>;
  53978. /**
  53979. * Should we display highlight as a solid stroke?
  53980. */
  53981. isStroke?: boolean;
  53982. /**
  53983. * The rendering group to draw the layer in.
  53984. */
  53985. renderingGroupId: number;
  53986. }
  53987. /**
  53988. * The highlight layer Helps adding a glow effect around a mesh.
  53989. *
  53990. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53991. * glowy meshes to your scene.
  53992. *
  53993. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53994. */
  53995. export class HighlightLayer extends EffectLayer {
  53996. name: string;
  53997. /**
  53998. * Effect Name of the highlight layer.
  53999. */
  54000. static readonly EffectName: string;
  54001. /**
  54002. * The neutral color used during the preparation of the glow effect.
  54003. * This is black by default as the blend operation is a blend operation.
  54004. */
  54005. static NeutralColor: Color4;
  54006. /**
  54007. * Stencil value used for glowing meshes.
  54008. */
  54009. static GlowingMeshStencilReference: number;
  54010. /**
  54011. * Stencil value used for the other meshes in the scene.
  54012. */
  54013. static NormalMeshStencilReference: number;
  54014. /**
  54015. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54016. */
  54017. innerGlow: boolean;
  54018. /**
  54019. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54020. */
  54021. outerGlow: boolean;
  54022. /**
  54023. * Specifies the horizontal size of the blur.
  54024. */
  54025. set blurHorizontalSize(value: number);
  54026. /**
  54027. * Specifies the vertical size of the blur.
  54028. */
  54029. set blurVerticalSize(value: number);
  54030. /**
  54031. * Gets the horizontal size of the blur.
  54032. */
  54033. get blurHorizontalSize(): number;
  54034. /**
  54035. * Gets the vertical size of the blur.
  54036. */
  54037. get blurVerticalSize(): number;
  54038. /**
  54039. * An event triggered when the highlight layer is being blurred.
  54040. */
  54041. onBeforeBlurObservable: Observable<HighlightLayer>;
  54042. /**
  54043. * An event triggered when the highlight layer has been blurred.
  54044. */
  54045. onAfterBlurObservable: Observable<HighlightLayer>;
  54046. private _instanceGlowingMeshStencilReference;
  54047. private _options;
  54048. private _downSamplePostprocess;
  54049. private _horizontalBlurPostprocess;
  54050. private _verticalBlurPostprocess;
  54051. private _blurTexture;
  54052. private _meshes;
  54053. private _excludedMeshes;
  54054. /**
  54055. * Instantiates a new highlight Layer and references it to the scene..
  54056. * @param name The name of the layer
  54057. * @param scene The scene to use the layer in
  54058. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54059. */
  54060. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54061. /**
  54062. * Get the effect name of the layer.
  54063. * @return The effect name
  54064. */
  54065. getEffectName(): string;
  54066. /**
  54067. * Create the merge effect. This is the shader use to blit the information back
  54068. * to the main canvas at the end of the scene rendering.
  54069. */
  54070. protected _createMergeEffect(): Effect;
  54071. /**
  54072. * Creates the render target textures and post processes used in the highlight layer.
  54073. */
  54074. protected _createTextureAndPostProcesses(): void;
  54075. /**
  54076. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54077. */
  54078. needStencil(): boolean;
  54079. /**
  54080. * Checks for the readiness of the element composing the layer.
  54081. * @param subMesh the mesh to check for
  54082. * @param useInstances specify wether or not to use instances to render the mesh
  54083. * @param emissiveTexture the associated emissive texture used to generate the glow
  54084. * @return true if ready otherwise, false
  54085. */
  54086. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54087. /**
  54088. * Implementation specific of rendering the generating effect on the main canvas.
  54089. * @param effect The effect used to render through
  54090. */
  54091. protected _internalRender(effect: Effect): void;
  54092. /**
  54093. * Returns true if the layer contains information to display, otherwise false.
  54094. */
  54095. shouldRender(): boolean;
  54096. /**
  54097. * Returns true if the mesh should render, otherwise false.
  54098. * @param mesh The mesh to render
  54099. * @returns true if it should render otherwise false
  54100. */
  54101. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54102. /**
  54103. * Adds specific effects defines.
  54104. * @param defines The defines to add specifics to.
  54105. */
  54106. protected _addCustomEffectDefines(defines: string[]): void;
  54107. /**
  54108. * Sets the required values for both the emissive texture and and the main color.
  54109. */
  54110. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54111. /**
  54112. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54113. * @param mesh The mesh to exclude from the highlight layer
  54114. */
  54115. addExcludedMesh(mesh: Mesh): void;
  54116. /**
  54117. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54118. * @param mesh The mesh to highlight
  54119. */
  54120. removeExcludedMesh(mesh: Mesh): void;
  54121. /**
  54122. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54123. * @param mesh mesh to test
  54124. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54125. */
  54126. hasMesh(mesh: AbstractMesh): boolean;
  54127. /**
  54128. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54129. * @param mesh The mesh to highlight
  54130. * @param color The color of the highlight
  54131. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54132. */
  54133. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54134. /**
  54135. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54136. * @param mesh The mesh to highlight
  54137. */
  54138. removeMesh(mesh: Mesh): void;
  54139. /**
  54140. * Remove all the meshes currently referenced in the highlight layer
  54141. */
  54142. removeAllMeshes(): void;
  54143. /**
  54144. * Force the stencil to the normal expected value for none glowing parts
  54145. */
  54146. private _defaultStencilReference;
  54147. /**
  54148. * Free any resources and references associated to a mesh.
  54149. * Internal use
  54150. * @param mesh The mesh to free.
  54151. * @hidden
  54152. */
  54153. _disposeMesh(mesh: Mesh): void;
  54154. /**
  54155. * Dispose the highlight layer and free resources.
  54156. */
  54157. dispose(): void;
  54158. /**
  54159. * Gets the class name of the effect layer
  54160. * @returns the string with the class name of the effect layer
  54161. */
  54162. getClassName(): string;
  54163. /**
  54164. * Serializes this Highlight layer
  54165. * @returns a serialized Highlight layer object
  54166. */
  54167. serialize(): any;
  54168. /**
  54169. * Creates a Highlight layer from parsed Highlight layer data
  54170. * @param parsedHightlightLayer defines the Highlight layer data
  54171. * @param scene defines the current scene
  54172. * @param rootUrl defines the root URL containing the Highlight layer information
  54173. * @returns a parsed Highlight layer
  54174. */
  54175. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54176. }
  54177. }
  54178. declare module BABYLON {
  54179. interface AbstractScene {
  54180. /**
  54181. * The list of layers (background and foreground) of the scene
  54182. */
  54183. layers: Array<Layer>;
  54184. }
  54185. /**
  54186. * Defines the layer scene component responsible to manage any layers
  54187. * in a given scene.
  54188. */
  54189. export class LayerSceneComponent implements ISceneComponent {
  54190. /**
  54191. * The component name helpfull to identify the component in the list of scene components.
  54192. */
  54193. readonly name: string;
  54194. /**
  54195. * The scene the component belongs to.
  54196. */
  54197. scene: Scene;
  54198. private _engine;
  54199. /**
  54200. * Creates a new instance of the component for the given scene
  54201. * @param scene Defines the scene to register the component in
  54202. */
  54203. constructor(scene: Scene);
  54204. /**
  54205. * Registers the component in a given scene
  54206. */
  54207. register(): void;
  54208. /**
  54209. * Rebuilds the elements related to this component in case of
  54210. * context lost for instance.
  54211. */
  54212. rebuild(): void;
  54213. /**
  54214. * Disposes the component and the associated ressources.
  54215. */
  54216. dispose(): void;
  54217. private _draw;
  54218. private _drawCameraPredicate;
  54219. private _drawCameraBackground;
  54220. private _drawCameraForeground;
  54221. private _drawRenderTargetPredicate;
  54222. private _drawRenderTargetBackground;
  54223. private _drawRenderTargetForeground;
  54224. /**
  54225. * Adds all the elements from the container to the scene
  54226. * @param container the container holding the elements
  54227. */
  54228. addFromContainer(container: AbstractScene): void;
  54229. /**
  54230. * Removes all the elements in the container from the scene
  54231. * @param container contains the elements to remove
  54232. * @param dispose if the removed element should be disposed (default: false)
  54233. */
  54234. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54235. }
  54236. }
  54237. declare module BABYLON {
  54238. /** @hidden */
  54239. export var layerPixelShader: {
  54240. name: string;
  54241. shader: string;
  54242. };
  54243. }
  54244. declare module BABYLON {
  54245. /** @hidden */
  54246. export var layerVertexShader: {
  54247. name: string;
  54248. shader: string;
  54249. };
  54250. }
  54251. declare module BABYLON {
  54252. /**
  54253. * This represents a full screen 2d layer.
  54254. * This can be useful to display a picture in the background of your scene for instance.
  54255. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54256. */
  54257. export class Layer {
  54258. /**
  54259. * Define the name of the layer.
  54260. */
  54261. name: string;
  54262. /**
  54263. * Define the texture the layer should display.
  54264. */
  54265. texture: Nullable<Texture>;
  54266. /**
  54267. * Is the layer in background or foreground.
  54268. */
  54269. isBackground: boolean;
  54270. /**
  54271. * Define the color of the layer (instead of texture).
  54272. */
  54273. color: Color4;
  54274. /**
  54275. * Define the scale of the layer in order to zoom in out of the texture.
  54276. */
  54277. scale: Vector2;
  54278. /**
  54279. * Define an offset for the layer in order to shift the texture.
  54280. */
  54281. offset: Vector2;
  54282. /**
  54283. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54284. */
  54285. alphaBlendingMode: number;
  54286. /**
  54287. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54288. * Alpha test will not mix with the background color in case of transparency.
  54289. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54290. */
  54291. alphaTest: boolean;
  54292. /**
  54293. * Define a mask to restrict the layer to only some of the scene cameras.
  54294. */
  54295. layerMask: number;
  54296. /**
  54297. * Define the list of render target the layer is visible into.
  54298. */
  54299. renderTargetTextures: RenderTargetTexture[];
  54300. /**
  54301. * Define if the layer is only used in renderTarget or if it also
  54302. * renders in the main frame buffer of the canvas.
  54303. */
  54304. renderOnlyInRenderTargetTextures: boolean;
  54305. private _scene;
  54306. private _vertexBuffers;
  54307. private _indexBuffer;
  54308. private _effect;
  54309. private _previousDefines;
  54310. /**
  54311. * An event triggered when the layer is disposed.
  54312. */
  54313. onDisposeObservable: Observable<Layer>;
  54314. private _onDisposeObserver;
  54315. /**
  54316. * Back compatibility with callback before the onDisposeObservable existed.
  54317. * The set callback will be triggered when the layer has been disposed.
  54318. */
  54319. set onDispose(callback: () => void);
  54320. /**
  54321. * An event triggered before rendering the scene
  54322. */
  54323. onBeforeRenderObservable: Observable<Layer>;
  54324. private _onBeforeRenderObserver;
  54325. /**
  54326. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54327. * The set callback will be triggered just before rendering the layer.
  54328. */
  54329. set onBeforeRender(callback: () => void);
  54330. /**
  54331. * An event triggered after rendering the scene
  54332. */
  54333. onAfterRenderObservable: Observable<Layer>;
  54334. private _onAfterRenderObserver;
  54335. /**
  54336. * Back compatibility with callback before the onAfterRenderObservable existed.
  54337. * The set callback will be triggered just after rendering the layer.
  54338. */
  54339. set onAfterRender(callback: () => void);
  54340. /**
  54341. * Instantiates a new layer.
  54342. * This represents a full screen 2d layer.
  54343. * This can be useful to display a picture in the background of your scene for instance.
  54344. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54345. * @param name Define the name of the layer in the scene
  54346. * @param imgUrl Define the url of the texture to display in the layer
  54347. * @param scene Define the scene the layer belongs to
  54348. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54349. * @param color Defines a color for the layer
  54350. */
  54351. constructor(
  54352. /**
  54353. * Define the name of the layer.
  54354. */
  54355. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54356. private _createIndexBuffer;
  54357. /** @hidden */
  54358. _rebuild(): void;
  54359. /**
  54360. * Renders the layer in the scene.
  54361. */
  54362. render(): void;
  54363. /**
  54364. * Disposes and releases the associated ressources.
  54365. */
  54366. dispose(): void;
  54367. }
  54368. }
  54369. declare module BABYLON {
  54370. /** @hidden */
  54371. export var lensFlarePixelShader: {
  54372. name: string;
  54373. shader: string;
  54374. };
  54375. }
  54376. declare module BABYLON {
  54377. /** @hidden */
  54378. export var lensFlareVertexShader: {
  54379. name: string;
  54380. shader: string;
  54381. };
  54382. }
  54383. declare module BABYLON {
  54384. /**
  54385. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54386. * It is usually composed of several `lensFlare`.
  54387. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54388. */
  54389. export class LensFlareSystem {
  54390. /**
  54391. * Define the name of the lens flare system
  54392. */
  54393. name: string;
  54394. /**
  54395. * List of lens flares used in this system.
  54396. */
  54397. lensFlares: LensFlare[];
  54398. /**
  54399. * Define a limit from the border the lens flare can be visible.
  54400. */
  54401. borderLimit: number;
  54402. /**
  54403. * Define a viewport border we do not want to see the lens flare in.
  54404. */
  54405. viewportBorder: number;
  54406. /**
  54407. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54408. */
  54409. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54410. /**
  54411. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54412. */
  54413. layerMask: number;
  54414. /**
  54415. * Define the id of the lens flare system in the scene.
  54416. * (equal to name by default)
  54417. */
  54418. id: string;
  54419. private _scene;
  54420. private _emitter;
  54421. private _vertexBuffers;
  54422. private _indexBuffer;
  54423. private _effect;
  54424. private _positionX;
  54425. private _positionY;
  54426. private _isEnabled;
  54427. /** @hidden */
  54428. static _SceneComponentInitialization: (scene: Scene) => void;
  54429. /**
  54430. * Instantiates a lens flare system.
  54431. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54432. * It is usually composed of several `lensFlare`.
  54433. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54434. * @param name Define the name of the lens flare system in the scene
  54435. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54436. * @param scene Define the scene the lens flare system belongs to
  54437. */
  54438. constructor(
  54439. /**
  54440. * Define the name of the lens flare system
  54441. */
  54442. name: string, emitter: any, scene: Scene);
  54443. /**
  54444. * Define if the lens flare system is enabled.
  54445. */
  54446. get isEnabled(): boolean;
  54447. set isEnabled(value: boolean);
  54448. /**
  54449. * Get the scene the effects belongs to.
  54450. * @returns the scene holding the lens flare system
  54451. */
  54452. getScene(): Scene;
  54453. /**
  54454. * Get the emitter of the lens flare system.
  54455. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54456. * @returns the emitter of the lens flare system
  54457. */
  54458. getEmitter(): any;
  54459. /**
  54460. * Set the emitter of the lens flare system.
  54461. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54462. * @param newEmitter Define the new emitter of the system
  54463. */
  54464. setEmitter(newEmitter: any): void;
  54465. /**
  54466. * Get the lens flare system emitter position.
  54467. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54468. * @returns the position
  54469. */
  54470. getEmitterPosition(): Vector3;
  54471. /**
  54472. * @hidden
  54473. */
  54474. computeEffectivePosition(globalViewport: Viewport): boolean;
  54475. /** @hidden */
  54476. _isVisible(): boolean;
  54477. /**
  54478. * @hidden
  54479. */
  54480. render(): boolean;
  54481. /**
  54482. * Dispose and release the lens flare with its associated resources.
  54483. */
  54484. dispose(): void;
  54485. /**
  54486. * Parse a lens flare system from a JSON repressentation
  54487. * @param parsedLensFlareSystem Define the JSON to parse
  54488. * @param scene Define the scene the parsed system should be instantiated in
  54489. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54490. * @returns the parsed system
  54491. */
  54492. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54493. /**
  54494. * Serialize the current Lens Flare System into a JSON representation.
  54495. * @returns the serialized JSON
  54496. */
  54497. serialize(): any;
  54498. }
  54499. }
  54500. declare module BABYLON {
  54501. /**
  54502. * This represents one of the lens effect in a `lensFlareSystem`.
  54503. * It controls one of the indiviual texture used in the effect.
  54504. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54505. */
  54506. export class LensFlare {
  54507. /**
  54508. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54509. */
  54510. size: number;
  54511. /**
  54512. * 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.
  54513. */
  54514. position: number;
  54515. /**
  54516. * Define the lens color.
  54517. */
  54518. color: Color3;
  54519. /**
  54520. * Define the lens texture.
  54521. */
  54522. texture: Nullable<Texture>;
  54523. /**
  54524. * Define the alpha mode to render this particular lens.
  54525. */
  54526. alphaMode: number;
  54527. private _system;
  54528. /**
  54529. * Creates a new Lens Flare.
  54530. * This represents one of the lens effect in a `lensFlareSystem`.
  54531. * It controls one of the indiviual texture used in the effect.
  54532. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54533. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54534. * @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.
  54535. * @param color Define the lens color
  54536. * @param imgUrl Define the lens texture url
  54537. * @param system Define the `lensFlareSystem` this flare is part of
  54538. * @returns The newly created Lens Flare
  54539. */
  54540. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54541. /**
  54542. * Instantiates a new Lens Flare.
  54543. * This represents one of the lens effect in a `lensFlareSystem`.
  54544. * It controls one of the indiviual texture used in the effect.
  54545. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54546. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54547. * @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.
  54548. * @param color Define the lens color
  54549. * @param imgUrl Define the lens texture url
  54550. * @param system Define the `lensFlareSystem` this flare is part of
  54551. */
  54552. constructor(
  54553. /**
  54554. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54555. */
  54556. size: number,
  54557. /**
  54558. * 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.
  54559. */
  54560. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54561. /**
  54562. * Dispose and release the lens flare with its associated resources.
  54563. */
  54564. dispose(): void;
  54565. }
  54566. }
  54567. declare module BABYLON {
  54568. interface AbstractScene {
  54569. /**
  54570. * The list of lens flare system added to the scene
  54571. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54572. */
  54573. lensFlareSystems: Array<LensFlareSystem>;
  54574. /**
  54575. * Removes the given lens flare system from this scene.
  54576. * @param toRemove The lens flare system to remove
  54577. * @returns The index of the removed lens flare system
  54578. */
  54579. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54580. /**
  54581. * Adds the given lens flare system to this scene
  54582. * @param newLensFlareSystem The lens flare system to add
  54583. */
  54584. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54585. /**
  54586. * Gets a lens flare system using its name
  54587. * @param name defines the name to look for
  54588. * @returns the lens flare system or null if not found
  54589. */
  54590. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54591. /**
  54592. * Gets a lens flare system using its id
  54593. * @param id defines the id to look for
  54594. * @returns the lens flare system or null if not found
  54595. */
  54596. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54597. }
  54598. /**
  54599. * Defines the lens flare scene component responsible to manage any lens flares
  54600. * in a given scene.
  54601. */
  54602. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54603. /**
  54604. * The component name helpfull to identify the component in the list of scene components.
  54605. */
  54606. readonly name: string;
  54607. /**
  54608. * The scene the component belongs to.
  54609. */
  54610. scene: Scene;
  54611. /**
  54612. * Creates a new instance of the component for the given scene
  54613. * @param scene Defines the scene to register the component in
  54614. */
  54615. constructor(scene: Scene);
  54616. /**
  54617. * Registers the component in a given scene
  54618. */
  54619. register(): void;
  54620. /**
  54621. * Rebuilds the elements related to this component in case of
  54622. * context lost for instance.
  54623. */
  54624. rebuild(): void;
  54625. /**
  54626. * Adds all the elements from the container to the scene
  54627. * @param container the container holding the elements
  54628. */
  54629. addFromContainer(container: AbstractScene): void;
  54630. /**
  54631. * Removes all the elements in the container from the scene
  54632. * @param container contains the elements to remove
  54633. * @param dispose if the removed element should be disposed (default: false)
  54634. */
  54635. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54636. /**
  54637. * Serializes the component data to the specified json object
  54638. * @param serializationObject The object to serialize to
  54639. */
  54640. serialize(serializationObject: any): void;
  54641. /**
  54642. * Disposes the component and the associated ressources.
  54643. */
  54644. dispose(): void;
  54645. private _draw;
  54646. }
  54647. }
  54648. declare module BABYLON {
  54649. /** @hidden */
  54650. export var depthPixelShader: {
  54651. name: string;
  54652. shader: string;
  54653. };
  54654. }
  54655. declare module BABYLON {
  54656. /** @hidden */
  54657. export var depthVertexShader: {
  54658. name: string;
  54659. shader: string;
  54660. };
  54661. }
  54662. declare module BABYLON {
  54663. /**
  54664. * This represents a depth renderer in Babylon.
  54665. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54666. */
  54667. export class DepthRenderer {
  54668. private _scene;
  54669. private _depthMap;
  54670. private _effect;
  54671. private readonly _storeNonLinearDepth;
  54672. private readonly _clearColor;
  54673. /** Get if the depth renderer is using packed depth or not */
  54674. readonly isPacked: boolean;
  54675. private _cachedDefines;
  54676. private _camera;
  54677. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54678. enabled: boolean;
  54679. /**
  54680. * Specifiess that the depth renderer will only be used within
  54681. * the camera it is created for.
  54682. * This can help forcing its rendering during the camera processing.
  54683. */
  54684. useOnlyInActiveCamera: boolean;
  54685. /** @hidden */
  54686. static _SceneComponentInitialization: (scene: Scene) => void;
  54687. /**
  54688. * Instantiates a depth renderer
  54689. * @param scene The scene the renderer belongs to
  54690. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54691. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54692. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54693. */
  54694. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54695. /**
  54696. * Creates the depth rendering effect and checks if the effect is ready.
  54697. * @param subMesh The submesh to be used to render the depth map of
  54698. * @param useInstances If multiple world instances should be used
  54699. * @returns if the depth renderer is ready to render the depth map
  54700. */
  54701. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54702. /**
  54703. * Gets the texture which the depth map will be written to.
  54704. * @returns The depth map texture
  54705. */
  54706. getDepthMap(): RenderTargetTexture;
  54707. /**
  54708. * Disposes of the depth renderer.
  54709. */
  54710. dispose(): void;
  54711. }
  54712. }
  54713. declare module BABYLON {
  54714. /** @hidden */
  54715. export var minmaxReduxPixelShader: {
  54716. name: string;
  54717. shader: string;
  54718. };
  54719. }
  54720. declare module BABYLON {
  54721. /**
  54722. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54723. * and maximum values from all values of the texture.
  54724. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54725. * The source values are read from the red channel of the texture.
  54726. */
  54727. export class MinMaxReducer {
  54728. /**
  54729. * Observable triggered when the computation has been performed
  54730. */
  54731. onAfterReductionPerformed: Observable<{
  54732. min: number;
  54733. max: number;
  54734. }>;
  54735. protected _camera: Camera;
  54736. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54737. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54738. protected _postProcessManager: PostProcessManager;
  54739. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54740. protected _forceFullscreenViewport: boolean;
  54741. /**
  54742. * Creates a min/max reducer
  54743. * @param camera The camera to use for the post processes
  54744. */
  54745. constructor(camera: Camera);
  54746. /**
  54747. * Gets the texture used to read the values from.
  54748. */
  54749. get sourceTexture(): Nullable<RenderTargetTexture>;
  54750. /**
  54751. * Sets the source texture to read the values from.
  54752. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54753. * because in such textures '1' value must not be taken into account to compute the maximum
  54754. * as this value is used to clear the texture.
  54755. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54756. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54757. * @param depthRedux Indicates if the texture is a depth texture or not
  54758. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54759. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54760. */
  54761. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54762. /**
  54763. * Defines the refresh rate of the computation.
  54764. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54765. */
  54766. get refreshRate(): number;
  54767. set refreshRate(value: number);
  54768. protected _activated: boolean;
  54769. /**
  54770. * Gets the activation status of the reducer
  54771. */
  54772. get activated(): boolean;
  54773. /**
  54774. * Activates the reduction computation.
  54775. * When activated, the observers registered in onAfterReductionPerformed are
  54776. * called after the compuation is performed
  54777. */
  54778. activate(): void;
  54779. /**
  54780. * Deactivates the reduction computation.
  54781. */
  54782. deactivate(): void;
  54783. /**
  54784. * Disposes the min/max reducer
  54785. * @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.
  54786. */
  54787. dispose(disposeAll?: boolean): void;
  54788. }
  54789. }
  54790. declare module BABYLON {
  54791. /**
  54792. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54793. */
  54794. export class DepthReducer extends MinMaxReducer {
  54795. private _depthRenderer;
  54796. private _depthRendererId;
  54797. /**
  54798. * Gets the depth renderer used for the computation.
  54799. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54800. */
  54801. get depthRenderer(): Nullable<DepthRenderer>;
  54802. /**
  54803. * Creates a depth reducer
  54804. * @param camera The camera used to render the depth texture
  54805. */
  54806. constructor(camera: Camera);
  54807. /**
  54808. * Sets the depth renderer to use to generate the depth map
  54809. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54810. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54811. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54812. */
  54813. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54814. /** @hidden */
  54815. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54816. /**
  54817. * Activates the reduction computation.
  54818. * When activated, the observers registered in onAfterReductionPerformed are
  54819. * called after the compuation is performed
  54820. */
  54821. activate(): void;
  54822. /**
  54823. * Deactivates the reduction computation.
  54824. */
  54825. deactivate(): void;
  54826. /**
  54827. * Disposes the depth reducer
  54828. * @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.
  54829. */
  54830. dispose(disposeAll?: boolean): void;
  54831. }
  54832. }
  54833. declare module BABYLON {
  54834. /**
  54835. * A CSM implementation allowing casting shadows on large scenes.
  54836. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54837. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54838. */
  54839. export class CascadedShadowGenerator extends ShadowGenerator {
  54840. private static readonly frustumCornersNDCSpace;
  54841. /**
  54842. * Name of the CSM class
  54843. */
  54844. static CLASSNAME: string;
  54845. /**
  54846. * Defines the default number of cascades used by the CSM.
  54847. */
  54848. static readonly DEFAULT_CASCADES_COUNT: number;
  54849. /**
  54850. * Defines the minimum number of cascades used by the CSM.
  54851. */
  54852. static readonly MIN_CASCADES_COUNT: number;
  54853. /**
  54854. * Defines the maximum number of cascades used by the CSM.
  54855. */
  54856. static readonly MAX_CASCADES_COUNT: number;
  54857. protected _validateFilter(filter: number): number;
  54858. /**
  54859. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54860. */
  54861. penumbraDarkness: number;
  54862. private _numCascades;
  54863. /**
  54864. * Gets or set the number of cascades used by the CSM.
  54865. */
  54866. get numCascades(): number;
  54867. set numCascades(value: number);
  54868. /**
  54869. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54870. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54871. */
  54872. stabilizeCascades: boolean;
  54873. private _freezeShadowCastersBoundingInfo;
  54874. private _freezeShadowCastersBoundingInfoObservable;
  54875. /**
  54876. * Enables or disables the shadow casters bounding info computation.
  54877. * If your shadow casters don't move, you can disable this feature.
  54878. * If it is enabled, the bounding box computation is done every frame.
  54879. */
  54880. get freezeShadowCastersBoundingInfo(): boolean;
  54881. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54882. private _scbiMin;
  54883. private _scbiMax;
  54884. protected _computeShadowCastersBoundingInfo(): void;
  54885. protected _shadowCastersBoundingInfo: BoundingInfo;
  54886. /**
  54887. * Gets or sets the shadow casters bounding info.
  54888. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54889. * so that the system won't overwrite the bounds you provide
  54890. */
  54891. get shadowCastersBoundingInfo(): BoundingInfo;
  54892. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54893. protected _breaksAreDirty: boolean;
  54894. protected _minDistance: number;
  54895. protected _maxDistance: number;
  54896. /**
  54897. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54898. *
  54899. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54900. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54901. * @param min minimal distance for the breaks (default to 0.)
  54902. * @param max maximal distance for the breaks (default to 1.)
  54903. */
  54904. setMinMaxDistance(min: number, max: number): void;
  54905. /** Gets the minimal distance used in the cascade break computation */
  54906. get minDistance(): number;
  54907. /** Gets the maximal distance used in the cascade break computation */
  54908. get maxDistance(): number;
  54909. /**
  54910. * Gets the class name of that object
  54911. * @returns "CascadedShadowGenerator"
  54912. */
  54913. getClassName(): string;
  54914. private _cascadeMinExtents;
  54915. private _cascadeMaxExtents;
  54916. /**
  54917. * Gets a cascade minimum extents
  54918. * @param cascadeIndex index of the cascade
  54919. * @returns the minimum cascade extents
  54920. */
  54921. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54922. /**
  54923. * Gets a cascade maximum extents
  54924. * @param cascadeIndex index of the cascade
  54925. * @returns the maximum cascade extents
  54926. */
  54927. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54928. private _cascades;
  54929. private _currentLayer;
  54930. private _viewSpaceFrustumsZ;
  54931. private _viewMatrices;
  54932. private _projectionMatrices;
  54933. private _transformMatrices;
  54934. private _transformMatricesAsArray;
  54935. private _frustumLengths;
  54936. private _lightSizeUVCorrection;
  54937. private _depthCorrection;
  54938. private _frustumCornersWorldSpace;
  54939. private _frustumCenter;
  54940. private _shadowCameraPos;
  54941. private _shadowMaxZ;
  54942. /**
  54943. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54944. * It defaults to camera.maxZ
  54945. */
  54946. get shadowMaxZ(): number;
  54947. /**
  54948. * Sets the shadow max z distance.
  54949. */
  54950. set shadowMaxZ(value: number);
  54951. protected _debug: boolean;
  54952. /**
  54953. * Gets or sets the debug flag.
  54954. * When enabled, the cascades are materialized by different colors on the screen.
  54955. */
  54956. get debug(): boolean;
  54957. set debug(dbg: boolean);
  54958. private _depthClamp;
  54959. /**
  54960. * Gets or sets the depth clamping value.
  54961. *
  54962. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54963. * to account for the shadow casters far away.
  54964. *
  54965. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54966. */
  54967. get depthClamp(): boolean;
  54968. set depthClamp(value: boolean);
  54969. private _cascadeBlendPercentage;
  54970. /**
  54971. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54972. * It defaults to 0.1 (10% blending).
  54973. */
  54974. get cascadeBlendPercentage(): number;
  54975. set cascadeBlendPercentage(value: number);
  54976. private _lambda;
  54977. /**
  54978. * Gets or set the lambda parameter.
  54979. * This parameter is used to split the camera frustum and create the cascades.
  54980. * 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.
  54981. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54982. */
  54983. get lambda(): number;
  54984. set lambda(value: number);
  54985. /**
  54986. * Gets the view matrix corresponding to a given cascade
  54987. * @param cascadeNum cascade to retrieve the view matrix from
  54988. * @returns the cascade view matrix
  54989. */
  54990. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54991. /**
  54992. * Gets the projection matrix corresponding to a given cascade
  54993. * @param cascadeNum cascade to retrieve the projection matrix from
  54994. * @returns the cascade projection matrix
  54995. */
  54996. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54997. /**
  54998. * Gets the transformation matrix corresponding to a given cascade
  54999. * @param cascadeNum cascade to retrieve the transformation matrix from
  55000. * @returns the cascade transformation matrix
  55001. */
  55002. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55003. private _depthRenderer;
  55004. /**
  55005. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55006. *
  55007. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55008. *
  55009. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55010. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55011. * @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
  55012. */
  55013. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55014. private _depthReducer;
  55015. private _autoCalcDepthBounds;
  55016. /**
  55017. * Gets or sets the autoCalcDepthBounds property.
  55018. *
  55019. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55020. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55021. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55022. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55023. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55024. */
  55025. get autoCalcDepthBounds(): boolean;
  55026. set autoCalcDepthBounds(value: boolean);
  55027. /**
  55028. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55029. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55030. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55031. * for setting the refresh rate on the renderer yourself!
  55032. */
  55033. get autoCalcDepthBoundsRefreshRate(): number;
  55034. set autoCalcDepthBoundsRefreshRate(value: number);
  55035. /**
  55036. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55037. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55038. * you change the camera near/far planes!
  55039. */
  55040. splitFrustum(): void;
  55041. private _splitFrustum;
  55042. private _computeMatrices;
  55043. private _computeFrustumInWorldSpace;
  55044. private _computeCascadeFrustum;
  55045. /**
  55046. * Support test.
  55047. */
  55048. static get IsSupported(): boolean;
  55049. /** @hidden */
  55050. static _SceneComponentInitialization: (scene: Scene) => void;
  55051. /**
  55052. * Creates a Cascaded Shadow Generator object.
  55053. * A ShadowGenerator is the required tool to use the shadows.
  55054. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55055. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55056. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55057. * @param light The directional light object generating the shadows.
  55058. * @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.
  55059. */
  55060. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55061. protected _initializeGenerator(): void;
  55062. protected _createTargetRenderTexture(): void;
  55063. protected _initializeShadowMap(): void;
  55064. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55065. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55066. /**
  55067. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55068. * @param defines Defines of the material we want to update
  55069. * @param lightIndex Index of the light in the enabled light list of the material
  55070. */
  55071. prepareDefines(defines: any, lightIndex: number): void;
  55072. /**
  55073. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55074. * defined in the generator but impacting the effect).
  55075. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55076. * @param effect The effect we are binfing the information for
  55077. */
  55078. bindShadowLight(lightIndex: string, effect: Effect): void;
  55079. /**
  55080. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55081. * (eq to view projection * shadow projection matrices)
  55082. * @returns The transform matrix used to create the shadow map
  55083. */
  55084. getTransformMatrix(): Matrix;
  55085. /**
  55086. * Disposes the ShadowGenerator.
  55087. * Returns nothing.
  55088. */
  55089. dispose(): void;
  55090. /**
  55091. * Serializes the shadow generator setup to a json object.
  55092. * @returns The serialized JSON object
  55093. */
  55094. serialize(): any;
  55095. /**
  55096. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55097. * @param parsedShadowGenerator The JSON object to parse
  55098. * @param scene The scene to create the shadow map for
  55099. * @returns The parsed shadow generator
  55100. */
  55101. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55102. }
  55103. }
  55104. declare module BABYLON {
  55105. /**
  55106. * Defines the shadow generator component responsible to manage any shadow generators
  55107. * in a given scene.
  55108. */
  55109. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55110. /**
  55111. * The component name helpfull to identify the component in the list of scene components.
  55112. */
  55113. readonly name: string;
  55114. /**
  55115. * The scene the component belongs to.
  55116. */
  55117. scene: Scene;
  55118. /**
  55119. * Creates a new instance of the component for the given scene
  55120. * @param scene Defines the scene to register the component in
  55121. */
  55122. constructor(scene: Scene);
  55123. /**
  55124. * Registers the component in a given scene
  55125. */
  55126. register(): void;
  55127. /**
  55128. * Rebuilds the elements related to this component in case of
  55129. * context lost for instance.
  55130. */
  55131. rebuild(): void;
  55132. /**
  55133. * Serializes the component data to the specified json object
  55134. * @param serializationObject The object to serialize to
  55135. */
  55136. serialize(serializationObject: any): void;
  55137. /**
  55138. * Adds all the elements from the container to the scene
  55139. * @param container the container holding the elements
  55140. */
  55141. addFromContainer(container: AbstractScene): void;
  55142. /**
  55143. * Removes all the elements in the container from the scene
  55144. * @param container contains the elements to remove
  55145. * @param dispose if the removed element should be disposed (default: false)
  55146. */
  55147. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55148. /**
  55149. * Rebuilds the elements related to this component in case of
  55150. * context lost for instance.
  55151. */
  55152. dispose(): void;
  55153. private _gatherRenderTargets;
  55154. }
  55155. }
  55156. declare module BABYLON {
  55157. /**
  55158. * A point light is a light defined by an unique point in world space.
  55159. * The light is emitted in every direction from this point.
  55160. * A good example of a point light is a standard light bulb.
  55161. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55162. */
  55163. export class PointLight extends ShadowLight {
  55164. private _shadowAngle;
  55165. /**
  55166. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55167. * This specifies what angle the shadow will use to be created.
  55168. *
  55169. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55170. */
  55171. get shadowAngle(): number;
  55172. /**
  55173. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55174. * This specifies what angle the shadow will use to be created.
  55175. *
  55176. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55177. */
  55178. set shadowAngle(value: number);
  55179. /**
  55180. * Gets the direction if it has been set.
  55181. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55182. */
  55183. get direction(): Vector3;
  55184. /**
  55185. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55186. */
  55187. set direction(value: Vector3);
  55188. /**
  55189. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55190. * A PointLight emits the light in every direction.
  55191. * It can cast shadows.
  55192. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55193. * ```javascript
  55194. * var pointLight = new PointLight("pl", camera.position, scene);
  55195. * ```
  55196. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55197. * @param name The light friendly name
  55198. * @param position The position of the point light in the scene
  55199. * @param scene The scene the lights belongs to
  55200. */
  55201. constructor(name: string, position: Vector3, scene: Scene);
  55202. /**
  55203. * Returns the string "PointLight"
  55204. * @returns the class name
  55205. */
  55206. getClassName(): string;
  55207. /**
  55208. * Returns the integer 0.
  55209. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55210. */
  55211. getTypeID(): number;
  55212. /**
  55213. * Specifies wether or not the shadowmap should be a cube texture.
  55214. * @returns true if the shadowmap needs to be a cube texture.
  55215. */
  55216. needCube(): boolean;
  55217. /**
  55218. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55219. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55220. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55221. */
  55222. getShadowDirection(faceIndex?: number): Vector3;
  55223. /**
  55224. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55225. * - fov = PI / 2
  55226. * - aspect ratio : 1.0
  55227. * - z-near and far equal to the active camera minZ and maxZ.
  55228. * Returns the PointLight.
  55229. */
  55230. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55231. protected _buildUniformLayout(): void;
  55232. /**
  55233. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55234. * @param effect The effect to update
  55235. * @param lightIndex The index of the light in the effect to update
  55236. * @returns The point light
  55237. */
  55238. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55239. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55240. /**
  55241. * Prepares the list of defines specific to the light type.
  55242. * @param defines the list of defines
  55243. * @param lightIndex defines the index of the light for the effect
  55244. */
  55245. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55246. }
  55247. }
  55248. declare module BABYLON {
  55249. /**
  55250. * Header information of HDR texture files.
  55251. */
  55252. export interface HDRInfo {
  55253. /**
  55254. * The height of the texture in pixels.
  55255. */
  55256. height: number;
  55257. /**
  55258. * The width of the texture in pixels.
  55259. */
  55260. width: number;
  55261. /**
  55262. * The index of the beginning of the data in the binary file.
  55263. */
  55264. dataPosition: number;
  55265. }
  55266. /**
  55267. * This groups tools to convert HDR texture to native colors array.
  55268. */
  55269. export class HDRTools {
  55270. private static Ldexp;
  55271. private static Rgbe2float;
  55272. private static readStringLine;
  55273. /**
  55274. * Reads header information from an RGBE texture stored in a native array.
  55275. * More information on this format are available here:
  55276. * https://en.wikipedia.org/wiki/RGBE_image_format
  55277. *
  55278. * @param uint8array The binary file stored in native array.
  55279. * @return The header information.
  55280. */
  55281. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55282. /**
  55283. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55284. * This RGBE texture needs to store the information as a panorama.
  55285. *
  55286. * More information on this format are available here:
  55287. * https://en.wikipedia.org/wiki/RGBE_image_format
  55288. *
  55289. * @param buffer The binary file stored in an array buffer.
  55290. * @param size The expected size of the extracted cubemap.
  55291. * @return The Cube Map information.
  55292. */
  55293. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55294. /**
  55295. * Returns the pixels data extracted from an RGBE texture.
  55296. * This pixels will be stored left to right up to down in the R G B order in one array.
  55297. *
  55298. * More information on this format are available here:
  55299. * https://en.wikipedia.org/wiki/RGBE_image_format
  55300. *
  55301. * @param uint8array The binary file stored in an array buffer.
  55302. * @param hdrInfo The header information of the file.
  55303. * @return The pixels data in RGB right to left up to down order.
  55304. */
  55305. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55306. private static RGBE_ReadPixels_RLE;
  55307. }
  55308. }
  55309. declare module BABYLON {
  55310. /**
  55311. * This represents a texture coming from an HDR input.
  55312. *
  55313. * The only supported format is currently panorama picture stored in RGBE format.
  55314. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55315. */
  55316. export class HDRCubeTexture extends BaseTexture {
  55317. private static _facesMapping;
  55318. private _generateHarmonics;
  55319. private _noMipmap;
  55320. private _textureMatrix;
  55321. private _size;
  55322. private _onLoad;
  55323. private _onError;
  55324. /**
  55325. * The texture URL.
  55326. */
  55327. url: string;
  55328. /**
  55329. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55330. */
  55331. coordinatesMode: number;
  55332. protected _isBlocking: boolean;
  55333. /**
  55334. * Sets wether or not the texture is blocking during loading.
  55335. */
  55336. set isBlocking(value: boolean);
  55337. /**
  55338. * Gets wether or not the texture is blocking during loading.
  55339. */
  55340. get isBlocking(): boolean;
  55341. protected _rotationY: number;
  55342. /**
  55343. * Sets texture matrix rotation angle around Y axis in radians.
  55344. */
  55345. set rotationY(value: number);
  55346. /**
  55347. * Gets texture matrix rotation angle around Y axis radians.
  55348. */
  55349. get rotationY(): number;
  55350. /**
  55351. * Gets or sets the center of the bounding box associated with the cube texture
  55352. * It must define where the camera used to render the texture was set
  55353. */
  55354. boundingBoxPosition: Vector3;
  55355. private _boundingBoxSize;
  55356. /**
  55357. * Gets or sets the size of the bounding box associated with the cube texture
  55358. * When defined, the cubemap will switch to local mode
  55359. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55360. * @example https://www.babylonjs-playground.com/#RNASML
  55361. */
  55362. set boundingBoxSize(value: Vector3);
  55363. get boundingBoxSize(): Vector3;
  55364. /**
  55365. * Instantiates an HDRTexture from the following parameters.
  55366. *
  55367. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55368. * @param scene The scene the texture will be used in
  55369. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55370. * @param noMipmap Forces to not generate the mipmap if true
  55371. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55372. * @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)
  55373. * @param reserved Reserved flag for internal use.
  55374. */
  55375. 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>);
  55376. /**
  55377. * Get the current class name of the texture useful for serialization or dynamic coding.
  55378. * @returns "HDRCubeTexture"
  55379. */
  55380. getClassName(): string;
  55381. /**
  55382. * Occurs when the file is raw .hdr file.
  55383. */
  55384. private loadTexture;
  55385. clone(): HDRCubeTexture;
  55386. delayLoad(): void;
  55387. /**
  55388. * Get the texture reflection matrix used to rotate/transform the reflection.
  55389. * @returns the reflection matrix
  55390. */
  55391. getReflectionTextureMatrix(): Matrix;
  55392. /**
  55393. * Set the texture reflection matrix used to rotate/transform the reflection.
  55394. * @param value Define the reflection matrix to set
  55395. */
  55396. setReflectionTextureMatrix(value: Matrix): void;
  55397. /**
  55398. * Parses a JSON representation of an HDR Texture in order to create the texture
  55399. * @param parsedTexture Define the JSON representation
  55400. * @param scene Define the scene the texture should be created in
  55401. * @param rootUrl Define the root url in case we need to load relative dependencies
  55402. * @returns the newly created texture after parsing
  55403. */
  55404. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55405. serialize(): any;
  55406. }
  55407. }
  55408. declare module BABYLON {
  55409. /**
  55410. * Class used to control physics engine
  55411. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55412. */
  55413. export class PhysicsEngine implements IPhysicsEngine {
  55414. private _physicsPlugin;
  55415. /**
  55416. * Global value used to control the smallest number supported by the simulation
  55417. */
  55418. static Epsilon: number;
  55419. private _impostors;
  55420. private _joints;
  55421. private _subTimeStep;
  55422. /**
  55423. * Gets the gravity vector used by the simulation
  55424. */
  55425. gravity: Vector3;
  55426. /**
  55427. * Factory used to create the default physics plugin.
  55428. * @returns The default physics plugin
  55429. */
  55430. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55431. /**
  55432. * Creates a new Physics Engine
  55433. * @param gravity defines the gravity vector used by the simulation
  55434. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55435. */
  55436. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55437. /**
  55438. * Sets the gravity vector used by the simulation
  55439. * @param gravity defines the gravity vector to use
  55440. */
  55441. setGravity(gravity: Vector3): void;
  55442. /**
  55443. * Set the time step of the physics engine.
  55444. * Default is 1/60.
  55445. * To slow it down, enter 1/600 for example.
  55446. * To speed it up, 1/30
  55447. * @param newTimeStep defines the new timestep to apply to this world.
  55448. */
  55449. setTimeStep(newTimeStep?: number): void;
  55450. /**
  55451. * Get the time step of the physics engine.
  55452. * @returns the current time step
  55453. */
  55454. getTimeStep(): number;
  55455. /**
  55456. * Set the sub time step of the physics engine.
  55457. * Default is 0 meaning there is no sub steps
  55458. * To increase physics resolution precision, set a small value (like 1 ms)
  55459. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55460. */
  55461. setSubTimeStep(subTimeStep?: number): void;
  55462. /**
  55463. * Get the sub time step of the physics engine.
  55464. * @returns the current sub time step
  55465. */
  55466. getSubTimeStep(): number;
  55467. /**
  55468. * Release all resources
  55469. */
  55470. dispose(): void;
  55471. /**
  55472. * Gets the name of the current physics plugin
  55473. * @returns the name of the plugin
  55474. */
  55475. getPhysicsPluginName(): string;
  55476. /**
  55477. * Adding a new impostor for the impostor tracking.
  55478. * This will be done by the impostor itself.
  55479. * @param impostor the impostor to add
  55480. */
  55481. addImpostor(impostor: PhysicsImpostor): void;
  55482. /**
  55483. * Remove an impostor from the engine.
  55484. * This impostor and its mesh will not longer be updated by the physics engine.
  55485. * @param impostor the impostor to remove
  55486. */
  55487. removeImpostor(impostor: PhysicsImpostor): void;
  55488. /**
  55489. * Add a joint to the physics engine
  55490. * @param mainImpostor defines the main impostor to which the joint is added.
  55491. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55492. * @param joint defines the joint that will connect both impostors.
  55493. */
  55494. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55495. /**
  55496. * Removes a joint from the simulation
  55497. * @param mainImpostor defines the impostor used with the joint
  55498. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55499. * @param joint defines the joint to remove
  55500. */
  55501. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55502. /**
  55503. * Called by the scene. No need to call it.
  55504. * @param delta defines the timespam between frames
  55505. */
  55506. _step(delta: number): void;
  55507. /**
  55508. * Gets the current plugin used to run the simulation
  55509. * @returns current plugin
  55510. */
  55511. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55512. /**
  55513. * Gets the list of physic impostors
  55514. * @returns an array of PhysicsImpostor
  55515. */
  55516. getImpostors(): Array<PhysicsImpostor>;
  55517. /**
  55518. * Gets the impostor for a physics enabled object
  55519. * @param object defines the object impersonated by the impostor
  55520. * @returns the PhysicsImpostor or null if not found
  55521. */
  55522. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55523. /**
  55524. * Gets the impostor for a physics body object
  55525. * @param body defines physics body used by the impostor
  55526. * @returns the PhysicsImpostor or null if not found
  55527. */
  55528. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55529. /**
  55530. * Does a raycast in the physics world
  55531. * @param from when should the ray start?
  55532. * @param to when should the ray end?
  55533. * @returns PhysicsRaycastResult
  55534. */
  55535. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55536. }
  55537. }
  55538. declare module BABYLON {
  55539. /** @hidden */
  55540. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55541. private _useDeltaForWorldStep;
  55542. world: any;
  55543. name: string;
  55544. private _physicsMaterials;
  55545. private _fixedTimeStep;
  55546. private _cannonRaycastResult;
  55547. private _raycastResult;
  55548. private _physicsBodysToRemoveAfterStep;
  55549. BJSCANNON: any;
  55550. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55551. setGravity(gravity: Vector3): void;
  55552. setTimeStep(timeStep: number): void;
  55553. getTimeStep(): number;
  55554. executeStep(delta: number): void;
  55555. private _removeMarkedPhysicsBodiesFromWorld;
  55556. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55557. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55558. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55559. private _processChildMeshes;
  55560. removePhysicsBody(impostor: PhysicsImpostor): void;
  55561. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55562. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55563. private _addMaterial;
  55564. private _checkWithEpsilon;
  55565. private _createShape;
  55566. private _createHeightmap;
  55567. private _minus90X;
  55568. private _plus90X;
  55569. private _tmpPosition;
  55570. private _tmpDeltaPosition;
  55571. private _tmpUnityRotation;
  55572. private _updatePhysicsBodyTransformation;
  55573. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55574. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55575. isSupported(): boolean;
  55576. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55577. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55578. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55579. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55580. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55581. getBodyMass(impostor: PhysicsImpostor): number;
  55582. getBodyFriction(impostor: PhysicsImpostor): number;
  55583. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55584. getBodyRestitution(impostor: PhysicsImpostor): number;
  55585. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55586. sleepBody(impostor: PhysicsImpostor): void;
  55587. wakeUpBody(impostor: PhysicsImpostor): void;
  55588. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55589. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55590. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55591. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55592. getRadius(impostor: PhysicsImpostor): number;
  55593. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55594. dispose(): void;
  55595. private _extendNamespace;
  55596. /**
  55597. * Does a raycast in the physics world
  55598. * @param from when should the ray start?
  55599. * @param to when should the ray end?
  55600. * @returns PhysicsRaycastResult
  55601. */
  55602. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55603. }
  55604. }
  55605. declare module BABYLON {
  55606. /** @hidden */
  55607. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55608. private _useDeltaForWorldStep;
  55609. world: any;
  55610. name: string;
  55611. BJSOIMO: any;
  55612. private _raycastResult;
  55613. private _fixedTimeStep;
  55614. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55615. setGravity(gravity: Vector3): void;
  55616. setTimeStep(timeStep: number): void;
  55617. getTimeStep(): number;
  55618. private _tmpImpostorsArray;
  55619. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55620. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55621. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55622. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55623. private _tmpPositionVector;
  55624. removePhysicsBody(impostor: PhysicsImpostor): void;
  55625. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55626. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55627. isSupported(): boolean;
  55628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55629. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55630. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55631. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55632. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55633. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55634. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55635. getBodyMass(impostor: PhysicsImpostor): number;
  55636. getBodyFriction(impostor: PhysicsImpostor): number;
  55637. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55638. getBodyRestitution(impostor: PhysicsImpostor): number;
  55639. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55640. sleepBody(impostor: PhysicsImpostor): void;
  55641. wakeUpBody(impostor: PhysicsImpostor): void;
  55642. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55643. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55644. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55645. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55646. getRadius(impostor: PhysicsImpostor): number;
  55647. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55648. dispose(): void;
  55649. /**
  55650. * Does a raycast in the physics world
  55651. * @param from when should the ray start?
  55652. * @param to when should the ray end?
  55653. * @returns PhysicsRaycastResult
  55654. */
  55655. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55656. }
  55657. }
  55658. declare module BABYLON {
  55659. /**
  55660. * Class containing static functions to help procedurally build meshes
  55661. */
  55662. export class RibbonBuilder {
  55663. /**
  55664. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55665. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55666. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55667. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55668. * * 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
  55669. * * 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
  55670. * * 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
  55671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55672. * * 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
  55673. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55674. * * 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
  55675. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55676. * * 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
  55677. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55679. * @param name defines the name of the mesh
  55680. * @param options defines the options used to create the mesh
  55681. * @param scene defines the hosting scene
  55682. * @returns the ribbon mesh
  55683. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55685. */
  55686. static CreateRibbon(name: string, options: {
  55687. pathArray: Vector3[][];
  55688. closeArray?: boolean;
  55689. closePath?: boolean;
  55690. offset?: number;
  55691. updatable?: boolean;
  55692. sideOrientation?: number;
  55693. frontUVs?: Vector4;
  55694. backUVs?: Vector4;
  55695. instance?: Mesh;
  55696. invertUV?: boolean;
  55697. uvs?: Vector2[];
  55698. colors?: Color4[];
  55699. }, scene?: Nullable<Scene>): Mesh;
  55700. }
  55701. }
  55702. declare module BABYLON {
  55703. /**
  55704. * Class containing static functions to help procedurally build meshes
  55705. */
  55706. export class ShapeBuilder {
  55707. /**
  55708. * 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.
  55709. * * 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.
  55710. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55711. * * 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.
  55712. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55713. * * 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
  55714. * * 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
  55715. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55717. * * 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
  55718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55720. * @param name defines the name of the mesh
  55721. * @param options defines the options used to create the mesh
  55722. * @param scene defines the hosting scene
  55723. * @returns the extruded shape mesh
  55724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55726. */
  55727. static ExtrudeShape(name: string, options: {
  55728. shape: Vector3[];
  55729. path: Vector3[];
  55730. scale?: number;
  55731. rotation?: number;
  55732. cap?: number;
  55733. updatable?: boolean;
  55734. sideOrientation?: number;
  55735. frontUVs?: Vector4;
  55736. backUVs?: Vector4;
  55737. instance?: Mesh;
  55738. invertUV?: boolean;
  55739. }, scene?: Nullable<Scene>): Mesh;
  55740. /**
  55741. * Creates an custom extruded shape mesh.
  55742. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55743. * * 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.
  55744. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55745. * * 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
  55746. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55747. * * 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
  55748. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55749. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55750. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55751. * * 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
  55752. * * 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
  55753. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55755. * * 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
  55756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55758. * @param name defines the name of the mesh
  55759. * @param options defines the options used to create the mesh
  55760. * @param scene defines the hosting scene
  55761. * @returns the custom extruded shape mesh
  55762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55763. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55765. */
  55766. static ExtrudeShapeCustom(name: string, options: {
  55767. shape: Vector3[];
  55768. path: Vector3[];
  55769. scaleFunction?: any;
  55770. rotationFunction?: any;
  55771. ribbonCloseArray?: boolean;
  55772. ribbonClosePath?: boolean;
  55773. cap?: number;
  55774. updatable?: boolean;
  55775. sideOrientation?: number;
  55776. frontUVs?: Vector4;
  55777. backUVs?: Vector4;
  55778. instance?: Mesh;
  55779. invertUV?: boolean;
  55780. }, scene?: Nullable<Scene>): Mesh;
  55781. private static _ExtrudeShapeGeneric;
  55782. }
  55783. }
  55784. declare module BABYLON {
  55785. /**
  55786. * AmmoJS Physics plugin
  55787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55788. * @see https://github.com/kripken/ammo.js/
  55789. */
  55790. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55791. private _useDeltaForWorldStep;
  55792. /**
  55793. * Reference to the Ammo library
  55794. */
  55795. bjsAMMO: any;
  55796. /**
  55797. * Created ammoJS world which physics bodies are added to
  55798. */
  55799. world: any;
  55800. /**
  55801. * Name of the plugin
  55802. */
  55803. name: string;
  55804. private _timeStep;
  55805. private _fixedTimeStep;
  55806. private _maxSteps;
  55807. private _tmpQuaternion;
  55808. private _tmpAmmoTransform;
  55809. private _tmpAmmoQuaternion;
  55810. private _tmpAmmoConcreteContactResultCallback;
  55811. private _collisionConfiguration;
  55812. private _dispatcher;
  55813. private _overlappingPairCache;
  55814. private _solver;
  55815. private _softBodySolver;
  55816. private _tmpAmmoVectorA;
  55817. private _tmpAmmoVectorB;
  55818. private _tmpAmmoVectorC;
  55819. private _tmpAmmoVectorD;
  55820. private _tmpContactCallbackResult;
  55821. private _tmpAmmoVectorRCA;
  55822. private _tmpAmmoVectorRCB;
  55823. private _raycastResult;
  55824. private static readonly DISABLE_COLLISION_FLAG;
  55825. private static readonly KINEMATIC_FLAG;
  55826. private static readonly DISABLE_DEACTIVATION_FLAG;
  55827. /**
  55828. * Initializes the ammoJS plugin
  55829. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55830. * @param ammoInjection can be used to inject your own ammo reference
  55831. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55832. */
  55833. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55834. /**
  55835. * Sets the gravity of the physics world (m/(s^2))
  55836. * @param gravity Gravity to set
  55837. */
  55838. setGravity(gravity: Vector3): void;
  55839. /**
  55840. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55841. * @param timeStep timestep to use in seconds
  55842. */
  55843. setTimeStep(timeStep: number): void;
  55844. /**
  55845. * 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)
  55846. * @param fixedTimeStep fixedTimeStep to use in seconds
  55847. */
  55848. setFixedTimeStep(fixedTimeStep: number): void;
  55849. /**
  55850. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55851. * @param maxSteps the maximum number of steps by the physics engine per frame
  55852. */
  55853. setMaxSteps(maxSteps: number): void;
  55854. /**
  55855. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55856. * @returns the current timestep in seconds
  55857. */
  55858. getTimeStep(): number;
  55859. /**
  55860. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55861. */
  55862. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55863. private _isImpostorInContact;
  55864. private _isImpostorPairInContact;
  55865. private _stepSimulation;
  55866. /**
  55867. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55868. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55869. * After the step the babylon meshes are set to the position of the physics imposters
  55870. * @param delta amount of time to step forward
  55871. * @param impostors array of imposters to update before/after the step
  55872. */
  55873. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55874. /**
  55875. * Update babylon mesh to match physics world object
  55876. * @param impostor imposter to match
  55877. */
  55878. private _afterSoftStep;
  55879. /**
  55880. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55881. * @param impostor imposter to match
  55882. */
  55883. private _ropeStep;
  55884. /**
  55885. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55886. * @param impostor imposter to match
  55887. */
  55888. private _softbodyOrClothStep;
  55889. private _tmpMatrix;
  55890. /**
  55891. * Applies an impulse on the imposter
  55892. * @param impostor imposter to apply impulse to
  55893. * @param force amount of force to be applied to the imposter
  55894. * @param contactPoint the location to apply the impulse on the imposter
  55895. */
  55896. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55897. /**
  55898. * Applies a force on the imposter
  55899. * @param impostor imposter to apply force
  55900. * @param force amount of force to be applied to the imposter
  55901. * @param contactPoint the location to apply the force on the imposter
  55902. */
  55903. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55904. /**
  55905. * Creates a physics body using the plugin
  55906. * @param impostor the imposter to create the physics body on
  55907. */
  55908. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55909. /**
  55910. * Removes the physics body from the imposter and disposes of the body's memory
  55911. * @param impostor imposter to remove the physics body from
  55912. */
  55913. removePhysicsBody(impostor: PhysicsImpostor): void;
  55914. /**
  55915. * Generates a joint
  55916. * @param impostorJoint the imposter joint to create the joint with
  55917. */
  55918. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55919. /**
  55920. * Removes a joint
  55921. * @param impostorJoint the imposter joint to remove the joint from
  55922. */
  55923. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55924. private _addMeshVerts;
  55925. /**
  55926. * Initialise the soft body vertices to match its object's (mesh) vertices
  55927. * Softbody vertices (nodes) are in world space and to match this
  55928. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55929. * @param impostor to create the softbody for
  55930. */
  55931. private _softVertexData;
  55932. /**
  55933. * Create an impostor's soft body
  55934. * @param impostor to create the softbody for
  55935. */
  55936. private _createSoftbody;
  55937. /**
  55938. * Create cloth for an impostor
  55939. * @param impostor to create the softbody for
  55940. */
  55941. private _createCloth;
  55942. /**
  55943. * Create rope for an impostor
  55944. * @param impostor to create the softbody for
  55945. */
  55946. private _createRope;
  55947. /**
  55948. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55949. * @param impostor to create the custom physics shape for
  55950. */
  55951. private _createCustom;
  55952. private _addHullVerts;
  55953. private _createShape;
  55954. /**
  55955. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55956. * @param impostor imposter containing the physics body and babylon object
  55957. */
  55958. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55959. /**
  55960. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55961. * @param impostor imposter containing the physics body and babylon object
  55962. * @param newPosition new position
  55963. * @param newRotation new rotation
  55964. */
  55965. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55966. /**
  55967. * If this plugin is supported
  55968. * @returns true if its supported
  55969. */
  55970. isSupported(): boolean;
  55971. /**
  55972. * Sets the linear velocity of the physics body
  55973. * @param impostor imposter to set the velocity on
  55974. * @param velocity velocity to set
  55975. */
  55976. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55977. /**
  55978. * Sets the angular velocity of the physics body
  55979. * @param impostor imposter to set the velocity on
  55980. * @param velocity velocity to set
  55981. */
  55982. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55983. /**
  55984. * gets the linear velocity
  55985. * @param impostor imposter to get linear velocity from
  55986. * @returns linear velocity
  55987. */
  55988. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55989. /**
  55990. * gets the angular velocity
  55991. * @param impostor imposter to get angular velocity from
  55992. * @returns angular velocity
  55993. */
  55994. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55995. /**
  55996. * Sets the mass of physics body
  55997. * @param impostor imposter to set the mass on
  55998. * @param mass mass to set
  55999. */
  56000. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56001. /**
  56002. * Gets the mass of the physics body
  56003. * @param impostor imposter to get the mass from
  56004. * @returns mass
  56005. */
  56006. getBodyMass(impostor: PhysicsImpostor): number;
  56007. /**
  56008. * Gets friction of the impostor
  56009. * @param impostor impostor to get friction from
  56010. * @returns friction value
  56011. */
  56012. getBodyFriction(impostor: PhysicsImpostor): number;
  56013. /**
  56014. * Sets friction of the impostor
  56015. * @param impostor impostor to set friction on
  56016. * @param friction friction value
  56017. */
  56018. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56019. /**
  56020. * Gets restitution of the impostor
  56021. * @param impostor impostor to get restitution from
  56022. * @returns restitution value
  56023. */
  56024. getBodyRestitution(impostor: PhysicsImpostor): number;
  56025. /**
  56026. * Sets resitution of the impostor
  56027. * @param impostor impostor to set resitution on
  56028. * @param restitution resitution value
  56029. */
  56030. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56031. /**
  56032. * Gets pressure inside the impostor
  56033. * @param impostor impostor to get pressure from
  56034. * @returns pressure value
  56035. */
  56036. getBodyPressure(impostor: PhysicsImpostor): number;
  56037. /**
  56038. * Sets pressure inside a soft body impostor
  56039. * Cloth and rope must remain 0 pressure
  56040. * @param impostor impostor to set pressure on
  56041. * @param pressure pressure value
  56042. */
  56043. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56044. /**
  56045. * Gets stiffness of the impostor
  56046. * @param impostor impostor to get stiffness from
  56047. * @returns pressure value
  56048. */
  56049. getBodyStiffness(impostor: PhysicsImpostor): number;
  56050. /**
  56051. * Sets stiffness of the impostor
  56052. * @param impostor impostor to set stiffness on
  56053. * @param stiffness stiffness value from 0 to 1
  56054. */
  56055. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56056. /**
  56057. * Gets velocityIterations of the impostor
  56058. * @param impostor impostor to get velocity iterations from
  56059. * @returns velocityIterations value
  56060. */
  56061. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56062. /**
  56063. * Sets velocityIterations of the impostor
  56064. * @param impostor impostor to set velocity iterations on
  56065. * @param velocityIterations velocityIterations value
  56066. */
  56067. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56068. /**
  56069. * Gets positionIterations of the impostor
  56070. * @param impostor impostor to get position iterations from
  56071. * @returns positionIterations value
  56072. */
  56073. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56074. /**
  56075. * Sets positionIterations of the impostor
  56076. * @param impostor impostor to set position on
  56077. * @param positionIterations positionIterations value
  56078. */
  56079. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56080. /**
  56081. * Append an anchor to a cloth object
  56082. * @param impostor is the cloth impostor to add anchor to
  56083. * @param otherImpostor is the rigid impostor to anchor to
  56084. * @param width ratio across width from 0 to 1
  56085. * @param height ratio up height from 0 to 1
  56086. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56088. */
  56089. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56090. /**
  56091. * Append an hook to a rope object
  56092. * @param impostor is the rope impostor to add hook to
  56093. * @param otherImpostor is the rigid impostor to hook to
  56094. * @param length ratio along the rope from 0 to 1
  56095. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56096. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56097. */
  56098. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56099. /**
  56100. * Sleeps the physics body and stops it from being active
  56101. * @param impostor impostor to sleep
  56102. */
  56103. sleepBody(impostor: PhysicsImpostor): void;
  56104. /**
  56105. * Activates the physics body
  56106. * @param impostor impostor to activate
  56107. */
  56108. wakeUpBody(impostor: PhysicsImpostor): void;
  56109. /**
  56110. * Updates the distance parameters of the joint
  56111. * @param joint joint to update
  56112. * @param maxDistance maximum distance of the joint
  56113. * @param minDistance minimum distance of the joint
  56114. */
  56115. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56116. /**
  56117. * Sets a motor on the joint
  56118. * @param joint joint to set motor on
  56119. * @param speed speed of the motor
  56120. * @param maxForce maximum force of the motor
  56121. * @param motorIndex index of the motor
  56122. */
  56123. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56124. /**
  56125. * Sets the motors limit
  56126. * @param joint joint to set limit on
  56127. * @param upperLimit upper limit
  56128. * @param lowerLimit lower limit
  56129. */
  56130. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56131. /**
  56132. * Syncs the position and rotation of a mesh with the impostor
  56133. * @param mesh mesh to sync
  56134. * @param impostor impostor to update the mesh with
  56135. */
  56136. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56137. /**
  56138. * Gets the radius of the impostor
  56139. * @param impostor impostor to get radius from
  56140. * @returns the radius
  56141. */
  56142. getRadius(impostor: PhysicsImpostor): number;
  56143. /**
  56144. * Gets the box size of the impostor
  56145. * @param impostor impostor to get box size from
  56146. * @param result the resulting box size
  56147. */
  56148. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56149. /**
  56150. * Disposes of the impostor
  56151. */
  56152. dispose(): void;
  56153. /**
  56154. * Does a raycast in the physics world
  56155. * @param from when should the ray start?
  56156. * @param to when should the ray end?
  56157. * @returns PhysicsRaycastResult
  56158. */
  56159. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56160. }
  56161. }
  56162. declare module BABYLON {
  56163. interface AbstractScene {
  56164. /**
  56165. * The list of reflection probes added to the scene
  56166. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56167. */
  56168. reflectionProbes: Array<ReflectionProbe>;
  56169. /**
  56170. * Removes the given reflection probe from this scene.
  56171. * @param toRemove The reflection probe to remove
  56172. * @returns The index of the removed reflection probe
  56173. */
  56174. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56175. /**
  56176. * Adds the given reflection probe to this scene.
  56177. * @param newReflectionProbe The reflection probe to add
  56178. */
  56179. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56180. }
  56181. /**
  56182. * Class used to generate realtime reflection / refraction cube textures
  56183. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56184. */
  56185. export class ReflectionProbe {
  56186. /** defines the name of the probe */
  56187. name: string;
  56188. private _scene;
  56189. private _renderTargetTexture;
  56190. private _projectionMatrix;
  56191. private _viewMatrix;
  56192. private _target;
  56193. private _add;
  56194. private _attachedMesh;
  56195. private _invertYAxis;
  56196. /** Gets or sets probe position (center of the cube map) */
  56197. position: Vector3;
  56198. /**
  56199. * Creates a new reflection probe
  56200. * @param name defines the name of the probe
  56201. * @param size defines the texture resolution (for each face)
  56202. * @param scene defines the hosting scene
  56203. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56204. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56205. */
  56206. constructor(
  56207. /** defines the name of the probe */
  56208. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56209. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56210. get samples(): number;
  56211. set samples(value: number);
  56212. /** Gets or sets the refresh rate to use (on every frame by default) */
  56213. get refreshRate(): number;
  56214. set refreshRate(value: number);
  56215. /**
  56216. * Gets the hosting scene
  56217. * @returns a Scene
  56218. */
  56219. getScene(): Scene;
  56220. /** Gets the internal CubeTexture used to render to */
  56221. get cubeTexture(): RenderTargetTexture;
  56222. /** Gets the list of meshes to render */
  56223. get renderList(): Nullable<AbstractMesh[]>;
  56224. /**
  56225. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56226. * @param mesh defines the mesh to attach to
  56227. */
  56228. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56229. /**
  56230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56231. * @param renderingGroupId The rendering group id corresponding to its index
  56232. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56233. */
  56234. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56235. /**
  56236. * Clean all associated resources
  56237. */
  56238. dispose(): void;
  56239. /**
  56240. * Converts the reflection probe information to a readable string for debug purpose.
  56241. * @param fullDetails Supports for multiple levels of logging within scene loading
  56242. * @returns the human readable reflection probe info
  56243. */
  56244. toString(fullDetails?: boolean): string;
  56245. /**
  56246. * Get the class name of the relfection probe.
  56247. * @returns "ReflectionProbe"
  56248. */
  56249. getClassName(): string;
  56250. /**
  56251. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56252. * @returns The JSON representation of the texture
  56253. */
  56254. serialize(): any;
  56255. /**
  56256. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56257. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56258. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56259. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56260. * @returns The parsed reflection probe if successful
  56261. */
  56262. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56263. }
  56264. }
  56265. declare module BABYLON {
  56266. /** @hidden */
  56267. export var _BabylonLoaderRegistered: boolean;
  56268. /**
  56269. * Helps setting up some configuration for the babylon file loader.
  56270. */
  56271. export class BabylonFileLoaderConfiguration {
  56272. /**
  56273. * The loader does not allow injecting custom physix engine into the plugins.
  56274. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56275. * So you could set this variable to your engine import to make it work.
  56276. */
  56277. static LoaderInjectedPhysicsEngine: any;
  56278. }
  56279. }
  56280. declare module BABYLON {
  56281. /**
  56282. * The Physically based simple base material of BJS.
  56283. *
  56284. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56285. * It is used as the base class for both the specGloss and metalRough conventions.
  56286. */
  56287. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56288. /**
  56289. * Number of Simultaneous lights allowed on the material.
  56290. */
  56291. maxSimultaneousLights: number;
  56292. /**
  56293. * If sets to true, disables all the lights affecting the material.
  56294. */
  56295. disableLighting: boolean;
  56296. /**
  56297. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56298. */
  56299. environmentTexture: BaseTexture;
  56300. /**
  56301. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56302. */
  56303. invertNormalMapX: boolean;
  56304. /**
  56305. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56306. */
  56307. invertNormalMapY: boolean;
  56308. /**
  56309. * Normal map used in the model.
  56310. */
  56311. normalTexture: BaseTexture;
  56312. /**
  56313. * Emissivie color used to self-illuminate the model.
  56314. */
  56315. emissiveColor: Color3;
  56316. /**
  56317. * Emissivie texture used to self-illuminate the model.
  56318. */
  56319. emissiveTexture: BaseTexture;
  56320. /**
  56321. * Occlusion Channel Strenght.
  56322. */
  56323. occlusionStrength: number;
  56324. /**
  56325. * Occlusion Texture of the material (adding extra occlusion effects).
  56326. */
  56327. occlusionTexture: BaseTexture;
  56328. /**
  56329. * Defines the alpha limits in alpha test mode.
  56330. */
  56331. alphaCutOff: number;
  56332. /**
  56333. * Gets the current double sided mode.
  56334. */
  56335. get doubleSided(): boolean;
  56336. /**
  56337. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56338. */
  56339. set doubleSided(value: boolean);
  56340. /**
  56341. * Stores the pre-calculated light information of a mesh in a texture.
  56342. */
  56343. lightmapTexture: BaseTexture;
  56344. /**
  56345. * If true, the light map contains occlusion information instead of lighting info.
  56346. */
  56347. useLightmapAsShadowmap: boolean;
  56348. /**
  56349. * Instantiates a new PBRMaterial instance.
  56350. *
  56351. * @param name The material name
  56352. * @param scene The scene the material will be use in.
  56353. */
  56354. constructor(name: string, scene: Scene);
  56355. getClassName(): string;
  56356. }
  56357. }
  56358. declare module BABYLON {
  56359. /**
  56360. * The PBR material of BJS following the metal roughness convention.
  56361. *
  56362. * This fits to the PBR convention in the GLTF definition:
  56363. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56364. */
  56365. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56366. /**
  56367. * The base color has two different interpretations depending on the value of metalness.
  56368. * When the material is a metal, the base color is the specific measured reflectance value
  56369. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56370. * of the material.
  56371. */
  56372. baseColor: Color3;
  56373. /**
  56374. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56375. * well as opacity information in the alpha channel.
  56376. */
  56377. baseTexture: BaseTexture;
  56378. /**
  56379. * Specifies the metallic scalar value of the material.
  56380. * Can also be used to scale the metalness values of the metallic texture.
  56381. */
  56382. metallic: number;
  56383. /**
  56384. * Specifies the roughness scalar value of the material.
  56385. * Can also be used to scale the roughness values of the metallic texture.
  56386. */
  56387. roughness: number;
  56388. /**
  56389. * Texture containing both the metallic value in the B channel and the
  56390. * roughness value in the G channel to keep better precision.
  56391. */
  56392. metallicRoughnessTexture: BaseTexture;
  56393. /**
  56394. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56395. *
  56396. * @param name The material name
  56397. * @param scene The scene the material will be use in.
  56398. */
  56399. constructor(name: string, scene: Scene);
  56400. /**
  56401. * Return the currrent class name of the material.
  56402. */
  56403. getClassName(): string;
  56404. /**
  56405. * Makes a duplicate of the current material.
  56406. * @param name - name to use for the new material.
  56407. */
  56408. clone(name: string): PBRMetallicRoughnessMaterial;
  56409. /**
  56410. * Serialize the material to a parsable JSON object.
  56411. */
  56412. serialize(): any;
  56413. /**
  56414. * Parses a JSON object correponding to the serialize function.
  56415. */
  56416. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56417. }
  56418. }
  56419. declare module BABYLON {
  56420. /**
  56421. * The PBR material of BJS following the specular glossiness convention.
  56422. *
  56423. * This fits to the PBR convention in the GLTF definition:
  56424. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56425. */
  56426. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56427. /**
  56428. * Specifies the diffuse color of the material.
  56429. */
  56430. diffuseColor: Color3;
  56431. /**
  56432. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56433. * channel.
  56434. */
  56435. diffuseTexture: BaseTexture;
  56436. /**
  56437. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56438. */
  56439. specularColor: Color3;
  56440. /**
  56441. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56442. */
  56443. glossiness: number;
  56444. /**
  56445. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56446. */
  56447. specularGlossinessTexture: BaseTexture;
  56448. /**
  56449. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56450. *
  56451. * @param name The material name
  56452. * @param scene The scene the material will be use in.
  56453. */
  56454. constructor(name: string, scene: Scene);
  56455. /**
  56456. * Return the currrent class name of the material.
  56457. */
  56458. getClassName(): string;
  56459. /**
  56460. * Makes a duplicate of the current material.
  56461. * @param name - name to use for the new material.
  56462. */
  56463. clone(name: string): PBRSpecularGlossinessMaterial;
  56464. /**
  56465. * Serialize the material to a parsable JSON object.
  56466. */
  56467. serialize(): any;
  56468. /**
  56469. * Parses a JSON object correponding to the serialize function.
  56470. */
  56471. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56472. }
  56473. }
  56474. declare module BABYLON {
  56475. /**
  56476. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56477. * It can help converting any input color in a desired output one. This can then be used to create effects
  56478. * from sepia, black and white to sixties or futuristic rendering...
  56479. *
  56480. * The only supported format is currently 3dl.
  56481. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56482. */
  56483. export class ColorGradingTexture extends BaseTexture {
  56484. /**
  56485. * The texture URL.
  56486. */
  56487. url: string;
  56488. /**
  56489. * Empty line regex stored for GC.
  56490. */
  56491. private static _noneEmptyLineRegex;
  56492. private _textureMatrix;
  56493. private _engine;
  56494. private _onLoad;
  56495. /**
  56496. * Instantiates a ColorGradingTexture from the following parameters.
  56497. *
  56498. * @param url The location of the color gradind data (currently only supporting 3dl)
  56499. * @param sceneOrEngine The scene or engine the texture will be used in
  56500. * @param onLoad defines a callback triggered when the texture has been loaded
  56501. */
  56502. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56503. /**
  56504. * Fires the onload event from the constructor if requested.
  56505. */
  56506. private _triggerOnLoad;
  56507. /**
  56508. * Returns the texture matrix used in most of the material.
  56509. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56510. */
  56511. getTextureMatrix(): Matrix;
  56512. /**
  56513. * Occurs when the file being loaded is a .3dl LUT file.
  56514. */
  56515. private load3dlTexture;
  56516. /**
  56517. * Starts the loading process of the texture.
  56518. */
  56519. private loadTexture;
  56520. /**
  56521. * Clones the color gradind texture.
  56522. */
  56523. clone(): ColorGradingTexture;
  56524. /**
  56525. * Called during delayed load for textures.
  56526. */
  56527. delayLoad(): void;
  56528. /**
  56529. * Parses a color grading texture serialized by Babylon.
  56530. * @param parsedTexture The texture information being parsedTexture
  56531. * @param scene The scene to load the texture in
  56532. * @param rootUrl The root url of the data assets to load
  56533. * @return A color gradind texture
  56534. */
  56535. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56536. /**
  56537. * Serializes the LUT texture to json format.
  56538. */
  56539. serialize(): any;
  56540. /**
  56541. * Returns true if the passed parameter is a scene object (can be use for typings)
  56542. * @param sceneOrEngine The object to test.
  56543. */
  56544. private static _isScene;
  56545. }
  56546. }
  56547. declare module BABYLON {
  56548. /**
  56549. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56550. */
  56551. export class EquiRectangularCubeTexture extends BaseTexture {
  56552. /** The six faces of the cube. */
  56553. private static _FacesMapping;
  56554. private _noMipmap;
  56555. private _onLoad;
  56556. private _onError;
  56557. /** The size of the cubemap. */
  56558. private _size;
  56559. /** The buffer of the image. */
  56560. private _buffer;
  56561. /** The width of the input image. */
  56562. private _width;
  56563. /** The height of the input image. */
  56564. private _height;
  56565. /** The URL to the image. */
  56566. url: string;
  56567. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56568. coordinatesMode: number;
  56569. /**
  56570. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56571. * @param url The location of the image
  56572. * @param scene The scene the texture will be used in
  56573. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56574. * @param noMipmap Forces to not generate the mipmap if true
  56575. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56576. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56577. * @param onLoad — defines a callback called when texture is loaded
  56578. * @param onError — defines a callback called if there is an error
  56579. */
  56580. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56581. /**
  56582. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56583. */
  56584. private loadImage;
  56585. /**
  56586. * Convert the image buffer into a cubemap and create a CubeTexture.
  56587. */
  56588. private loadTexture;
  56589. /**
  56590. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56591. * @param buffer The ArrayBuffer that should be converted.
  56592. * @returns The buffer as Float32Array.
  56593. */
  56594. private getFloat32ArrayFromArrayBuffer;
  56595. /**
  56596. * Get the current class name of the texture useful for serialization or dynamic coding.
  56597. * @returns "EquiRectangularCubeTexture"
  56598. */
  56599. getClassName(): string;
  56600. /**
  56601. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56602. * @returns A clone of the current EquiRectangularCubeTexture.
  56603. */
  56604. clone(): EquiRectangularCubeTexture;
  56605. }
  56606. }
  56607. declare module BABYLON {
  56608. /**
  56609. * Based on jsTGALoader - Javascript loader for TGA file
  56610. * By Vincent Thibault
  56611. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56612. */
  56613. export class TGATools {
  56614. private static _TYPE_INDEXED;
  56615. private static _TYPE_RGB;
  56616. private static _TYPE_GREY;
  56617. private static _TYPE_RLE_INDEXED;
  56618. private static _TYPE_RLE_RGB;
  56619. private static _TYPE_RLE_GREY;
  56620. private static _ORIGIN_MASK;
  56621. private static _ORIGIN_SHIFT;
  56622. private static _ORIGIN_BL;
  56623. private static _ORIGIN_BR;
  56624. private static _ORIGIN_UL;
  56625. private static _ORIGIN_UR;
  56626. /**
  56627. * Gets the header of a TGA file
  56628. * @param data defines the TGA data
  56629. * @returns the header
  56630. */
  56631. static GetTGAHeader(data: Uint8Array): any;
  56632. /**
  56633. * Uploads TGA content to a Babylon Texture
  56634. * @hidden
  56635. */
  56636. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56637. /** @hidden */
  56638. 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;
  56639. /** @hidden */
  56640. 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;
  56641. /** @hidden */
  56642. 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;
  56643. /** @hidden */
  56644. 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;
  56645. /** @hidden */
  56646. 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;
  56647. /** @hidden */
  56648. 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;
  56649. }
  56650. }
  56651. declare module BABYLON {
  56652. /**
  56653. * Implementation of the TGA Texture Loader.
  56654. * @hidden
  56655. */
  56656. export class _TGATextureLoader implements IInternalTextureLoader {
  56657. /**
  56658. * Defines wether the loader supports cascade loading the different faces.
  56659. */
  56660. readonly supportCascades: boolean;
  56661. /**
  56662. * This returns if the loader support the current file information.
  56663. * @param extension defines the file extension of the file being loaded
  56664. * @returns true if the loader can load the specified file
  56665. */
  56666. canLoad(extension: string): boolean;
  56667. /**
  56668. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56669. * @param data contains the texture data
  56670. * @param texture defines the BabylonJS internal texture
  56671. * @param createPolynomials will be true if polynomials have been requested
  56672. * @param onLoad defines the callback to trigger once the texture is ready
  56673. * @param onError defines the callback to trigger in case of error
  56674. */
  56675. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56676. /**
  56677. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56678. * @param data contains the texture data
  56679. * @param texture defines the BabylonJS internal texture
  56680. * @param callback defines the method to call once ready to upload
  56681. */
  56682. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56683. }
  56684. }
  56685. declare module BABYLON {
  56686. /**
  56687. * Info about the .basis files
  56688. */
  56689. class BasisFileInfo {
  56690. /**
  56691. * If the file has alpha
  56692. */
  56693. hasAlpha: boolean;
  56694. /**
  56695. * Info about each image of the basis file
  56696. */
  56697. images: Array<{
  56698. levels: Array<{
  56699. width: number;
  56700. height: number;
  56701. transcodedPixels: ArrayBufferView;
  56702. }>;
  56703. }>;
  56704. }
  56705. /**
  56706. * Result of transcoding a basis file
  56707. */
  56708. class TranscodeResult {
  56709. /**
  56710. * Info about the .basis file
  56711. */
  56712. fileInfo: BasisFileInfo;
  56713. /**
  56714. * Format to use when loading the file
  56715. */
  56716. format: number;
  56717. }
  56718. /**
  56719. * Configuration options for the Basis transcoder
  56720. */
  56721. export class BasisTranscodeConfiguration {
  56722. /**
  56723. * Supported compression formats used to determine the supported output format of the transcoder
  56724. */
  56725. supportedCompressionFormats?: {
  56726. /**
  56727. * etc1 compression format
  56728. */
  56729. etc1?: boolean;
  56730. /**
  56731. * s3tc compression format
  56732. */
  56733. s3tc?: boolean;
  56734. /**
  56735. * pvrtc compression format
  56736. */
  56737. pvrtc?: boolean;
  56738. /**
  56739. * etc2 compression format
  56740. */
  56741. etc2?: boolean;
  56742. };
  56743. /**
  56744. * If mipmap levels should be loaded for transcoded images (Default: true)
  56745. */
  56746. loadMipmapLevels?: boolean;
  56747. /**
  56748. * Index of a single image to load (Default: all images)
  56749. */
  56750. loadSingleImage?: number;
  56751. }
  56752. /**
  56753. * Used to load .Basis files
  56754. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56755. */
  56756. export class BasisTools {
  56757. private static _IgnoreSupportedFormats;
  56758. /**
  56759. * URL to use when loading the basis transcoder
  56760. */
  56761. static JSModuleURL: string;
  56762. /**
  56763. * URL to use when loading the wasm module for the transcoder
  56764. */
  56765. static WasmModuleURL: string;
  56766. /**
  56767. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56768. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56769. * @returns internal format corresponding to the Basis format
  56770. */
  56771. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56772. private static _WorkerPromise;
  56773. private static _Worker;
  56774. private static _actionId;
  56775. private static _CreateWorkerAsync;
  56776. /**
  56777. * Transcodes a loaded image file to compressed pixel data
  56778. * @param data image data to transcode
  56779. * @param config configuration options for the transcoding
  56780. * @returns a promise resulting in the transcoded image
  56781. */
  56782. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56783. /**
  56784. * Loads a texture from the transcode result
  56785. * @param texture texture load to
  56786. * @param transcodeResult the result of transcoding the basis file to load from
  56787. */
  56788. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56789. }
  56790. }
  56791. declare module BABYLON {
  56792. /**
  56793. * Loader for .basis file format
  56794. */
  56795. export class _BasisTextureLoader implements IInternalTextureLoader {
  56796. /**
  56797. * Defines whether the loader supports cascade loading the different faces.
  56798. */
  56799. readonly supportCascades: boolean;
  56800. /**
  56801. * This returns if the loader support the current file information.
  56802. * @param extension defines the file extension of the file being loaded
  56803. * @returns true if the loader can load the specified file
  56804. */
  56805. canLoad(extension: string): boolean;
  56806. /**
  56807. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56808. * @param data contains the texture data
  56809. * @param texture defines the BabylonJS internal texture
  56810. * @param createPolynomials will be true if polynomials have been requested
  56811. * @param onLoad defines the callback to trigger once the texture is ready
  56812. * @param onError defines the callback to trigger in case of error
  56813. */
  56814. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56815. /**
  56816. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56817. * @param data contains the texture data
  56818. * @param texture defines the BabylonJS internal texture
  56819. * @param callback defines the method to call once ready to upload
  56820. */
  56821. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56822. }
  56823. }
  56824. declare module BABYLON {
  56825. /**
  56826. * 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.
  56827. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56828. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56829. */
  56830. export class CustomProceduralTexture extends ProceduralTexture {
  56831. private _animate;
  56832. private _time;
  56833. private _config;
  56834. private _texturePath;
  56835. /**
  56836. * Instantiates a new Custom Procedural Texture.
  56837. * 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.
  56838. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56839. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56840. * @param name Define the name of the texture
  56841. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56842. * @param size Define the size of the texture to create
  56843. * @param scene Define the scene the texture belongs to
  56844. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56845. * @param generateMipMaps Define if the texture should creates mip maps or not
  56846. */
  56847. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56848. private _loadJson;
  56849. /**
  56850. * Is the texture ready to be used ? (rendered at least once)
  56851. * @returns true if ready, otherwise, false.
  56852. */
  56853. isReady(): boolean;
  56854. /**
  56855. * Render the texture to its associated render target.
  56856. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56857. */
  56858. render(useCameraPostProcess?: boolean): void;
  56859. /**
  56860. * Update the list of dependant textures samplers in the shader.
  56861. */
  56862. updateTextures(): void;
  56863. /**
  56864. * Update the uniform values of the procedural texture in the shader.
  56865. */
  56866. updateShaderUniforms(): void;
  56867. /**
  56868. * Define if the texture animates or not.
  56869. */
  56870. get animate(): boolean;
  56871. set animate(value: boolean);
  56872. }
  56873. }
  56874. declare module BABYLON {
  56875. /** @hidden */
  56876. export var noisePixelShader: {
  56877. name: string;
  56878. shader: string;
  56879. };
  56880. }
  56881. declare module BABYLON {
  56882. /**
  56883. * Class used to generate noise procedural textures
  56884. */
  56885. export class NoiseProceduralTexture extends ProceduralTexture {
  56886. private _time;
  56887. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56888. brightness: number;
  56889. /** Defines the number of octaves to process */
  56890. octaves: number;
  56891. /** Defines the level of persistence (0.8 by default) */
  56892. persistence: number;
  56893. /** Gets or sets animation speed factor (default is 1) */
  56894. animationSpeedFactor: number;
  56895. /**
  56896. * Creates a new NoiseProceduralTexture
  56897. * @param name defines the name fo the texture
  56898. * @param size defines the size of the texture (default is 256)
  56899. * @param scene defines the hosting scene
  56900. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56901. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56902. */
  56903. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56904. private _updateShaderUniforms;
  56905. protected _getDefines(): string;
  56906. /** Generate the current state of the procedural texture */
  56907. render(useCameraPostProcess?: boolean): void;
  56908. /**
  56909. * Serializes this noise procedural texture
  56910. * @returns a serialized noise procedural texture object
  56911. */
  56912. serialize(): any;
  56913. /**
  56914. * Clone the texture.
  56915. * @returns the cloned texture
  56916. */
  56917. clone(): NoiseProceduralTexture;
  56918. /**
  56919. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56920. * @param parsedTexture defines parsed texture data
  56921. * @param scene defines the current scene
  56922. * @param rootUrl defines the root URL containing noise procedural texture information
  56923. * @returns a parsed NoiseProceduralTexture
  56924. */
  56925. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56926. }
  56927. }
  56928. declare module BABYLON {
  56929. /**
  56930. * Raw cube texture where the raw buffers are passed in
  56931. */
  56932. export class RawCubeTexture extends CubeTexture {
  56933. /**
  56934. * Creates a cube texture where the raw buffers are passed in.
  56935. * @param scene defines the scene the texture is attached to
  56936. * @param data defines the array of data to use to create each face
  56937. * @param size defines the size of the textures
  56938. * @param format defines the format of the data
  56939. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56940. * @param generateMipMaps defines if the engine should generate the mip levels
  56941. * @param invertY defines if data must be stored with Y axis inverted
  56942. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56943. * @param compression defines the compression used (null by default)
  56944. */
  56945. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56946. /**
  56947. * Updates the raw cube texture.
  56948. * @param data defines the data to store
  56949. * @param format defines the data format
  56950. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56951. * @param invertY defines if data must be stored with Y axis inverted
  56952. * @param compression defines the compression used (null by default)
  56953. * @param level defines which level of the texture to update
  56954. */
  56955. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56956. /**
  56957. * Updates a raw cube texture with RGBD encoded data.
  56958. * @param data defines the array of data [mipmap][face] to use to create each face
  56959. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56960. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56961. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56962. * @returns a promsie that resolves when the operation is complete
  56963. */
  56964. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56965. /**
  56966. * Clones the raw cube texture.
  56967. * @return a new cube texture
  56968. */
  56969. clone(): CubeTexture;
  56970. /** @hidden */
  56971. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56972. }
  56973. }
  56974. declare module BABYLON {
  56975. /**
  56976. * Class used to store 3D textures containing user data
  56977. */
  56978. export class RawTexture3D extends Texture {
  56979. /** Gets or sets the texture format to use */
  56980. format: number;
  56981. private _engine;
  56982. /**
  56983. * Create a new RawTexture3D
  56984. * @param data defines the data of the texture
  56985. * @param width defines the width of the texture
  56986. * @param height defines the height of the texture
  56987. * @param depth defines the depth of the texture
  56988. * @param format defines the texture format to use
  56989. * @param scene defines the hosting scene
  56990. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56991. * @param invertY defines if texture must be stored with Y axis inverted
  56992. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56993. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56994. */
  56995. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56996. /** Gets or sets the texture format to use */
  56997. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56998. /**
  56999. * Update the texture with new data
  57000. * @param data defines the data to store in the texture
  57001. */
  57002. update(data: ArrayBufferView): void;
  57003. }
  57004. }
  57005. declare module BABYLON {
  57006. /**
  57007. * Class used to store 2D array textures containing user data
  57008. */
  57009. export class RawTexture2DArray extends Texture {
  57010. /** Gets or sets the texture format to use */
  57011. format: number;
  57012. private _engine;
  57013. /**
  57014. * Create a new RawTexture2DArray
  57015. * @param data defines the data of the texture
  57016. * @param width defines the width of the texture
  57017. * @param height defines the height of the texture
  57018. * @param depth defines the number of layers of the texture
  57019. * @param format defines the texture format to use
  57020. * @param scene defines the hosting scene
  57021. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57022. * @param invertY defines if texture must be stored with Y axis inverted
  57023. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57024. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57025. */
  57026. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57027. /** Gets or sets the texture format to use */
  57028. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57029. /**
  57030. * Update the texture with new data
  57031. * @param data defines the data to store in the texture
  57032. */
  57033. update(data: ArrayBufferView): void;
  57034. }
  57035. }
  57036. declare module BABYLON {
  57037. /**
  57038. * Creates a refraction texture used by refraction channel of the standard material.
  57039. * It is like a mirror but to see through a material.
  57040. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57041. */
  57042. export class RefractionTexture extends RenderTargetTexture {
  57043. /**
  57044. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57045. * 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.
  57046. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57047. */
  57048. refractionPlane: Plane;
  57049. /**
  57050. * Define how deep under the surface we should see.
  57051. */
  57052. depth: number;
  57053. /**
  57054. * Creates a refraction texture used by refraction channel of the standard material.
  57055. * It is like a mirror but to see through a material.
  57056. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57057. * @param name Define the texture name
  57058. * @param size Define the size of the underlying texture
  57059. * @param scene Define the scene the refraction belongs to
  57060. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57061. */
  57062. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57063. /**
  57064. * Clone the refraction texture.
  57065. * @returns the cloned texture
  57066. */
  57067. clone(): RefractionTexture;
  57068. /**
  57069. * Serialize the texture to a JSON representation you could use in Parse later on
  57070. * @returns the serialized JSON representation
  57071. */
  57072. serialize(): any;
  57073. }
  57074. }
  57075. declare module BABYLON {
  57076. /**
  57077. * Defines the options related to the creation of an HtmlElementTexture
  57078. */
  57079. export interface IHtmlElementTextureOptions {
  57080. /**
  57081. * Defines wether mip maps should be created or not.
  57082. */
  57083. generateMipMaps?: boolean;
  57084. /**
  57085. * Defines the sampling mode of the texture.
  57086. */
  57087. samplingMode?: number;
  57088. /**
  57089. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57090. */
  57091. engine: Nullable<ThinEngine>;
  57092. /**
  57093. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57094. */
  57095. scene: Nullable<Scene>;
  57096. }
  57097. /**
  57098. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57099. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57100. * is automatically managed.
  57101. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57102. * in your application.
  57103. *
  57104. * As the update is not automatic, you need to call them manually.
  57105. */
  57106. export class HtmlElementTexture extends BaseTexture {
  57107. /**
  57108. * The texture URL.
  57109. */
  57110. element: HTMLVideoElement | HTMLCanvasElement;
  57111. private static readonly DefaultOptions;
  57112. private _textureMatrix;
  57113. private _engine;
  57114. private _isVideo;
  57115. private _generateMipMaps;
  57116. private _samplingMode;
  57117. /**
  57118. * Instantiates a HtmlElementTexture from the following parameters.
  57119. *
  57120. * @param name Defines the name of the texture
  57121. * @param element Defines the video or canvas the texture is filled with
  57122. * @param options Defines the other none mandatory texture creation options
  57123. */
  57124. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57125. private _createInternalTexture;
  57126. /**
  57127. * Returns the texture matrix used in most of the material.
  57128. */
  57129. getTextureMatrix(): Matrix;
  57130. /**
  57131. * Updates the content of the texture.
  57132. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57133. */
  57134. update(invertY?: Nullable<boolean>): void;
  57135. }
  57136. }
  57137. declare module BABYLON {
  57138. /**
  57139. * Defines the basic options interface of a TexturePacker Frame
  57140. */
  57141. export interface ITexturePackerFrame {
  57142. /**
  57143. * The frame ID
  57144. */
  57145. id: number;
  57146. /**
  57147. * The frames Scale
  57148. */
  57149. scale: Vector2;
  57150. /**
  57151. * The Frames offset
  57152. */
  57153. offset: Vector2;
  57154. }
  57155. /**
  57156. * This is a support class for frame Data on texture packer sets.
  57157. */
  57158. export class TexturePackerFrame implements ITexturePackerFrame {
  57159. /**
  57160. * The frame ID
  57161. */
  57162. id: number;
  57163. /**
  57164. * The frames Scale
  57165. */
  57166. scale: Vector2;
  57167. /**
  57168. * The Frames offset
  57169. */
  57170. offset: Vector2;
  57171. /**
  57172. * Initializes a texture package frame.
  57173. * @param id The numerical frame identifier
  57174. * @param scale Scalar Vector2 for UV frame
  57175. * @param offset Vector2 for the frame position in UV units.
  57176. * @returns TexturePackerFrame
  57177. */
  57178. constructor(id: number, scale: Vector2, offset: Vector2);
  57179. }
  57180. }
  57181. declare module BABYLON {
  57182. /**
  57183. * Defines the basic options interface of a TexturePacker
  57184. */
  57185. export interface ITexturePackerOptions {
  57186. /**
  57187. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57188. */
  57189. map?: string[];
  57190. /**
  57191. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57192. */
  57193. uvsIn?: string;
  57194. /**
  57195. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57196. */
  57197. uvsOut?: string;
  57198. /**
  57199. * number representing the layout style. Defaults to LAYOUT_STRIP
  57200. */
  57201. layout?: number;
  57202. /**
  57203. * number of columns if using custom column count layout(2). This defaults to 4.
  57204. */
  57205. colnum?: number;
  57206. /**
  57207. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57208. */
  57209. updateInputMeshes?: boolean;
  57210. /**
  57211. * boolean flag to dispose all the source textures. Defaults to true.
  57212. */
  57213. disposeSources?: boolean;
  57214. /**
  57215. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57216. */
  57217. fillBlanks?: boolean;
  57218. /**
  57219. * string value representing the context fill style color. Defaults to 'black'.
  57220. */
  57221. customFillColor?: string;
  57222. /**
  57223. * Width and Height Value of each Frame in the TexturePacker Sets
  57224. */
  57225. frameSize?: number;
  57226. /**
  57227. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57228. */
  57229. paddingRatio?: number;
  57230. /**
  57231. * Number that declares the fill method for the padding gutter.
  57232. */
  57233. paddingMode?: number;
  57234. /**
  57235. * If in SUBUV_COLOR padding mode what color to use.
  57236. */
  57237. paddingColor?: Color3 | Color4;
  57238. }
  57239. /**
  57240. * Defines the basic interface of a TexturePacker JSON File
  57241. */
  57242. export interface ITexturePackerJSON {
  57243. /**
  57244. * The frame ID
  57245. */
  57246. name: string;
  57247. /**
  57248. * The base64 channel data
  57249. */
  57250. sets: any;
  57251. /**
  57252. * The options of the Packer
  57253. */
  57254. options: ITexturePackerOptions;
  57255. /**
  57256. * The frame data of the Packer
  57257. */
  57258. frames: Array<number>;
  57259. }
  57260. /**
  57261. * This is a support class that generates a series of packed texture sets.
  57262. * @see https://doc.babylonjs.com/babylon101/materials
  57263. */
  57264. export class TexturePacker {
  57265. /** Packer Layout Constant 0 */
  57266. static readonly LAYOUT_STRIP: number;
  57267. /** Packer Layout Constant 1 */
  57268. static readonly LAYOUT_POWER2: number;
  57269. /** Packer Layout Constant 2 */
  57270. static readonly LAYOUT_COLNUM: number;
  57271. /** Packer Layout Constant 0 */
  57272. static readonly SUBUV_WRAP: number;
  57273. /** Packer Layout Constant 1 */
  57274. static readonly SUBUV_EXTEND: number;
  57275. /** Packer Layout Constant 2 */
  57276. static readonly SUBUV_COLOR: number;
  57277. /** The Name of the Texture Package */
  57278. name: string;
  57279. /** The scene scope of the TexturePacker */
  57280. scene: Scene;
  57281. /** The Meshes to target */
  57282. meshes: AbstractMesh[];
  57283. /** Arguments passed with the Constructor */
  57284. options: ITexturePackerOptions;
  57285. /** The promise that is started upon initialization */
  57286. promise: Nullable<Promise<TexturePacker | string>>;
  57287. /** The Container object for the channel sets that are generated */
  57288. sets: object;
  57289. /** The Container array for the frames that are generated */
  57290. frames: TexturePackerFrame[];
  57291. /** The expected number of textures the system is parsing. */
  57292. private _expecting;
  57293. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57294. private _paddingValue;
  57295. /**
  57296. * Initializes a texture package series from an array of meshes or a single mesh.
  57297. * @param name The name of the package
  57298. * @param meshes The target meshes to compose the package from
  57299. * @param options The arguments that texture packer should follow while building.
  57300. * @param scene The scene which the textures are scoped to.
  57301. * @returns TexturePacker
  57302. */
  57303. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57304. /**
  57305. * Starts the package process
  57306. * @param resolve The promises resolution function
  57307. * @returns TexturePacker
  57308. */
  57309. private _createFrames;
  57310. /**
  57311. * Calculates the Size of the Channel Sets
  57312. * @returns Vector2
  57313. */
  57314. private _calculateSize;
  57315. /**
  57316. * Calculates the UV data for the frames.
  57317. * @param baseSize the base frameSize
  57318. * @param padding the base frame padding
  57319. * @param dtSize size of the Dynamic Texture for that channel
  57320. * @param dtUnits is 1/dtSize
  57321. * @param update flag to update the input meshes
  57322. */
  57323. private _calculateMeshUVFrames;
  57324. /**
  57325. * Calculates the frames Offset.
  57326. * @param index of the frame
  57327. * @returns Vector2
  57328. */
  57329. private _getFrameOffset;
  57330. /**
  57331. * Updates a Mesh to the frame data
  57332. * @param mesh that is the target
  57333. * @param frameID or the frame index
  57334. */
  57335. private _updateMeshUV;
  57336. /**
  57337. * Updates a Meshes materials to use the texture packer channels
  57338. * @param m is the mesh to target
  57339. * @param force all channels on the packer to be set.
  57340. */
  57341. private _updateTextureReferences;
  57342. /**
  57343. * Public method to set a Mesh to a frame
  57344. * @param m that is the target
  57345. * @param frameID or the frame index
  57346. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57347. */
  57348. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57349. /**
  57350. * Starts the async promise to compile the texture packer.
  57351. * @returns Promise<void>
  57352. */
  57353. processAsync(): Promise<void>;
  57354. /**
  57355. * Disposes all textures associated with this packer
  57356. */
  57357. dispose(): void;
  57358. /**
  57359. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57360. * @param imageType is the image type to use.
  57361. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57362. */
  57363. download(imageType?: string, quality?: number): void;
  57364. /**
  57365. * Public method to load a texturePacker JSON file.
  57366. * @param data of the JSON file in string format.
  57367. */
  57368. updateFromJSON(data: string): void;
  57369. }
  57370. }
  57371. declare module BABYLON {
  57372. /**
  57373. * Enum used to define the target of a block
  57374. */
  57375. export enum NodeMaterialBlockTargets {
  57376. /** Vertex shader */
  57377. Vertex = 1,
  57378. /** Fragment shader */
  57379. Fragment = 2,
  57380. /** Neutral */
  57381. Neutral = 4,
  57382. /** Vertex and Fragment */
  57383. VertexAndFragment = 3
  57384. }
  57385. }
  57386. declare module BABYLON {
  57387. /**
  57388. * Defines the kind of connection point for node based material
  57389. */
  57390. export enum NodeMaterialBlockConnectionPointTypes {
  57391. /** Float */
  57392. Float = 1,
  57393. /** Int */
  57394. Int = 2,
  57395. /** Vector2 */
  57396. Vector2 = 4,
  57397. /** Vector3 */
  57398. Vector3 = 8,
  57399. /** Vector4 */
  57400. Vector4 = 16,
  57401. /** Color3 */
  57402. Color3 = 32,
  57403. /** Color4 */
  57404. Color4 = 64,
  57405. /** Matrix */
  57406. Matrix = 128,
  57407. /** Detect type based on connection */
  57408. AutoDetect = 1024,
  57409. /** Output type that will be defined by input type */
  57410. BasedOnInput = 2048
  57411. }
  57412. }
  57413. declare module BABYLON {
  57414. /**
  57415. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57416. */
  57417. export enum NodeMaterialBlockConnectionPointMode {
  57418. /** Value is an uniform */
  57419. Uniform = 0,
  57420. /** Value is a mesh attribute */
  57421. Attribute = 1,
  57422. /** Value is a varying between vertex and fragment shaders */
  57423. Varying = 2,
  57424. /** Mode is undefined */
  57425. Undefined = 3
  57426. }
  57427. }
  57428. declare module BABYLON {
  57429. /**
  57430. * Enum used to define system values e.g. values automatically provided by the system
  57431. */
  57432. export enum NodeMaterialSystemValues {
  57433. /** World */
  57434. World = 1,
  57435. /** View */
  57436. View = 2,
  57437. /** Projection */
  57438. Projection = 3,
  57439. /** ViewProjection */
  57440. ViewProjection = 4,
  57441. /** WorldView */
  57442. WorldView = 5,
  57443. /** WorldViewProjection */
  57444. WorldViewProjection = 6,
  57445. /** CameraPosition */
  57446. CameraPosition = 7,
  57447. /** Fog Color */
  57448. FogColor = 8,
  57449. /** Delta time */
  57450. DeltaTime = 9
  57451. }
  57452. }
  57453. declare module BABYLON {
  57454. /**
  57455. * Root class for all node material optimizers
  57456. */
  57457. export class NodeMaterialOptimizer {
  57458. /**
  57459. * Function used to optimize a NodeMaterial graph
  57460. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57461. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57462. */
  57463. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57464. }
  57465. }
  57466. declare module BABYLON {
  57467. /**
  57468. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57469. */
  57470. export class TransformBlock extends NodeMaterialBlock {
  57471. /**
  57472. * Defines the value to use to complement W value to transform it to a Vector4
  57473. */
  57474. complementW: number;
  57475. /**
  57476. * Defines the value to use to complement z value to transform it to a Vector4
  57477. */
  57478. complementZ: number;
  57479. /**
  57480. * Creates a new TransformBlock
  57481. * @param name defines the block name
  57482. */
  57483. constructor(name: string);
  57484. /**
  57485. * Gets the current class name
  57486. * @returns the class name
  57487. */
  57488. getClassName(): string;
  57489. /**
  57490. * Gets the vector input
  57491. */
  57492. get vector(): NodeMaterialConnectionPoint;
  57493. /**
  57494. * Gets the output component
  57495. */
  57496. get output(): NodeMaterialConnectionPoint;
  57497. /**
  57498. * Gets the xyz output component
  57499. */
  57500. get xyz(): NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the matrix transform input
  57503. */
  57504. get transform(): NodeMaterialConnectionPoint;
  57505. protected _buildBlock(state: NodeMaterialBuildState): this;
  57506. serialize(): any;
  57507. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57508. protected _dumpPropertiesCode(): string;
  57509. }
  57510. }
  57511. declare module BABYLON {
  57512. /**
  57513. * Block used to output the vertex position
  57514. */
  57515. export class VertexOutputBlock extends NodeMaterialBlock {
  57516. /**
  57517. * Creates a new VertexOutputBlock
  57518. * @param name defines the block name
  57519. */
  57520. constructor(name: string);
  57521. /**
  57522. * Gets the current class name
  57523. * @returns the class name
  57524. */
  57525. getClassName(): string;
  57526. /**
  57527. * Gets the vector input component
  57528. */
  57529. get vector(): NodeMaterialConnectionPoint;
  57530. protected _buildBlock(state: NodeMaterialBuildState): this;
  57531. }
  57532. }
  57533. declare module BABYLON {
  57534. /**
  57535. * Block used to output the final color
  57536. */
  57537. export class FragmentOutputBlock extends NodeMaterialBlock {
  57538. /**
  57539. * Create a new FragmentOutputBlock
  57540. * @param name defines the block name
  57541. */
  57542. constructor(name: string);
  57543. /**
  57544. * Gets the current class name
  57545. * @returns the class name
  57546. */
  57547. getClassName(): string;
  57548. /**
  57549. * Gets the rgba input component
  57550. */
  57551. get rgba(): NodeMaterialConnectionPoint;
  57552. /**
  57553. * Gets the rgb input component
  57554. */
  57555. get rgb(): NodeMaterialConnectionPoint;
  57556. /**
  57557. * Gets the a input component
  57558. */
  57559. get a(): NodeMaterialConnectionPoint;
  57560. protected _buildBlock(state: NodeMaterialBuildState): this;
  57561. }
  57562. }
  57563. declare module BABYLON {
  57564. /**
  57565. * Block used to read a reflection texture from a sampler
  57566. */
  57567. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57568. private _define3DName;
  57569. private _defineCubicName;
  57570. private _defineExplicitName;
  57571. private _defineProjectionName;
  57572. private _defineLocalCubicName;
  57573. private _defineSphericalName;
  57574. private _definePlanarName;
  57575. private _defineEquirectangularName;
  57576. private _defineMirroredEquirectangularFixedName;
  57577. private _defineEquirectangularFixedName;
  57578. private _defineSkyboxName;
  57579. private _cubeSamplerName;
  57580. private _2DSamplerName;
  57581. private _positionUVWName;
  57582. private _directionWName;
  57583. private _reflectionCoordsName;
  57584. private _reflection2DCoordsName;
  57585. private _reflectionColorName;
  57586. private _reflectionMatrixName;
  57587. /**
  57588. * Gets or sets the texture associated with the node
  57589. */
  57590. texture: Nullable<BaseTexture>;
  57591. /**
  57592. * Create a new TextureBlock
  57593. * @param name defines the block name
  57594. */
  57595. constructor(name: string);
  57596. /**
  57597. * Gets the current class name
  57598. * @returns the class name
  57599. */
  57600. getClassName(): string;
  57601. /**
  57602. * Gets the world position input component
  57603. */
  57604. get position(): NodeMaterialConnectionPoint;
  57605. /**
  57606. * Gets the world position input component
  57607. */
  57608. get worldPosition(): NodeMaterialConnectionPoint;
  57609. /**
  57610. * Gets the world normal input component
  57611. */
  57612. get worldNormal(): NodeMaterialConnectionPoint;
  57613. /**
  57614. * Gets the world input component
  57615. */
  57616. get world(): NodeMaterialConnectionPoint;
  57617. /**
  57618. * Gets the camera (or eye) position component
  57619. */
  57620. get cameraPosition(): NodeMaterialConnectionPoint;
  57621. /**
  57622. * Gets the view input component
  57623. */
  57624. get view(): NodeMaterialConnectionPoint;
  57625. /**
  57626. * Gets the rgb output component
  57627. */
  57628. get rgb(): NodeMaterialConnectionPoint;
  57629. /**
  57630. * Gets the r output component
  57631. */
  57632. get r(): NodeMaterialConnectionPoint;
  57633. /**
  57634. * Gets the g output component
  57635. */
  57636. get g(): NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the b output component
  57639. */
  57640. get b(): NodeMaterialConnectionPoint;
  57641. autoConfigure(material: NodeMaterial): void;
  57642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57643. isReady(): boolean;
  57644. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57645. private _injectVertexCode;
  57646. private _writeOutput;
  57647. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57648. protected _dumpPropertiesCode(): string;
  57649. serialize(): any;
  57650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57651. }
  57652. }
  57653. declare module BABYLON {
  57654. /**
  57655. * Interface used to configure the node material editor
  57656. */
  57657. export interface INodeMaterialEditorOptions {
  57658. /** Define the URl to load node editor script */
  57659. editorURL?: string;
  57660. }
  57661. /** @hidden */
  57662. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57663. NORMAL: boolean;
  57664. TANGENT: boolean;
  57665. UV1: boolean;
  57666. /** BONES */
  57667. NUM_BONE_INFLUENCERS: number;
  57668. BonesPerMesh: number;
  57669. BONETEXTURE: boolean;
  57670. /** MORPH TARGETS */
  57671. MORPHTARGETS: boolean;
  57672. MORPHTARGETS_NORMAL: boolean;
  57673. MORPHTARGETS_TANGENT: boolean;
  57674. MORPHTARGETS_UV: boolean;
  57675. NUM_MORPH_INFLUENCERS: number;
  57676. /** IMAGE PROCESSING */
  57677. IMAGEPROCESSING: boolean;
  57678. VIGNETTE: boolean;
  57679. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57680. VIGNETTEBLENDMODEOPAQUE: boolean;
  57681. TONEMAPPING: boolean;
  57682. TONEMAPPING_ACES: boolean;
  57683. CONTRAST: boolean;
  57684. EXPOSURE: boolean;
  57685. COLORCURVES: boolean;
  57686. COLORGRADING: boolean;
  57687. COLORGRADING3D: boolean;
  57688. SAMPLER3DGREENDEPTH: boolean;
  57689. SAMPLER3DBGRMAP: boolean;
  57690. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57691. /** MISC. */
  57692. BUMPDIRECTUV: number;
  57693. constructor();
  57694. setValue(name: string, value: boolean): void;
  57695. }
  57696. /**
  57697. * Class used to configure NodeMaterial
  57698. */
  57699. export interface INodeMaterialOptions {
  57700. /**
  57701. * Defines if blocks should emit comments
  57702. */
  57703. emitComments: boolean;
  57704. }
  57705. /**
  57706. * Class used to create a node based material built by assembling shader blocks
  57707. */
  57708. export class NodeMaterial extends PushMaterial {
  57709. private static _BuildIdGenerator;
  57710. private _options;
  57711. private _vertexCompilationState;
  57712. private _fragmentCompilationState;
  57713. private _sharedData;
  57714. private _buildId;
  57715. private _buildWasSuccessful;
  57716. private _cachedWorldViewMatrix;
  57717. private _cachedWorldViewProjectionMatrix;
  57718. private _optimizers;
  57719. private _animationFrame;
  57720. /** Define the Url to load node editor script */
  57721. static EditorURL: string;
  57722. /** Define the Url to load snippets */
  57723. static SnippetUrl: string;
  57724. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57725. static IgnoreTexturesAtLoadTime: boolean;
  57726. private BJSNODEMATERIALEDITOR;
  57727. /** Get the inspector from bundle or global */
  57728. private _getGlobalNodeMaterialEditor;
  57729. /**
  57730. * Snippet ID if the material was created from the snippet server
  57731. */
  57732. snippetId: string;
  57733. /**
  57734. * Gets or sets data used by visual editor
  57735. * @see https://nme.babylonjs.com
  57736. */
  57737. editorData: any;
  57738. /**
  57739. * 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)
  57740. */
  57741. ignoreAlpha: boolean;
  57742. /**
  57743. * Defines the maximum number of lights that can be used in the material
  57744. */
  57745. maxSimultaneousLights: number;
  57746. /**
  57747. * Observable raised when the material is built
  57748. */
  57749. onBuildObservable: Observable<NodeMaterial>;
  57750. /**
  57751. * Gets or sets the root nodes of the material vertex shader
  57752. */
  57753. _vertexOutputNodes: NodeMaterialBlock[];
  57754. /**
  57755. * Gets or sets the root nodes of the material fragment (pixel) shader
  57756. */
  57757. _fragmentOutputNodes: NodeMaterialBlock[];
  57758. /** Gets or sets options to control the node material overall behavior */
  57759. get options(): INodeMaterialOptions;
  57760. set options(options: INodeMaterialOptions);
  57761. /**
  57762. * Default configuration related to image processing available in the standard Material.
  57763. */
  57764. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57765. /**
  57766. * Gets the image processing configuration used either in this material.
  57767. */
  57768. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57769. /**
  57770. * Sets the Default image processing configuration used either in the this material.
  57771. *
  57772. * If sets to null, the scene one is in use.
  57773. */
  57774. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57775. /**
  57776. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57777. */
  57778. attachedBlocks: NodeMaterialBlock[];
  57779. /**
  57780. * Create a new node based material
  57781. * @param name defines the material name
  57782. * @param scene defines the hosting scene
  57783. * @param options defines creation option
  57784. */
  57785. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57786. /**
  57787. * Gets the current class name of the material e.g. "NodeMaterial"
  57788. * @returns the class name
  57789. */
  57790. getClassName(): string;
  57791. /**
  57792. * Keep track of the image processing observer to allow dispose and replace.
  57793. */
  57794. private _imageProcessingObserver;
  57795. /**
  57796. * Attaches a new image processing configuration to the Standard Material.
  57797. * @param configuration
  57798. */
  57799. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57800. /**
  57801. * Get a block by its name
  57802. * @param name defines the name of the block to retrieve
  57803. * @returns the required block or null if not found
  57804. */
  57805. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57806. /**
  57807. * Get a block by its name
  57808. * @param predicate defines the predicate used to find the good candidate
  57809. * @returns the required block or null if not found
  57810. */
  57811. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57812. /**
  57813. * Get an input block by its name
  57814. * @param predicate defines the predicate used to find the good candidate
  57815. * @returns the required input block or null if not found
  57816. */
  57817. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57818. /**
  57819. * Gets the list of input blocks attached to this material
  57820. * @returns an array of InputBlocks
  57821. */
  57822. getInputBlocks(): InputBlock[];
  57823. /**
  57824. * Adds a new optimizer to the list of optimizers
  57825. * @param optimizer defines the optimizers to add
  57826. * @returns the current material
  57827. */
  57828. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57829. /**
  57830. * Remove an optimizer from the list of optimizers
  57831. * @param optimizer defines the optimizers to remove
  57832. * @returns the current material
  57833. */
  57834. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57835. /**
  57836. * Add a new block to the list of output nodes
  57837. * @param node defines the node to add
  57838. * @returns the current material
  57839. */
  57840. addOutputNode(node: NodeMaterialBlock): this;
  57841. /**
  57842. * Remove a block from the list of root nodes
  57843. * @param node defines the node to remove
  57844. * @returns the current material
  57845. */
  57846. removeOutputNode(node: NodeMaterialBlock): this;
  57847. private _addVertexOutputNode;
  57848. private _removeVertexOutputNode;
  57849. private _addFragmentOutputNode;
  57850. private _removeFragmentOutputNode;
  57851. /**
  57852. * Specifies if the material will require alpha blending
  57853. * @returns a boolean specifying if alpha blending is needed
  57854. */
  57855. needAlphaBlending(): boolean;
  57856. /**
  57857. * Specifies if this material should be rendered in alpha test mode
  57858. * @returns a boolean specifying if an alpha test is needed.
  57859. */
  57860. needAlphaTesting(): boolean;
  57861. private _initializeBlock;
  57862. private _resetDualBlocks;
  57863. /**
  57864. * Remove a block from the current node material
  57865. * @param block defines the block to remove
  57866. */
  57867. removeBlock(block: NodeMaterialBlock): void;
  57868. /**
  57869. * Build the material and generates the inner effect
  57870. * @param verbose defines if the build should log activity
  57871. */
  57872. build(verbose?: boolean): void;
  57873. /**
  57874. * Runs an otpimization phase to try to improve the shader code
  57875. */
  57876. optimize(): void;
  57877. private _prepareDefinesForAttributes;
  57878. /**
  57879. * Get if the submesh is ready to be used and all its information available.
  57880. * Child classes can use it to update shaders
  57881. * @param mesh defines the mesh to check
  57882. * @param subMesh defines which submesh to check
  57883. * @param useInstances specifies that instances should be used
  57884. * @returns a boolean indicating that the submesh is ready or not
  57885. */
  57886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57887. /**
  57888. * Get a string representing the shaders built by the current node graph
  57889. */
  57890. get compiledShaders(): string;
  57891. /**
  57892. * Binds the world matrix to the material
  57893. * @param world defines the world transformation matrix
  57894. */
  57895. bindOnlyWorldMatrix(world: Matrix): void;
  57896. /**
  57897. * Binds the submesh to this material by preparing the effect and shader to draw
  57898. * @param world defines the world transformation matrix
  57899. * @param mesh defines the mesh containing the submesh
  57900. * @param subMesh defines the submesh to bind the material to
  57901. */
  57902. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57903. /**
  57904. * Gets the active textures from the material
  57905. * @returns an array of textures
  57906. */
  57907. getActiveTextures(): BaseTexture[];
  57908. /**
  57909. * Gets the list of texture blocks
  57910. * @returns an array of texture blocks
  57911. */
  57912. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57913. /**
  57914. * Specifies if the material uses a texture
  57915. * @param texture defines the texture to check against the material
  57916. * @returns a boolean specifying if the material uses the texture
  57917. */
  57918. hasTexture(texture: BaseTexture): boolean;
  57919. /**
  57920. * Disposes the material
  57921. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57922. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57923. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57924. */
  57925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57926. /** Creates the node editor window. */
  57927. private _createNodeEditor;
  57928. /**
  57929. * Launch the node material editor
  57930. * @param config Define the configuration of the editor
  57931. * @return a promise fulfilled when the node editor is visible
  57932. */
  57933. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57934. /**
  57935. * Clear the current material
  57936. */
  57937. clear(): void;
  57938. /**
  57939. * Clear the current material and set it to a default state
  57940. */
  57941. setToDefault(): void;
  57942. /**
  57943. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57944. * @param url defines the url to load from
  57945. * @returns a promise that will fullfil when the material is fully loaded
  57946. */
  57947. loadAsync(url: string): Promise<void>;
  57948. private _gatherBlocks;
  57949. /**
  57950. * Generate a string containing the code declaration required to create an equivalent of this material
  57951. * @returns a string
  57952. */
  57953. generateCode(): string;
  57954. /**
  57955. * Serializes this material in a JSON representation
  57956. * @returns the serialized material object
  57957. */
  57958. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57959. private _restoreConnections;
  57960. /**
  57961. * Clear the current graph and load a new one from a serialization object
  57962. * @param source defines the JSON representation of the material
  57963. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57964. */
  57965. loadFromSerialization(source: any, rootUrl?: string): void;
  57966. /**
  57967. * Makes a duplicate of the current material.
  57968. * @param name - name to use for the new material.
  57969. */
  57970. clone(name: string): NodeMaterial;
  57971. /**
  57972. * Creates a node material from parsed material data
  57973. * @param source defines the JSON representation of the material
  57974. * @param scene defines the hosting scene
  57975. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57976. * @returns a new node material
  57977. */
  57978. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57979. /**
  57980. * Creates a node material from a snippet saved in a remote file
  57981. * @param name defines the name of the material to create
  57982. * @param url defines the url to load from
  57983. * @param scene defines the hosting scene
  57984. * @returns a promise that will resolve to the new node material
  57985. */
  57986. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57987. /**
  57988. * Creates a node material from a snippet saved by the node material editor
  57989. * @param snippetId defines the snippet to load
  57990. * @param scene defines the hosting scene
  57991. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57992. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57993. * @returns a promise that will resolve to the new node material
  57994. */
  57995. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57996. /**
  57997. * Creates a new node material set to default basic configuration
  57998. * @param name defines the name of the material
  57999. * @param scene defines the hosting scene
  58000. * @returns a new NodeMaterial
  58001. */
  58002. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58003. }
  58004. }
  58005. declare module BABYLON {
  58006. /**
  58007. * Block used to read a texture from a sampler
  58008. */
  58009. export class TextureBlock extends NodeMaterialBlock {
  58010. private _defineName;
  58011. private _linearDefineName;
  58012. private _tempTextureRead;
  58013. private _samplerName;
  58014. private _transformedUVName;
  58015. private _textureTransformName;
  58016. private _textureInfoName;
  58017. private _mainUVName;
  58018. private _mainUVDefineName;
  58019. /**
  58020. * Gets or sets the texture associated with the node
  58021. */
  58022. texture: Nullable<Texture>;
  58023. /**
  58024. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58025. */
  58026. convertToGammaSpace: boolean;
  58027. /**
  58028. * Create a new TextureBlock
  58029. * @param name defines the block name
  58030. */
  58031. constructor(name: string);
  58032. /**
  58033. * Gets the current class name
  58034. * @returns the class name
  58035. */
  58036. getClassName(): string;
  58037. /**
  58038. * Gets the uv input component
  58039. */
  58040. get uv(): NodeMaterialConnectionPoint;
  58041. /**
  58042. * Gets the rgba output component
  58043. */
  58044. get rgba(): NodeMaterialConnectionPoint;
  58045. /**
  58046. * Gets the rgb output component
  58047. */
  58048. get rgb(): NodeMaterialConnectionPoint;
  58049. /**
  58050. * Gets the r output component
  58051. */
  58052. get r(): NodeMaterialConnectionPoint;
  58053. /**
  58054. * Gets the g output component
  58055. */
  58056. get g(): NodeMaterialConnectionPoint;
  58057. /**
  58058. * Gets the b output component
  58059. */
  58060. get b(): NodeMaterialConnectionPoint;
  58061. /**
  58062. * Gets the a output component
  58063. */
  58064. get a(): NodeMaterialConnectionPoint;
  58065. get target(): NodeMaterialBlockTargets;
  58066. autoConfigure(material: NodeMaterial): void;
  58067. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58069. isReady(): boolean;
  58070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58071. private get _isMixed();
  58072. private _injectVertexCode;
  58073. private _writeTextureRead;
  58074. private _writeOutput;
  58075. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58076. protected _dumpPropertiesCode(): string;
  58077. serialize(): any;
  58078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58079. }
  58080. }
  58081. declare module BABYLON {
  58082. /**
  58083. * Class used to store shared data between 2 NodeMaterialBuildState
  58084. */
  58085. export class NodeMaterialBuildStateSharedData {
  58086. /**
  58087. * Gets the list of emitted varyings
  58088. */
  58089. temps: string[];
  58090. /**
  58091. * Gets the list of emitted varyings
  58092. */
  58093. varyings: string[];
  58094. /**
  58095. * Gets the varying declaration string
  58096. */
  58097. varyingDeclaration: string;
  58098. /**
  58099. * Input blocks
  58100. */
  58101. inputBlocks: InputBlock[];
  58102. /**
  58103. * Input blocks
  58104. */
  58105. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58106. /**
  58107. * Bindable blocks (Blocks that need to set data to the effect)
  58108. */
  58109. bindableBlocks: NodeMaterialBlock[];
  58110. /**
  58111. * List of blocks that can provide a compilation fallback
  58112. */
  58113. blocksWithFallbacks: NodeMaterialBlock[];
  58114. /**
  58115. * List of blocks that can provide a define update
  58116. */
  58117. blocksWithDefines: NodeMaterialBlock[];
  58118. /**
  58119. * List of blocks that can provide a repeatable content
  58120. */
  58121. repeatableContentBlocks: NodeMaterialBlock[];
  58122. /**
  58123. * List of blocks that can provide a dynamic list of uniforms
  58124. */
  58125. dynamicUniformBlocks: NodeMaterialBlock[];
  58126. /**
  58127. * List of blocks that can block the isReady function for the material
  58128. */
  58129. blockingBlocks: NodeMaterialBlock[];
  58130. /**
  58131. * Gets the list of animated inputs
  58132. */
  58133. animatedInputs: InputBlock[];
  58134. /**
  58135. * Build Id used to avoid multiple recompilations
  58136. */
  58137. buildId: number;
  58138. /** List of emitted variables */
  58139. variableNames: {
  58140. [key: string]: number;
  58141. };
  58142. /** List of emitted defines */
  58143. defineNames: {
  58144. [key: string]: number;
  58145. };
  58146. /** Should emit comments? */
  58147. emitComments: boolean;
  58148. /** Emit build activity */
  58149. verbose: boolean;
  58150. /** Gets or sets the hosting scene */
  58151. scene: Scene;
  58152. /**
  58153. * Gets the compilation hints emitted at compilation time
  58154. */
  58155. hints: {
  58156. needWorldViewMatrix: boolean;
  58157. needWorldViewProjectionMatrix: boolean;
  58158. needAlphaBlending: boolean;
  58159. needAlphaTesting: boolean;
  58160. };
  58161. /**
  58162. * List of compilation checks
  58163. */
  58164. checks: {
  58165. emitVertex: boolean;
  58166. emitFragment: boolean;
  58167. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58168. };
  58169. /** Creates a new shared data */
  58170. constructor();
  58171. /**
  58172. * Emits console errors and exceptions if there is a failing check
  58173. */
  58174. emitErrors(): void;
  58175. }
  58176. }
  58177. declare module BABYLON {
  58178. /**
  58179. * Class used to store node based material build state
  58180. */
  58181. export class NodeMaterialBuildState {
  58182. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58183. supportUniformBuffers: boolean;
  58184. /**
  58185. * Gets the list of emitted attributes
  58186. */
  58187. attributes: string[];
  58188. /**
  58189. * Gets the list of emitted uniforms
  58190. */
  58191. uniforms: string[];
  58192. /**
  58193. * Gets the list of emitted constants
  58194. */
  58195. constants: string[];
  58196. /**
  58197. * Gets the list of emitted samplers
  58198. */
  58199. samplers: string[];
  58200. /**
  58201. * Gets the list of emitted functions
  58202. */
  58203. functions: {
  58204. [key: string]: string;
  58205. };
  58206. /**
  58207. * Gets the list of emitted extensions
  58208. */
  58209. extensions: {
  58210. [key: string]: string;
  58211. };
  58212. /**
  58213. * Gets the target of the compilation state
  58214. */
  58215. target: NodeMaterialBlockTargets;
  58216. /**
  58217. * Gets the list of emitted counters
  58218. */
  58219. counters: {
  58220. [key: string]: number;
  58221. };
  58222. /**
  58223. * Shared data between multiple NodeMaterialBuildState instances
  58224. */
  58225. sharedData: NodeMaterialBuildStateSharedData;
  58226. /** @hidden */
  58227. _vertexState: NodeMaterialBuildState;
  58228. /** @hidden */
  58229. _attributeDeclaration: string;
  58230. /** @hidden */
  58231. _uniformDeclaration: string;
  58232. /** @hidden */
  58233. _constantDeclaration: string;
  58234. /** @hidden */
  58235. _samplerDeclaration: string;
  58236. /** @hidden */
  58237. _varyingTransfer: string;
  58238. private _repeatableContentAnchorIndex;
  58239. /** @hidden */
  58240. _builtCompilationString: string;
  58241. /**
  58242. * Gets the emitted compilation strings
  58243. */
  58244. compilationString: string;
  58245. /**
  58246. * Finalize the compilation strings
  58247. * @param state defines the current compilation state
  58248. */
  58249. finalize(state: NodeMaterialBuildState): void;
  58250. /** @hidden */
  58251. get _repeatableContentAnchor(): string;
  58252. /** @hidden */
  58253. _getFreeVariableName(prefix: string): string;
  58254. /** @hidden */
  58255. _getFreeDefineName(prefix: string): string;
  58256. /** @hidden */
  58257. _excludeVariableName(name: string): void;
  58258. /** @hidden */
  58259. _emit2DSampler(name: string): void;
  58260. /** @hidden */
  58261. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58262. /** @hidden */
  58263. _emitExtension(name: string, extension: string): void;
  58264. /** @hidden */
  58265. _emitFunction(name: string, code: string, comments: string): void;
  58266. /** @hidden */
  58267. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58268. replaceStrings?: {
  58269. search: RegExp;
  58270. replace: string;
  58271. }[];
  58272. repeatKey?: string;
  58273. }): string;
  58274. /** @hidden */
  58275. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58276. repeatKey?: string;
  58277. removeAttributes?: boolean;
  58278. removeUniforms?: boolean;
  58279. removeVaryings?: boolean;
  58280. removeIfDef?: boolean;
  58281. replaceStrings?: {
  58282. search: RegExp;
  58283. replace: string;
  58284. }[];
  58285. }, storeKey?: string): void;
  58286. /** @hidden */
  58287. _registerTempVariable(name: string): boolean;
  58288. /** @hidden */
  58289. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58290. /** @hidden */
  58291. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58292. /** @hidden */
  58293. _emitFloat(value: number): string;
  58294. }
  58295. }
  58296. declare module BABYLON {
  58297. /**
  58298. * Defines a block that can be used inside a node based material
  58299. */
  58300. export class NodeMaterialBlock {
  58301. private _buildId;
  58302. private _buildTarget;
  58303. private _target;
  58304. private _isFinalMerger;
  58305. private _isInput;
  58306. protected _isUnique: boolean;
  58307. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58308. inputsAreExclusive: boolean;
  58309. /** @hidden */
  58310. _codeVariableName: string;
  58311. /** @hidden */
  58312. _inputs: NodeMaterialConnectionPoint[];
  58313. /** @hidden */
  58314. _outputs: NodeMaterialConnectionPoint[];
  58315. /** @hidden */
  58316. _preparationId: number;
  58317. /**
  58318. * Gets or sets the name of the block
  58319. */
  58320. name: string;
  58321. /**
  58322. * Gets or sets the unique id of the node
  58323. */
  58324. uniqueId: number;
  58325. /**
  58326. * Gets or sets the comments associated with this block
  58327. */
  58328. comments: string;
  58329. /**
  58330. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58331. */
  58332. get isUnique(): boolean;
  58333. /**
  58334. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58335. */
  58336. get isFinalMerger(): boolean;
  58337. /**
  58338. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58339. */
  58340. get isInput(): boolean;
  58341. /**
  58342. * Gets or sets the build Id
  58343. */
  58344. get buildId(): number;
  58345. set buildId(value: number);
  58346. /**
  58347. * Gets or sets the target of the block
  58348. */
  58349. get target(): NodeMaterialBlockTargets;
  58350. set target(value: NodeMaterialBlockTargets);
  58351. /**
  58352. * Gets the list of input points
  58353. */
  58354. get inputs(): NodeMaterialConnectionPoint[];
  58355. /** Gets the list of output points */
  58356. get outputs(): NodeMaterialConnectionPoint[];
  58357. /**
  58358. * Find an input by its name
  58359. * @param name defines the name of the input to look for
  58360. * @returns the input or null if not found
  58361. */
  58362. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58363. /**
  58364. * Find an output by its name
  58365. * @param name defines the name of the outputto look for
  58366. * @returns the output or null if not found
  58367. */
  58368. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58369. /**
  58370. * Creates a new NodeMaterialBlock
  58371. * @param name defines the block name
  58372. * @param target defines the target of that block (Vertex by default)
  58373. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58374. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58375. */
  58376. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58377. /**
  58378. * Initialize the block and prepare the context for build
  58379. * @param state defines the state that will be used for the build
  58380. */
  58381. initialize(state: NodeMaterialBuildState): void;
  58382. /**
  58383. * Bind data to effect. Will only be called for blocks with isBindable === true
  58384. * @param effect defines the effect to bind data to
  58385. * @param nodeMaterial defines the hosting NodeMaterial
  58386. * @param mesh defines the mesh that will be rendered
  58387. */
  58388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58389. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58390. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58391. protected _writeFloat(value: number): string;
  58392. /**
  58393. * Gets the current class name e.g. "NodeMaterialBlock"
  58394. * @returns the class name
  58395. */
  58396. getClassName(): string;
  58397. /**
  58398. * Register a new input. Must be called inside a block constructor
  58399. * @param name defines the connection point name
  58400. * @param type defines the connection point type
  58401. * @param isOptional defines a boolean indicating that this input can be omitted
  58402. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58403. * @returns the current block
  58404. */
  58405. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58406. /**
  58407. * Register a new output. Must be called inside a block constructor
  58408. * @param name defines the connection point name
  58409. * @param type defines the connection point type
  58410. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58411. * @returns the current block
  58412. */
  58413. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58414. /**
  58415. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58416. * @param forOutput defines an optional connection point to check compatibility with
  58417. * @returns the first available input or null
  58418. */
  58419. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58420. /**
  58421. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58422. * @param forBlock defines an optional block to check compatibility with
  58423. * @returns the first available input or null
  58424. */
  58425. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58426. /**
  58427. * Gets the sibling of the given output
  58428. * @param current defines the current output
  58429. * @returns the next output in the list or null
  58430. */
  58431. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58432. /**
  58433. * Connect current block with another block
  58434. * @param other defines the block to connect with
  58435. * @param options define the various options to help pick the right connections
  58436. * @returns the current block
  58437. */
  58438. connectTo(other: NodeMaterialBlock, options?: {
  58439. input?: string;
  58440. output?: string;
  58441. outputSwizzle?: string;
  58442. }): this | undefined;
  58443. protected _buildBlock(state: NodeMaterialBuildState): void;
  58444. /**
  58445. * Add uniforms, samplers and uniform buffers at compilation time
  58446. * @param state defines the state to update
  58447. * @param nodeMaterial defines the node material requesting the update
  58448. * @param defines defines the material defines to update
  58449. * @param uniformBuffers defines the list of uniform buffer names
  58450. */
  58451. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58452. /**
  58453. * Add potential fallbacks if shader compilation fails
  58454. * @param mesh defines the mesh to be rendered
  58455. * @param fallbacks defines the current prioritized list of fallbacks
  58456. */
  58457. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58458. /**
  58459. * Initialize defines for shader compilation
  58460. * @param mesh defines the mesh to be rendered
  58461. * @param nodeMaterial defines the node material requesting the update
  58462. * @param defines defines the material defines to update
  58463. * @param useInstances specifies that instances should be used
  58464. */
  58465. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58466. /**
  58467. * Update defines for shader compilation
  58468. * @param mesh defines the mesh to be rendered
  58469. * @param nodeMaterial defines the node material requesting the update
  58470. * @param defines defines the material defines to update
  58471. * @param useInstances specifies that instances should be used
  58472. */
  58473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58474. /**
  58475. * Lets the block try to connect some inputs automatically
  58476. * @param material defines the hosting NodeMaterial
  58477. */
  58478. autoConfigure(material: NodeMaterial): void;
  58479. /**
  58480. * Function called when a block is declared as repeatable content generator
  58481. * @param vertexShaderState defines the current compilation state for the vertex shader
  58482. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58483. * @param mesh defines the mesh to be rendered
  58484. * @param defines defines the material defines to update
  58485. */
  58486. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58487. /**
  58488. * Checks if the block is ready
  58489. * @param mesh defines the mesh to be rendered
  58490. * @param nodeMaterial defines the node material requesting the update
  58491. * @param defines defines the material defines to update
  58492. * @param useInstances specifies that instances should be used
  58493. * @returns true if the block is ready
  58494. */
  58495. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58496. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58497. private _processBuild;
  58498. /**
  58499. * Compile the current node and generate the shader code
  58500. * @param state defines the current compilation state (uniforms, samplers, current string)
  58501. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58502. * @returns true if already built
  58503. */
  58504. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58505. protected _inputRename(name: string): string;
  58506. protected _outputRename(name: string): string;
  58507. protected _dumpPropertiesCode(): string;
  58508. /** @hidden */
  58509. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58510. /** @hidden */
  58511. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58512. /**
  58513. * Clone the current block to a new identical block
  58514. * @param scene defines the hosting scene
  58515. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58516. * @returns a copy of the current block
  58517. */
  58518. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58519. /**
  58520. * Serializes this block in a JSON representation
  58521. * @returns the serialized block object
  58522. */
  58523. serialize(): any;
  58524. /** @hidden */
  58525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58526. /**
  58527. * Release resources
  58528. */
  58529. dispose(): void;
  58530. }
  58531. }
  58532. declare module BABYLON {
  58533. /**
  58534. * Enum defining the type of animations supported by InputBlock
  58535. */
  58536. export enum AnimatedInputBlockTypes {
  58537. /** No animation */
  58538. None = 0,
  58539. /** Time based animation. Will only work for floats */
  58540. Time = 1
  58541. }
  58542. }
  58543. declare module BABYLON {
  58544. /**
  58545. * Block used to expose an input value
  58546. */
  58547. export class InputBlock extends NodeMaterialBlock {
  58548. private _mode;
  58549. private _associatedVariableName;
  58550. private _storedValue;
  58551. private _valueCallback;
  58552. private _type;
  58553. private _animationType;
  58554. /** Gets or set a value used to limit the range of float values */
  58555. min: number;
  58556. /** Gets or set a value used to limit the range of float values */
  58557. max: number;
  58558. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58559. isBoolean: boolean;
  58560. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58561. matrixMode: number;
  58562. /** @hidden */
  58563. _systemValue: Nullable<NodeMaterialSystemValues>;
  58564. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58565. visibleInInspector: boolean;
  58566. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58567. isConstant: boolean;
  58568. /** Gets or sets the group to use to display this block in the Inspector */
  58569. groupInInspector: string;
  58570. /** Gets an observable raised when the value is changed */
  58571. onValueChangedObservable: Observable<InputBlock>;
  58572. /**
  58573. * Gets or sets the connection point type (default is float)
  58574. */
  58575. get type(): NodeMaterialBlockConnectionPointTypes;
  58576. /**
  58577. * Creates a new InputBlock
  58578. * @param name defines the block name
  58579. * @param target defines the target of that block (Vertex by default)
  58580. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58581. */
  58582. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58583. /**
  58584. * Gets the output component
  58585. */
  58586. get output(): NodeMaterialConnectionPoint;
  58587. /**
  58588. * Set the source of this connection point to a vertex attribute
  58589. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58590. * @returns the current connection point
  58591. */
  58592. setAsAttribute(attributeName?: string): InputBlock;
  58593. /**
  58594. * Set the source of this connection point to a system value
  58595. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58596. * @returns the current connection point
  58597. */
  58598. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58599. /**
  58600. * Gets or sets the value of that point.
  58601. * Please note that this value will be ignored if valueCallback is defined
  58602. */
  58603. get value(): any;
  58604. set value(value: any);
  58605. /**
  58606. * Gets or sets a callback used to get the value of that point.
  58607. * Please note that setting this value will force the connection point to ignore the value property
  58608. */
  58609. get valueCallback(): () => any;
  58610. set valueCallback(value: () => any);
  58611. /**
  58612. * Gets or sets the associated variable name in the shader
  58613. */
  58614. get associatedVariableName(): string;
  58615. set associatedVariableName(value: string);
  58616. /** Gets or sets the type of animation applied to the input */
  58617. get animationType(): AnimatedInputBlockTypes;
  58618. set animationType(value: AnimatedInputBlockTypes);
  58619. /**
  58620. * Gets a boolean indicating that this connection point not defined yet
  58621. */
  58622. get isUndefined(): boolean;
  58623. /**
  58624. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58625. * In this case the connection point name must be the name of the uniform to use.
  58626. * Can only be set on inputs
  58627. */
  58628. get isUniform(): boolean;
  58629. set isUniform(value: boolean);
  58630. /**
  58631. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58632. * In this case the connection point name must be the name of the attribute to use
  58633. * Can only be set on inputs
  58634. */
  58635. get isAttribute(): boolean;
  58636. set isAttribute(value: boolean);
  58637. /**
  58638. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58639. * Can only be set on exit points
  58640. */
  58641. get isVarying(): boolean;
  58642. set isVarying(value: boolean);
  58643. /**
  58644. * Gets a boolean indicating that the current connection point is a system value
  58645. */
  58646. get isSystemValue(): boolean;
  58647. /**
  58648. * Gets or sets the current well known value or null if not defined as a system value
  58649. */
  58650. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58651. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58652. /**
  58653. * Gets the current class name
  58654. * @returns the class name
  58655. */
  58656. getClassName(): string;
  58657. /**
  58658. * Animate the input if animationType !== None
  58659. * @param scene defines the rendering scene
  58660. */
  58661. animate(scene: Scene): void;
  58662. private _emitDefine;
  58663. initialize(state: NodeMaterialBuildState): void;
  58664. /**
  58665. * Set the input block to its default value (based on its type)
  58666. */
  58667. setDefaultValue(): void;
  58668. private _emitConstant;
  58669. private _emit;
  58670. /** @hidden */
  58671. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58672. /** @hidden */
  58673. _transmit(effect: Effect, scene: Scene): void;
  58674. protected _buildBlock(state: NodeMaterialBuildState): void;
  58675. protected _dumpPropertiesCode(): string;
  58676. dispose(): void;
  58677. serialize(): any;
  58678. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58679. }
  58680. }
  58681. declare module BABYLON {
  58682. /**
  58683. * Enum used to define the compatibility state between two connection points
  58684. */
  58685. export enum NodeMaterialConnectionPointCompatibilityStates {
  58686. /** Points are compatibles */
  58687. Compatible = 0,
  58688. /** Points are incompatible because of their types */
  58689. TypeIncompatible = 1,
  58690. /** Points are incompatible because of their targets (vertex vs fragment) */
  58691. TargetIncompatible = 2
  58692. }
  58693. /**
  58694. * Defines the direction of a connection point
  58695. */
  58696. export enum NodeMaterialConnectionPointDirection {
  58697. /** Input */
  58698. Input = 0,
  58699. /** Output */
  58700. Output = 1
  58701. }
  58702. /**
  58703. * Defines a connection point for a block
  58704. */
  58705. export class NodeMaterialConnectionPoint {
  58706. /** @hidden */
  58707. _ownerBlock: NodeMaterialBlock;
  58708. /** @hidden */
  58709. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58710. private _endpoints;
  58711. private _associatedVariableName;
  58712. private _direction;
  58713. /** @hidden */
  58714. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58715. /** @hidden */
  58716. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58717. private _type;
  58718. /** @hidden */
  58719. _enforceAssociatedVariableName: boolean;
  58720. /** Gets the direction of the point */
  58721. get direction(): NodeMaterialConnectionPointDirection;
  58722. /**
  58723. * Gets or sets the additional types supported by this connection point
  58724. */
  58725. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58726. /**
  58727. * Gets or sets the additional types excluded by this connection point
  58728. */
  58729. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58730. /**
  58731. * Observable triggered when this point is connected
  58732. */
  58733. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58734. /**
  58735. * Gets or sets the associated variable name in the shader
  58736. */
  58737. get associatedVariableName(): string;
  58738. set associatedVariableName(value: string);
  58739. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58740. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58741. /**
  58742. * Gets or sets the connection point type (default is float)
  58743. */
  58744. get type(): NodeMaterialBlockConnectionPointTypes;
  58745. set type(value: NodeMaterialBlockConnectionPointTypes);
  58746. /**
  58747. * Gets or sets the connection point name
  58748. */
  58749. name: string;
  58750. /**
  58751. * Gets or sets a boolean indicating that this connection point can be omitted
  58752. */
  58753. isOptional: boolean;
  58754. /**
  58755. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58756. */
  58757. define: string;
  58758. /** @hidden */
  58759. _prioritizeVertex: boolean;
  58760. private _target;
  58761. /** Gets or sets the target of that connection point */
  58762. get target(): NodeMaterialBlockTargets;
  58763. set target(value: NodeMaterialBlockTargets);
  58764. /**
  58765. * Gets a boolean indicating that the current point is connected
  58766. */
  58767. get isConnected(): boolean;
  58768. /**
  58769. * Gets a boolean indicating that the current point is connected to an input block
  58770. */
  58771. get isConnectedToInputBlock(): boolean;
  58772. /**
  58773. * Gets a the connected input block (if any)
  58774. */
  58775. get connectInputBlock(): Nullable<InputBlock>;
  58776. /** Get the other side of the connection (if any) */
  58777. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58778. /** Get the block that owns this connection point */
  58779. get ownerBlock(): NodeMaterialBlock;
  58780. /** Get the block connected on the other side of this connection (if any) */
  58781. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58782. /** Get the block connected on the endpoints of this connection (if any) */
  58783. get connectedBlocks(): Array<NodeMaterialBlock>;
  58784. /** Gets the list of connected endpoints */
  58785. get endpoints(): NodeMaterialConnectionPoint[];
  58786. /** Gets a boolean indicating if that output point is connected to at least one input */
  58787. get hasEndpoints(): boolean;
  58788. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58789. get isConnectedInVertexShader(): boolean;
  58790. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58791. get isConnectedInFragmentShader(): boolean;
  58792. /**
  58793. * Creates a new connection point
  58794. * @param name defines the connection point name
  58795. * @param ownerBlock defines the block hosting this connection point
  58796. * @param direction defines the direction of the connection point
  58797. */
  58798. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58799. /**
  58800. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58801. * @returns the class name
  58802. */
  58803. getClassName(): string;
  58804. /**
  58805. * Gets a boolean indicating if the current point can be connected to another point
  58806. * @param connectionPoint defines the other connection point
  58807. * @returns a boolean
  58808. */
  58809. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58810. /**
  58811. * Gets a number indicating if the current point can be connected to another point
  58812. * @param connectionPoint defines the other connection point
  58813. * @returns a number defining the compatibility state
  58814. */
  58815. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58816. /**
  58817. * Connect this point to another connection point
  58818. * @param connectionPoint defines the other connection point
  58819. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58820. * @returns the current connection point
  58821. */
  58822. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58823. /**
  58824. * Disconnect this point from one of his endpoint
  58825. * @param endpoint defines the other connection point
  58826. * @returns the current connection point
  58827. */
  58828. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58829. /**
  58830. * Serializes this point in a JSON representation
  58831. * @returns the serialized point object
  58832. */
  58833. serialize(): any;
  58834. /**
  58835. * Release resources
  58836. */
  58837. dispose(): void;
  58838. }
  58839. }
  58840. declare module BABYLON {
  58841. /**
  58842. * Block used to add support for vertex skinning (bones)
  58843. */
  58844. export class BonesBlock extends NodeMaterialBlock {
  58845. /**
  58846. * Creates a new BonesBlock
  58847. * @param name defines the block name
  58848. */
  58849. constructor(name: string);
  58850. /**
  58851. * Initialize the block and prepare the context for build
  58852. * @param state defines the state that will be used for the build
  58853. */
  58854. initialize(state: NodeMaterialBuildState): void;
  58855. /**
  58856. * Gets the current class name
  58857. * @returns the class name
  58858. */
  58859. getClassName(): string;
  58860. /**
  58861. * Gets the matrix indices input component
  58862. */
  58863. get matricesIndices(): NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the matrix weights input component
  58866. */
  58867. get matricesWeights(): NodeMaterialConnectionPoint;
  58868. /**
  58869. * Gets the extra matrix indices input component
  58870. */
  58871. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58872. /**
  58873. * Gets the extra matrix weights input component
  58874. */
  58875. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58876. /**
  58877. * Gets the world input component
  58878. */
  58879. get world(): NodeMaterialConnectionPoint;
  58880. /**
  58881. * Gets the output component
  58882. */
  58883. get output(): NodeMaterialConnectionPoint;
  58884. autoConfigure(material: NodeMaterial): void;
  58885. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58886. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58888. protected _buildBlock(state: NodeMaterialBuildState): this;
  58889. }
  58890. }
  58891. declare module BABYLON {
  58892. /**
  58893. * Block used to add support for instances
  58894. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58895. */
  58896. export class InstancesBlock extends NodeMaterialBlock {
  58897. /**
  58898. * Creates a new InstancesBlock
  58899. * @param name defines the block name
  58900. */
  58901. constructor(name: string);
  58902. /**
  58903. * Gets the current class name
  58904. * @returns the class name
  58905. */
  58906. getClassName(): string;
  58907. /**
  58908. * Gets the first world row input component
  58909. */
  58910. get world0(): NodeMaterialConnectionPoint;
  58911. /**
  58912. * Gets the second world row input component
  58913. */
  58914. get world1(): NodeMaterialConnectionPoint;
  58915. /**
  58916. * Gets the third world row input component
  58917. */
  58918. get world2(): NodeMaterialConnectionPoint;
  58919. /**
  58920. * Gets the forth world row input component
  58921. */
  58922. get world3(): NodeMaterialConnectionPoint;
  58923. /**
  58924. * Gets the world input component
  58925. */
  58926. get world(): NodeMaterialConnectionPoint;
  58927. /**
  58928. * Gets the output component
  58929. */
  58930. get output(): NodeMaterialConnectionPoint;
  58931. /**
  58932. * Gets the isntanceID component
  58933. */
  58934. get instanceID(): NodeMaterialConnectionPoint;
  58935. autoConfigure(material: NodeMaterial): void;
  58936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58937. protected _buildBlock(state: NodeMaterialBuildState): this;
  58938. }
  58939. }
  58940. declare module BABYLON {
  58941. /**
  58942. * Block used to add morph targets support to vertex shader
  58943. */
  58944. export class MorphTargetsBlock extends NodeMaterialBlock {
  58945. private _repeatableContentAnchor;
  58946. /**
  58947. * Create a new MorphTargetsBlock
  58948. * @param name defines the block name
  58949. */
  58950. constructor(name: string);
  58951. /**
  58952. * Gets the current class name
  58953. * @returns the class name
  58954. */
  58955. getClassName(): string;
  58956. /**
  58957. * Gets the position input component
  58958. */
  58959. get position(): NodeMaterialConnectionPoint;
  58960. /**
  58961. * Gets the normal input component
  58962. */
  58963. get normal(): NodeMaterialConnectionPoint;
  58964. /**
  58965. * Gets the tangent input component
  58966. */
  58967. get tangent(): NodeMaterialConnectionPoint;
  58968. /**
  58969. * Gets the tangent input component
  58970. */
  58971. get uv(): NodeMaterialConnectionPoint;
  58972. /**
  58973. * Gets the position output component
  58974. */
  58975. get positionOutput(): NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the normal output component
  58978. */
  58979. get normalOutput(): NodeMaterialConnectionPoint;
  58980. /**
  58981. * Gets the tangent output component
  58982. */
  58983. get tangentOutput(): NodeMaterialConnectionPoint;
  58984. /**
  58985. * Gets the tangent output component
  58986. */
  58987. get uvOutput(): NodeMaterialConnectionPoint;
  58988. initialize(state: NodeMaterialBuildState): void;
  58989. autoConfigure(material: NodeMaterial): void;
  58990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58991. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58992. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58993. protected _buildBlock(state: NodeMaterialBuildState): this;
  58994. }
  58995. }
  58996. declare module BABYLON {
  58997. /**
  58998. * Block used to get data information from a light
  58999. */
  59000. export class LightInformationBlock extends NodeMaterialBlock {
  59001. private _lightDataUniformName;
  59002. private _lightColorUniformName;
  59003. private _lightTypeDefineName;
  59004. /**
  59005. * Gets or sets the light associated with this block
  59006. */
  59007. light: Nullable<Light>;
  59008. /**
  59009. * Creates a new LightInformationBlock
  59010. * @param name defines the block name
  59011. */
  59012. constructor(name: string);
  59013. /**
  59014. * Gets the current class name
  59015. * @returns the class name
  59016. */
  59017. getClassName(): string;
  59018. /**
  59019. * Gets the world position input component
  59020. */
  59021. get worldPosition(): NodeMaterialConnectionPoint;
  59022. /**
  59023. * Gets the direction output component
  59024. */
  59025. get direction(): NodeMaterialConnectionPoint;
  59026. /**
  59027. * Gets the direction output component
  59028. */
  59029. get color(): NodeMaterialConnectionPoint;
  59030. /**
  59031. * Gets the direction output component
  59032. */
  59033. get intensity(): NodeMaterialConnectionPoint;
  59034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59036. protected _buildBlock(state: NodeMaterialBuildState): this;
  59037. serialize(): any;
  59038. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59039. }
  59040. }
  59041. declare module BABYLON {
  59042. /**
  59043. * Block used to add image processing support to fragment shader
  59044. */
  59045. export class ImageProcessingBlock extends NodeMaterialBlock {
  59046. /**
  59047. * Create a new ImageProcessingBlock
  59048. * @param name defines the block name
  59049. */
  59050. constructor(name: string);
  59051. /**
  59052. * Gets the current class name
  59053. * @returns the class name
  59054. */
  59055. getClassName(): string;
  59056. /**
  59057. * Gets the color input component
  59058. */
  59059. get color(): NodeMaterialConnectionPoint;
  59060. /**
  59061. * Gets the output component
  59062. */
  59063. get output(): NodeMaterialConnectionPoint;
  59064. /**
  59065. * Initialize the block and prepare the context for build
  59066. * @param state defines the state that will be used for the build
  59067. */
  59068. initialize(state: NodeMaterialBuildState): void;
  59069. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59072. protected _buildBlock(state: NodeMaterialBuildState): this;
  59073. }
  59074. }
  59075. declare module BABYLON {
  59076. /**
  59077. * Block used to pertub normals based on a normal map
  59078. */
  59079. export class PerturbNormalBlock extends NodeMaterialBlock {
  59080. private _tangentSpaceParameterName;
  59081. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59082. invertX: boolean;
  59083. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59084. invertY: boolean;
  59085. /**
  59086. * Create a new PerturbNormalBlock
  59087. * @param name defines the block name
  59088. */
  59089. constructor(name: string);
  59090. /**
  59091. * Gets the current class name
  59092. * @returns the class name
  59093. */
  59094. getClassName(): string;
  59095. /**
  59096. * Gets the world position input component
  59097. */
  59098. get worldPosition(): NodeMaterialConnectionPoint;
  59099. /**
  59100. * Gets the world normal input component
  59101. */
  59102. get worldNormal(): NodeMaterialConnectionPoint;
  59103. /**
  59104. * Gets the world tangent input component
  59105. */
  59106. get worldTangent(): NodeMaterialConnectionPoint;
  59107. /**
  59108. * Gets the uv input component
  59109. */
  59110. get uv(): NodeMaterialConnectionPoint;
  59111. /**
  59112. * Gets the normal map color input component
  59113. */
  59114. get normalMapColor(): NodeMaterialConnectionPoint;
  59115. /**
  59116. * Gets the strength input component
  59117. */
  59118. get strength(): NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the output component
  59121. */
  59122. get output(): NodeMaterialConnectionPoint;
  59123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59125. autoConfigure(material: NodeMaterial): void;
  59126. protected _buildBlock(state: NodeMaterialBuildState): this;
  59127. protected _dumpPropertiesCode(): string;
  59128. serialize(): any;
  59129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59130. }
  59131. }
  59132. declare module BABYLON {
  59133. /**
  59134. * Block used to discard a pixel if a value is smaller than a cutoff
  59135. */
  59136. export class DiscardBlock extends NodeMaterialBlock {
  59137. /**
  59138. * Create a new DiscardBlock
  59139. * @param name defines the block name
  59140. */
  59141. constructor(name: string);
  59142. /**
  59143. * Gets the current class name
  59144. * @returns the class name
  59145. */
  59146. getClassName(): string;
  59147. /**
  59148. * Gets the color input component
  59149. */
  59150. get value(): NodeMaterialConnectionPoint;
  59151. /**
  59152. * Gets the cutoff input component
  59153. */
  59154. get cutoff(): NodeMaterialConnectionPoint;
  59155. protected _buildBlock(state: NodeMaterialBuildState): this;
  59156. }
  59157. }
  59158. declare module BABYLON {
  59159. /**
  59160. * Block used to test if the fragment shader is front facing
  59161. */
  59162. export class FrontFacingBlock extends NodeMaterialBlock {
  59163. /**
  59164. * Creates a new FrontFacingBlock
  59165. * @param name defines the block name
  59166. */
  59167. constructor(name: string);
  59168. /**
  59169. * Gets the current class name
  59170. * @returns the class name
  59171. */
  59172. getClassName(): string;
  59173. /**
  59174. * Gets the output component
  59175. */
  59176. get output(): NodeMaterialConnectionPoint;
  59177. protected _buildBlock(state: NodeMaterialBuildState): this;
  59178. }
  59179. }
  59180. declare module BABYLON {
  59181. /**
  59182. * Block used to get the derivative value on x and y of a given input
  59183. */
  59184. export class DerivativeBlock extends NodeMaterialBlock {
  59185. /**
  59186. * Create a new DerivativeBlock
  59187. * @param name defines the block name
  59188. */
  59189. constructor(name: string);
  59190. /**
  59191. * Gets the current class name
  59192. * @returns the class name
  59193. */
  59194. getClassName(): string;
  59195. /**
  59196. * Gets the input component
  59197. */
  59198. get input(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the derivative output on x
  59201. */
  59202. get dx(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the derivative output on y
  59205. */
  59206. get dy(): NodeMaterialConnectionPoint;
  59207. protected _buildBlock(state: NodeMaterialBuildState): this;
  59208. }
  59209. }
  59210. declare module BABYLON {
  59211. /**
  59212. * Block used to add support for scene fog
  59213. */
  59214. export class FogBlock extends NodeMaterialBlock {
  59215. private _fogDistanceName;
  59216. private _fogParameters;
  59217. /**
  59218. * Create a new FogBlock
  59219. * @param name defines the block name
  59220. */
  59221. constructor(name: string);
  59222. /**
  59223. * Gets the current class name
  59224. * @returns the class name
  59225. */
  59226. getClassName(): string;
  59227. /**
  59228. * Gets the world position input component
  59229. */
  59230. get worldPosition(): NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the view input component
  59233. */
  59234. get view(): NodeMaterialConnectionPoint;
  59235. /**
  59236. * Gets the color input component
  59237. */
  59238. get input(): NodeMaterialConnectionPoint;
  59239. /**
  59240. * Gets the fog color input component
  59241. */
  59242. get fogColor(): NodeMaterialConnectionPoint;
  59243. /**
  59244. * Gets the output component
  59245. */
  59246. get output(): NodeMaterialConnectionPoint;
  59247. autoConfigure(material: NodeMaterial): void;
  59248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59250. protected _buildBlock(state: NodeMaterialBuildState): this;
  59251. }
  59252. }
  59253. declare module BABYLON {
  59254. /**
  59255. * Block used to add light in the fragment shader
  59256. */
  59257. export class LightBlock extends NodeMaterialBlock {
  59258. private _lightId;
  59259. /**
  59260. * Gets or sets the light associated with this block
  59261. */
  59262. light: Nullable<Light>;
  59263. /**
  59264. * Create a new LightBlock
  59265. * @param name defines the block name
  59266. */
  59267. constructor(name: string);
  59268. /**
  59269. * Gets the current class name
  59270. * @returns the class name
  59271. */
  59272. getClassName(): string;
  59273. /**
  59274. * Gets the world position input component
  59275. */
  59276. get worldPosition(): NodeMaterialConnectionPoint;
  59277. /**
  59278. * Gets the world normal input component
  59279. */
  59280. get worldNormal(): NodeMaterialConnectionPoint;
  59281. /**
  59282. * Gets the camera (or eye) position component
  59283. */
  59284. get cameraPosition(): NodeMaterialConnectionPoint;
  59285. /**
  59286. * Gets the glossiness component
  59287. */
  59288. get glossiness(): NodeMaterialConnectionPoint;
  59289. /**
  59290. * Gets the glossinness power component
  59291. */
  59292. get glossPower(): NodeMaterialConnectionPoint;
  59293. /**
  59294. * Gets the diffuse color component
  59295. */
  59296. get diffuseColor(): NodeMaterialConnectionPoint;
  59297. /**
  59298. * Gets the specular color component
  59299. */
  59300. get specularColor(): NodeMaterialConnectionPoint;
  59301. /**
  59302. * Gets the diffuse output component
  59303. */
  59304. get diffuseOutput(): NodeMaterialConnectionPoint;
  59305. /**
  59306. * Gets the specular output component
  59307. */
  59308. get specularOutput(): NodeMaterialConnectionPoint;
  59309. /**
  59310. * Gets the shadow output component
  59311. */
  59312. get shadow(): NodeMaterialConnectionPoint;
  59313. autoConfigure(material: NodeMaterial): void;
  59314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59315. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59317. private _injectVertexCode;
  59318. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59319. serialize(): any;
  59320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59321. }
  59322. }
  59323. declare module BABYLON {
  59324. /**
  59325. * Block used to multiply 2 values
  59326. */
  59327. export class MultiplyBlock extends NodeMaterialBlock {
  59328. /**
  59329. * Creates a new MultiplyBlock
  59330. * @param name defines the block name
  59331. */
  59332. constructor(name: string);
  59333. /**
  59334. * Gets the current class name
  59335. * @returns the class name
  59336. */
  59337. getClassName(): string;
  59338. /**
  59339. * Gets the left operand input component
  59340. */
  59341. get left(): NodeMaterialConnectionPoint;
  59342. /**
  59343. * Gets the right operand input component
  59344. */
  59345. get right(): NodeMaterialConnectionPoint;
  59346. /**
  59347. * Gets the output component
  59348. */
  59349. get output(): NodeMaterialConnectionPoint;
  59350. protected _buildBlock(state: NodeMaterialBuildState): this;
  59351. }
  59352. }
  59353. declare module BABYLON {
  59354. /**
  59355. * Block used to add 2 vectors
  59356. */
  59357. export class AddBlock extends NodeMaterialBlock {
  59358. /**
  59359. * Creates a new AddBlock
  59360. * @param name defines the block name
  59361. */
  59362. constructor(name: string);
  59363. /**
  59364. * Gets the current class name
  59365. * @returns the class name
  59366. */
  59367. getClassName(): string;
  59368. /**
  59369. * Gets the left operand input component
  59370. */
  59371. get left(): NodeMaterialConnectionPoint;
  59372. /**
  59373. * Gets the right operand input component
  59374. */
  59375. get right(): NodeMaterialConnectionPoint;
  59376. /**
  59377. * Gets the output component
  59378. */
  59379. get output(): NodeMaterialConnectionPoint;
  59380. protected _buildBlock(state: NodeMaterialBuildState): this;
  59381. }
  59382. }
  59383. declare module BABYLON {
  59384. /**
  59385. * Block used to scale a vector by a float
  59386. */
  59387. export class ScaleBlock extends NodeMaterialBlock {
  59388. /**
  59389. * Creates a new ScaleBlock
  59390. * @param name defines the block name
  59391. */
  59392. constructor(name: string);
  59393. /**
  59394. * Gets the current class name
  59395. * @returns the class name
  59396. */
  59397. getClassName(): string;
  59398. /**
  59399. * Gets the input component
  59400. */
  59401. get input(): NodeMaterialConnectionPoint;
  59402. /**
  59403. * Gets the factor input component
  59404. */
  59405. get factor(): NodeMaterialConnectionPoint;
  59406. /**
  59407. * Gets the output component
  59408. */
  59409. get output(): NodeMaterialConnectionPoint;
  59410. protected _buildBlock(state: NodeMaterialBuildState): this;
  59411. }
  59412. }
  59413. declare module BABYLON {
  59414. /**
  59415. * Block used to clamp a float
  59416. */
  59417. export class ClampBlock extends NodeMaterialBlock {
  59418. /** Gets or sets the minimum range */
  59419. minimum: number;
  59420. /** Gets or sets the maximum range */
  59421. maximum: number;
  59422. /**
  59423. * Creates a new ClampBlock
  59424. * @param name defines the block name
  59425. */
  59426. constructor(name: string);
  59427. /**
  59428. * Gets the current class name
  59429. * @returns the class name
  59430. */
  59431. getClassName(): string;
  59432. /**
  59433. * Gets the value input component
  59434. */
  59435. get value(): NodeMaterialConnectionPoint;
  59436. /**
  59437. * Gets the output component
  59438. */
  59439. get output(): NodeMaterialConnectionPoint;
  59440. protected _buildBlock(state: NodeMaterialBuildState): this;
  59441. protected _dumpPropertiesCode(): string;
  59442. serialize(): any;
  59443. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59444. }
  59445. }
  59446. declare module BABYLON {
  59447. /**
  59448. * Block used to apply a cross product between 2 vectors
  59449. */
  59450. export class CrossBlock extends NodeMaterialBlock {
  59451. /**
  59452. * Creates a new CrossBlock
  59453. * @param name defines the block name
  59454. */
  59455. constructor(name: string);
  59456. /**
  59457. * Gets the current class name
  59458. * @returns the class name
  59459. */
  59460. getClassName(): string;
  59461. /**
  59462. * Gets the left operand input component
  59463. */
  59464. get left(): NodeMaterialConnectionPoint;
  59465. /**
  59466. * Gets the right operand input component
  59467. */
  59468. get right(): NodeMaterialConnectionPoint;
  59469. /**
  59470. * Gets the output component
  59471. */
  59472. get output(): NodeMaterialConnectionPoint;
  59473. protected _buildBlock(state: NodeMaterialBuildState): this;
  59474. }
  59475. }
  59476. declare module BABYLON {
  59477. /**
  59478. * Block used to apply a dot product between 2 vectors
  59479. */
  59480. export class DotBlock extends NodeMaterialBlock {
  59481. /**
  59482. * Creates a new DotBlock
  59483. * @param name defines the block name
  59484. */
  59485. constructor(name: string);
  59486. /**
  59487. * Gets the current class name
  59488. * @returns the class name
  59489. */
  59490. getClassName(): string;
  59491. /**
  59492. * Gets the left operand input component
  59493. */
  59494. get left(): NodeMaterialConnectionPoint;
  59495. /**
  59496. * Gets the right operand input component
  59497. */
  59498. get right(): NodeMaterialConnectionPoint;
  59499. /**
  59500. * Gets the output component
  59501. */
  59502. get output(): NodeMaterialConnectionPoint;
  59503. protected _buildBlock(state: NodeMaterialBuildState): this;
  59504. }
  59505. }
  59506. declare module BABYLON {
  59507. /**
  59508. * Block used to remap a float from a range to a new one
  59509. */
  59510. export class RemapBlock extends NodeMaterialBlock {
  59511. /**
  59512. * Gets or sets the source range
  59513. */
  59514. sourceRange: Vector2;
  59515. /**
  59516. * Gets or sets the target range
  59517. */
  59518. targetRange: Vector2;
  59519. /**
  59520. * Creates a new RemapBlock
  59521. * @param name defines the block name
  59522. */
  59523. constructor(name: string);
  59524. /**
  59525. * Gets the current class name
  59526. * @returns the class name
  59527. */
  59528. getClassName(): string;
  59529. /**
  59530. * Gets the input component
  59531. */
  59532. get input(): NodeMaterialConnectionPoint;
  59533. /**
  59534. * Gets the source min input component
  59535. */
  59536. get sourceMin(): NodeMaterialConnectionPoint;
  59537. /**
  59538. * Gets the source max input component
  59539. */
  59540. get sourceMax(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Gets the target min input component
  59543. */
  59544. get targetMin(): NodeMaterialConnectionPoint;
  59545. /**
  59546. * Gets the target max input component
  59547. */
  59548. get targetMax(): NodeMaterialConnectionPoint;
  59549. /**
  59550. * Gets the output component
  59551. */
  59552. get output(): NodeMaterialConnectionPoint;
  59553. protected _buildBlock(state: NodeMaterialBuildState): this;
  59554. protected _dumpPropertiesCode(): string;
  59555. serialize(): any;
  59556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59557. }
  59558. }
  59559. declare module BABYLON {
  59560. /**
  59561. * Block used to normalize a vector
  59562. */
  59563. export class NormalizeBlock extends NodeMaterialBlock {
  59564. /**
  59565. * Creates a new NormalizeBlock
  59566. * @param name defines the block name
  59567. */
  59568. constructor(name: string);
  59569. /**
  59570. * Gets the current class name
  59571. * @returns the class name
  59572. */
  59573. getClassName(): string;
  59574. /**
  59575. * Gets the input component
  59576. */
  59577. get input(): NodeMaterialConnectionPoint;
  59578. /**
  59579. * Gets the output component
  59580. */
  59581. get output(): NodeMaterialConnectionPoint;
  59582. protected _buildBlock(state: NodeMaterialBuildState): this;
  59583. }
  59584. }
  59585. declare module BABYLON {
  59586. /**
  59587. * Operations supported by the Trigonometry block
  59588. */
  59589. export enum TrigonometryBlockOperations {
  59590. /** Cos */
  59591. Cos = 0,
  59592. /** Sin */
  59593. Sin = 1,
  59594. /** Abs */
  59595. Abs = 2,
  59596. /** Exp */
  59597. Exp = 3,
  59598. /** Exp2 */
  59599. Exp2 = 4,
  59600. /** Round */
  59601. Round = 5,
  59602. /** Floor */
  59603. Floor = 6,
  59604. /** Ceiling */
  59605. Ceiling = 7,
  59606. /** Square root */
  59607. Sqrt = 8,
  59608. /** Log */
  59609. Log = 9,
  59610. /** Tangent */
  59611. Tan = 10,
  59612. /** Arc tangent */
  59613. ArcTan = 11,
  59614. /** Arc cosinus */
  59615. ArcCos = 12,
  59616. /** Arc sinus */
  59617. ArcSin = 13,
  59618. /** Fraction */
  59619. Fract = 14,
  59620. /** Sign */
  59621. Sign = 15,
  59622. /** To radians (from degrees) */
  59623. Radians = 16,
  59624. /** To degrees (from radians) */
  59625. Degrees = 17
  59626. }
  59627. /**
  59628. * Block used to apply trigonometry operation to floats
  59629. */
  59630. export class TrigonometryBlock extends NodeMaterialBlock {
  59631. /**
  59632. * Gets or sets the operation applied by the block
  59633. */
  59634. operation: TrigonometryBlockOperations;
  59635. /**
  59636. * Creates a new TrigonometryBlock
  59637. * @param name defines the block name
  59638. */
  59639. constructor(name: string);
  59640. /**
  59641. * Gets the current class name
  59642. * @returns the class name
  59643. */
  59644. getClassName(): string;
  59645. /**
  59646. * Gets the input component
  59647. */
  59648. get input(): NodeMaterialConnectionPoint;
  59649. /**
  59650. * Gets the output component
  59651. */
  59652. get output(): NodeMaterialConnectionPoint;
  59653. protected _buildBlock(state: NodeMaterialBuildState): this;
  59654. serialize(): any;
  59655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59656. protected _dumpPropertiesCode(): string;
  59657. }
  59658. }
  59659. declare module BABYLON {
  59660. /**
  59661. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59662. */
  59663. export class ColorMergerBlock extends NodeMaterialBlock {
  59664. /**
  59665. * Create a new ColorMergerBlock
  59666. * @param name defines the block name
  59667. */
  59668. constructor(name: string);
  59669. /**
  59670. * Gets the current class name
  59671. * @returns the class name
  59672. */
  59673. getClassName(): string;
  59674. /**
  59675. * Gets the rgb component (input)
  59676. */
  59677. get rgbIn(): NodeMaterialConnectionPoint;
  59678. /**
  59679. * Gets the r component (input)
  59680. */
  59681. get r(): NodeMaterialConnectionPoint;
  59682. /**
  59683. * Gets the g component (input)
  59684. */
  59685. get g(): NodeMaterialConnectionPoint;
  59686. /**
  59687. * Gets the b component (input)
  59688. */
  59689. get b(): NodeMaterialConnectionPoint;
  59690. /**
  59691. * Gets the a component (input)
  59692. */
  59693. get a(): NodeMaterialConnectionPoint;
  59694. /**
  59695. * Gets the rgba component (output)
  59696. */
  59697. get rgba(): NodeMaterialConnectionPoint;
  59698. /**
  59699. * Gets the rgb component (output)
  59700. */
  59701. get rgbOut(): NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the rgb component (output)
  59704. * @deprecated Please use rgbOut instead.
  59705. */
  59706. get rgb(): NodeMaterialConnectionPoint;
  59707. protected _buildBlock(state: NodeMaterialBuildState): this;
  59708. }
  59709. }
  59710. declare module BABYLON {
  59711. /**
  59712. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59713. */
  59714. export class VectorMergerBlock extends NodeMaterialBlock {
  59715. /**
  59716. * Create a new VectorMergerBlock
  59717. * @param name defines the block name
  59718. */
  59719. constructor(name: string);
  59720. /**
  59721. * Gets the current class name
  59722. * @returns the class name
  59723. */
  59724. getClassName(): string;
  59725. /**
  59726. * Gets the xyz component (input)
  59727. */
  59728. get xyzIn(): NodeMaterialConnectionPoint;
  59729. /**
  59730. * Gets the xy component (input)
  59731. */
  59732. get xyIn(): NodeMaterialConnectionPoint;
  59733. /**
  59734. * Gets the x component (input)
  59735. */
  59736. get x(): NodeMaterialConnectionPoint;
  59737. /**
  59738. * Gets the y component (input)
  59739. */
  59740. get y(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the z component (input)
  59743. */
  59744. get z(): NodeMaterialConnectionPoint;
  59745. /**
  59746. * Gets the w component (input)
  59747. */
  59748. get w(): NodeMaterialConnectionPoint;
  59749. /**
  59750. * Gets the xyzw component (output)
  59751. */
  59752. get xyzw(): NodeMaterialConnectionPoint;
  59753. /**
  59754. * Gets the xyz component (output)
  59755. */
  59756. get xyzOut(): NodeMaterialConnectionPoint;
  59757. /**
  59758. * Gets the xy component (output)
  59759. */
  59760. get xyOut(): NodeMaterialConnectionPoint;
  59761. /**
  59762. * Gets the xy component (output)
  59763. * @deprecated Please use xyOut instead.
  59764. */
  59765. get xy(): NodeMaterialConnectionPoint;
  59766. /**
  59767. * Gets the xyz component (output)
  59768. * @deprecated Please use xyzOut instead.
  59769. */
  59770. get xyz(): NodeMaterialConnectionPoint;
  59771. protected _buildBlock(state: NodeMaterialBuildState): this;
  59772. }
  59773. }
  59774. declare module BABYLON {
  59775. /**
  59776. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59777. */
  59778. export class ColorSplitterBlock extends NodeMaterialBlock {
  59779. /**
  59780. * Create a new ColorSplitterBlock
  59781. * @param name defines the block name
  59782. */
  59783. constructor(name: string);
  59784. /**
  59785. * Gets the current class name
  59786. * @returns the class name
  59787. */
  59788. getClassName(): string;
  59789. /**
  59790. * Gets the rgba component (input)
  59791. */
  59792. get rgba(): NodeMaterialConnectionPoint;
  59793. /**
  59794. * Gets the rgb component (input)
  59795. */
  59796. get rgbIn(): NodeMaterialConnectionPoint;
  59797. /**
  59798. * Gets the rgb component (output)
  59799. */
  59800. get rgbOut(): NodeMaterialConnectionPoint;
  59801. /**
  59802. * Gets the r component (output)
  59803. */
  59804. get r(): NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the g component (output)
  59807. */
  59808. get g(): NodeMaterialConnectionPoint;
  59809. /**
  59810. * Gets the b component (output)
  59811. */
  59812. get b(): NodeMaterialConnectionPoint;
  59813. /**
  59814. * Gets the a component (output)
  59815. */
  59816. get a(): NodeMaterialConnectionPoint;
  59817. protected _inputRename(name: string): string;
  59818. protected _outputRename(name: string): string;
  59819. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59820. }
  59821. }
  59822. declare module BABYLON {
  59823. /**
  59824. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59825. */
  59826. export class VectorSplitterBlock extends NodeMaterialBlock {
  59827. /**
  59828. * Create a new VectorSplitterBlock
  59829. * @param name defines the block name
  59830. */
  59831. constructor(name: string);
  59832. /**
  59833. * Gets the current class name
  59834. * @returns the class name
  59835. */
  59836. getClassName(): string;
  59837. /**
  59838. * Gets the xyzw component (input)
  59839. */
  59840. get xyzw(): NodeMaterialConnectionPoint;
  59841. /**
  59842. * Gets the xyz component (input)
  59843. */
  59844. get xyzIn(): NodeMaterialConnectionPoint;
  59845. /**
  59846. * Gets the xy component (input)
  59847. */
  59848. get xyIn(): NodeMaterialConnectionPoint;
  59849. /**
  59850. * Gets the xyz component (output)
  59851. */
  59852. get xyzOut(): NodeMaterialConnectionPoint;
  59853. /**
  59854. * Gets the xy component (output)
  59855. */
  59856. get xyOut(): NodeMaterialConnectionPoint;
  59857. /**
  59858. * Gets the x component (output)
  59859. */
  59860. get x(): NodeMaterialConnectionPoint;
  59861. /**
  59862. * Gets the y component (output)
  59863. */
  59864. get y(): NodeMaterialConnectionPoint;
  59865. /**
  59866. * Gets the z component (output)
  59867. */
  59868. get z(): NodeMaterialConnectionPoint;
  59869. /**
  59870. * Gets the w component (output)
  59871. */
  59872. get w(): NodeMaterialConnectionPoint;
  59873. protected _inputRename(name: string): string;
  59874. protected _outputRename(name: string): string;
  59875. protected _buildBlock(state: NodeMaterialBuildState): this;
  59876. }
  59877. }
  59878. declare module BABYLON {
  59879. /**
  59880. * Block used to lerp between 2 values
  59881. */
  59882. export class LerpBlock extends NodeMaterialBlock {
  59883. /**
  59884. * Creates a new LerpBlock
  59885. * @param name defines the block name
  59886. */
  59887. constructor(name: string);
  59888. /**
  59889. * Gets the current class name
  59890. * @returns the class name
  59891. */
  59892. getClassName(): string;
  59893. /**
  59894. * Gets the left operand input component
  59895. */
  59896. get left(): NodeMaterialConnectionPoint;
  59897. /**
  59898. * Gets the right operand input component
  59899. */
  59900. get right(): NodeMaterialConnectionPoint;
  59901. /**
  59902. * Gets the gradient operand input component
  59903. */
  59904. get gradient(): NodeMaterialConnectionPoint;
  59905. /**
  59906. * Gets the output component
  59907. */
  59908. get output(): NodeMaterialConnectionPoint;
  59909. protected _buildBlock(state: NodeMaterialBuildState): this;
  59910. }
  59911. }
  59912. declare module BABYLON {
  59913. /**
  59914. * Block used to divide 2 vectors
  59915. */
  59916. export class DivideBlock extends NodeMaterialBlock {
  59917. /**
  59918. * Creates a new DivideBlock
  59919. * @param name defines the block name
  59920. */
  59921. constructor(name: string);
  59922. /**
  59923. * Gets the current class name
  59924. * @returns the class name
  59925. */
  59926. getClassName(): string;
  59927. /**
  59928. * Gets the left operand input component
  59929. */
  59930. get left(): NodeMaterialConnectionPoint;
  59931. /**
  59932. * Gets the right operand input component
  59933. */
  59934. get right(): NodeMaterialConnectionPoint;
  59935. /**
  59936. * Gets the output component
  59937. */
  59938. get output(): NodeMaterialConnectionPoint;
  59939. protected _buildBlock(state: NodeMaterialBuildState): this;
  59940. }
  59941. }
  59942. declare module BABYLON {
  59943. /**
  59944. * Block used to subtract 2 vectors
  59945. */
  59946. export class SubtractBlock extends NodeMaterialBlock {
  59947. /**
  59948. * Creates a new SubtractBlock
  59949. * @param name defines the block name
  59950. */
  59951. constructor(name: string);
  59952. /**
  59953. * Gets the current class name
  59954. * @returns the class name
  59955. */
  59956. getClassName(): string;
  59957. /**
  59958. * Gets the left operand input component
  59959. */
  59960. get left(): NodeMaterialConnectionPoint;
  59961. /**
  59962. * Gets the right operand input component
  59963. */
  59964. get right(): NodeMaterialConnectionPoint;
  59965. /**
  59966. * Gets the output component
  59967. */
  59968. get output(): NodeMaterialConnectionPoint;
  59969. protected _buildBlock(state: NodeMaterialBuildState): this;
  59970. }
  59971. }
  59972. declare module BABYLON {
  59973. /**
  59974. * Block used to step a value
  59975. */
  59976. export class StepBlock extends NodeMaterialBlock {
  59977. /**
  59978. * Creates a new StepBlock
  59979. * @param name defines the block name
  59980. */
  59981. constructor(name: string);
  59982. /**
  59983. * Gets the current class name
  59984. * @returns the class name
  59985. */
  59986. getClassName(): string;
  59987. /**
  59988. * Gets the value operand input component
  59989. */
  59990. get value(): NodeMaterialConnectionPoint;
  59991. /**
  59992. * Gets the edge operand input component
  59993. */
  59994. get edge(): NodeMaterialConnectionPoint;
  59995. /**
  59996. * Gets the output component
  59997. */
  59998. get output(): NodeMaterialConnectionPoint;
  59999. protected _buildBlock(state: NodeMaterialBuildState): this;
  60000. }
  60001. }
  60002. declare module BABYLON {
  60003. /**
  60004. * Block used to get the opposite (1 - x) of a value
  60005. */
  60006. export class OneMinusBlock extends NodeMaterialBlock {
  60007. /**
  60008. * Creates a new OneMinusBlock
  60009. * @param name defines the block name
  60010. */
  60011. constructor(name: string);
  60012. /**
  60013. * Gets the current class name
  60014. * @returns the class name
  60015. */
  60016. getClassName(): string;
  60017. /**
  60018. * Gets the input component
  60019. */
  60020. get input(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the output component
  60023. */
  60024. get output(): NodeMaterialConnectionPoint;
  60025. protected _buildBlock(state: NodeMaterialBuildState): this;
  60026. }
  60027. }
  60028. declare module BABYLON {
  60029. /**
  60030. * Block used to get the view direction
  60031. */
  60032. export class ViewDirectionBlock extends NodeMaterialBlock {
  60033. /**
  60034. * Creates a new ViewDirectionBlock
  60035. * @param name defines the block name
  60036. */
  60037. constructor(name: string);
  60038. /**
  60039. * Gets the current class name
  60040. * @returns the class name
  60041. */
  60042. getClassName(): string;
  60043. /**
  60044. * Gets the world position component
  60045. */
  60046. get worldPosition(): NodeMaterialConnectionPoint;
  60047. /**
  60048. * Gets the camera position component
  60049. */
  60050. get cameraPosition(): NodeMaterialConnectionPoint;
  60051. /**
  60052. * Gets the output component
  60053. */
  60054. get output(): NodeMaterialConnectionPoint;
  60055. autoConfigure(material: NodeMaterial): void;
  60056. protected _buildBlock(state: NodeMaterialBuildState): this;
  60057. }
  60058. }
  60059. declare module BABYLON {
  60060. /**
  60061. * Block used to compute fresnel value
  60062. */
  60063. export class FresnelBlock extends NodeMaterialBlock {
  60064. /**
  60065. * Create a new FresnelBlock
  60066. * @param name defines the block name
  60067. */
  60068. constructor(name: string);
  60069. /**
  60070. * Gets the current class name
  60071. * @returns the class name
  60072. */
  60073. getClassName(): string;
  60074. /**
  60075. * Gets the world normal input component
  60076. */
  60077. get worldNormal(): NodeMaterialConnectionPoint;
  60078. /**
  60079. * Gets the view direction input component
  60080. */
  60081. get viewDirection(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the bias input component
  60084. */
  60085. get bias(): NodeMaterialConnectionPoint;
  60086. /**
  60087. * Gets the camera (or eye) position component
  60088. */
  60089. get power(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the fresnel output component
  60092. */
  60093. get fresnel(): NodeMaterialConnectionPoint;
  60094. autoConfigure(material: NodeMaterial): void;
  60095. protected _buildBlock(state: NodeMaterialBuildState): this;
  60096. }
  60097. }
  60098. declare module BABYLON {
  60099. /**
  60100. * Block used to get the max of 2 values
  60101. */
  60102. export class MaxBlock extends NodeMaterialBlock {
  60103. /**
  60104. * Creates a new MaxBlock
  60105. * @param name defines the block name
  60106. */
  60107. constructor(name: string);
  60108. /**
  60109. * Gets the current class name
  60110. * @returns the class name
  60111. */
  60112. getClassName(): string;
  60113. /**
  60114. * Gets the left operand input component
  60115. */
  60116. get left(): NodeMaterialConnectionPoint;
  60117. /**
  60118. * Gets the right operand input component
  60119. */
  60120. get right(): NodeMaterialConnectionPoint;
  60121. /**
  60122. * Gets the output component
  60123. */
  60124. get output(): NodeMaterialConnectionPoint;
  60125. protected _buildBlock(state: NodeMaterialBuildState): this;
  60126. }
  60127. }
  60128. declare module BABYLON {
  60129. /**
  60130. * Block used to get the min of 2 values
  60131. */
  60132. export class MinBlock extends NodeMaterialBlock {
  60133. /**
  60134. * Creates a new MinBlock
  60135. * @param name defines the block name
  60136. */
  60137. constructor(name: string);
  60138. /**
  60139. * Gets the current class name
  60140. * @returns the class name
  60141. */
  60142. getClassName(): string;
  60143. /**
  60144. * Gets the left operand input component
  60145. */
  60146. get left(): NodeMaterialConnectionPoint;
  60147. /**
  60148. * Gets the right operand input component
  60149. */
  60150. get right(): NodeMaterialConnectionPoint;
  60151. /**
  60152. * Gets the output component
  60153. */
  60154. get output(): NodeMaterialConnectionPoint;
  60155. protected _buildBlock(state: NodeMaterialBuildState): this;
  60156. }
  60157. }
  60158. declare module BABYLON {
  60159. /**
  60160. * Block used to get the distance between 2 values
  60161. */
  60162. export class DistanceBlock extends NodeMaterialBlock {
  60163. /**
  60164. * Creates a new DistanceBlock
  60165. * @param name defines the block name
  60166. */
  60167. constructor(name: string);
  60168. /**
  60169. * Gets the current class name
  60170. * @returns the class name
  60171. */
  60172. getClassName(): string;
  60173. /**
  60174. * Gets the left operand input component
  60175. */
  60176. get left(): NodeMaterialConnectionPoint;
  60177. /**
  60178. * Gets the right operand input component
  60179. */
  60180. get right(): NodeMaterialConnectionPoint;
  60181. /**
  60182. * Gets the output component
  60183. */
  60184. get output(): NodeMaterialConnectionPoint;
  60185. protected _buildBlock(state: NodeMaterialBuildState): this;
  60186. }
  60187. }
  60188. declare module BABYLON {
  60189. /**
  60190. * Block used to get the length of a vector
  60191. */
  60192. export class LengthBlock extends NodeMaterialBlock {
  60193. /**
  60194. * Creates a new LengthBlock
  60195. * @param name defines the block name
  60196. */
  60197. constructor(name: string);
  60198. /**
  60199. * Gets the current class name
  60200. * @returns the class name
  60201. */
  60202. getClassName(): string;
  60203. /**
  60204. * Gets the value input component
  60205. */
  60206. get value(): NodeMaterialConnectionPoint;
  60207. /**
  60208. * Gets the output component
  60209. */
  60210. get output(): NodeMaterialConnectionPoint;
  60211. protected _buildBlock(state: NodeMaterialBuildState): this;
  60212. }
  60213. }
  60214. declare module BABYLON {
  60215. /**
  60216. * Block used to get negative version of a value (i.e. x * -1)
  60217. */
  60218. export class NegateBlock extends NodeMaterialBlock {
  60219. /**
  60220. * Creates a new NegateBlock
  60221. * @param name defines the block name
  60222. */
  60223. constructor(name: string);
  60224. /**
  60225. * Gets the current class name
  60226. * @returns the class name
  60227. */
  60228. getClassName(): string;
  60229. /**
  60230. * Gets the value input component
  60231. */
  60232. get value(): NodeMaterialConnectionPoint;
  60233. /**
  60234. * Gets the output component
  60235. */
  60236. get output(): NodeMaterialConnectionPoint;
  60237. protected _buildBlock(state: NodeMaterialBuildState): this;
  60238. }
  60239. }
  60240. declare module BABYLON {
  60241. /**
  60242. * Block used to get the value of the first parameter raised to the power of the second
  60243. */
  60244. export class PowBlock extends NodeMaterialBlock {
  60245. /**
  60246. * Creates a new PowBlock
  60247. * @param name defines the block name
  60248. */
  60249. constructor(name: string);
  60250. /**
  60251. * Gets the current class name
  60252. * @returns the class name
  60253. */
  60254. getClassName(): string;
  60255. /**
  60256. * Gets the value operand input component
  60257. */
  60258. get value(): NodeMaterialConnectionPoint;
  60259. /**
  60260. * Gets the power operand input component
  60261. */
  60262. get power(): NodeMaterialConnectionPoint;
  60263. /**
  60264. * Gets the output component
  60265. */
  60266. get output(): NodeMaterialConnectionPoint;
  60267. protected _buildBlock(state: NodeMaterialBuildState): this;
  60268. }
  60269. }
  60270. declare module BABYLON {
  60271. /**
  60272. * Block used to get a random number
  60273. */
  60274. export class RandomNumberBlock extends NodeMaterialBlock {
  60275. /**
  60276. * Creates a new RandomNumberBlock
  60277. * @param name defines the block name
  60278. */
  60279. constructor(name: string);
  60280. /**
  60281. * Gets the current class name
  60282. * @returns the class name
  60283. */
  60284. getClassName(): string;
  60285. /**
  60286. * Gets the seed input component
  60287. */
  60288. get seed(): NodeMaterialConnectionPoint;
  60289. /**
  60290. * Gets the output component
  60291. */
  60292. get output(): NodeMaterialConnectionPoint;
  60293. protected _buildBlock(state: NodeMaterialBuildState): this;
  60294. }
  60295. }
  60296. declare module BABYLON {
  60297. /**
  60298. * Block used to compute arc tangent of 2 values
  60299. */
  60300. export class ArcTan2Block extends NodeMaterialBlock {
  60301. /**
  60302. * Creates a new ArcTan2Block
  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 x operand input component
  60313. */
  60314. get x(): NodeMaterialConnectionPoint;
  60315. /**
  60316. * Gets the y operand input component
  60317. */
  60318. get y(): NodeMaterialConnectionPoint;
  60319. /**
  60320. * Gets the output component
  60321. */
  60322. get output(): NodeMaterialConnectionPoint;
  60323. protected _buildBlock(state: NodeMaterialBuildState): this;
  60324. }
  60325. }
  60326. declare module BABYLON {
  60327. /**
  60328. * Block used to smooth step a value
  60329. */
  60330. export class SmoothStepBlock extends NodeMaterialBlock {
  60331. /**
  60332. * Creates a new SmoothStepBlock
  60333. * @param name defines the block name
  60334. */
  60335. constructor(name: string);
  60336. /**
  60337. * Gets the current class name
  60338. * @returns the class name
  60339. */
  60340. getClassName(): string;
  60341. /**
  60342. * Gets the value operand input component
  60343. */
  60344. get value(): NodeMaterialConnectionPoint;
  60345. /**
  60346. * Gets the first edge operand input component
  60347. */
  60348. get edge0(): NodeMaterialConnectionPoint;
  60349. /**
  60350. * Gets the second edge operand input component
  60351. */
  60352. get edge1(): NodeMaterialConnectionPoint;
  60353. /**
  60354. * Gets the output component
  60355. */
  60356. get output(): NodeMaterialConnectionPoint;
  60357. protected _buildBlock(state: NodeMaterialBuildState): this;
  60358. }
  60359. }
  60360. declare module BABYLON {
  60361. /**
  60362. * Block used to get the reciprocal (1 / x) of a value
  60363. */
  60364. export class ReciprocalBlock extends NodeMaterialBlock {
  60365. /**
  60366. * Creates a new ReciprocalBlock
  60367. * @param name defines the block name
  60368. */
  60369. constructor(name: string);
  60370. /**
  60371. * Gets the current class name
  60372. * @returns the class name
  60373. */
  60374. getClassName(): string;
  60375. /**
  60376. * Gets the input component
  60377. */
  60378. get input(): NodeMaterialConnectionPoint;
  60379. /**
  60380. * Gets the output component
  60381. */
  60382. get output(): NodeMaterialConnectionPoint;
  60383. protected _buildBlock(state: NodeMaterialBuildState): this;
  60384. }
  60385. }
  60386. declare module BABYLON {
  60387. /**
  60388. * Block used to replace a color by another one
  60389. */
  60390. export class ReplaceColorBlock extends NodeMaterialBlock {
  60391. /**
  60392. * Creates a new ReplaceColorBlock
  60393. * @param name defines the block name
  60394. */
  60395. constructor(name: string);
  60396. /**
  60397. * Gets the current class name
  60398. * @returns the class name
  60399. */
  60400. getClassName(): string;
  60401. /**
  60402. * Gets the value input component
  60403. */
  60404. get value(): NodeMaterialConnectionPoint;
  60405. /**
  60406. * Gets the reference input component
  60407. */
  60408. get reference(): NodeMaterialConnectionPoint;
  60409. /**
  60410. * Gets the distance input component
  60411. */
  60412. get distance(): NodeMaterialConnectionPoint;
  60413. /**
  60414. * Gets the replacement input component
  60415. */
  60416. get replacement(): NodeMaterialConnectionPoint;
  60417. /**
  60418. * Gets the output component
  60419. */
  60420. get output(): NodeMaterialConnectionPoint;
  60421. protected _buildBlock(state: NodeMaterialBuildState): this;
  60422. }
  60423. }
  60424. declare module BABYLON {
  60425. /**
  60426. * Block used to posterize a value
  60427. * @see https://en.wikipedia.org/wiki/Posterization
  60428. */
  60429. export class PosterizeBlock extends NodeMaterialBlock {
  60430. /**
  60431. * Creates a new PosterizeBlock
  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 value input component
  60442. */
  60443. get value(): NodeMaterialConnectionPoint;
  60444. /**
  60445. * Gets the steps input component
  60446. */
  60447. get steps(): 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. * Operations supported by the Wave block
  60458. */
  60459. export enum WaveBlockKind {
  60460. /** SawTooth */
  60461. SawTooth = 0,
  60462. /** Square */
  60463. Square = 1,
  60464. /** Triangle */
  60465. Triangle = 2
  60466. }
  60467. /**
  60468. * Block used to apply wave operation to floats
  60469. */
  60470. export class WaveBlock extends NodeMaterialBlock {
  60471. /**
  60472. * Gets or sets the kibnd of wave to be applied by the block
  60473. */
  60474. kind: WaveBlockKind;
  60475. /**
  60476. * Creates a new WaveBlock
  60477. * @param name defines the block name
  60478. */
  60479. constructor(name: string);
  60480. /**
  60481. * Gets the current class name
  60482. * @returns the class name
  60483. */
  60484. getClassName(): string;
  60485. /**
  60486. * Gets the input component
  60487. */
  60488. get input(): NodeMaterialConnectionPoint;
  60489. /**
  60490. * Gets the output component
  60491. */
  60492. get output(): NodeMaterialConnectionPoint;
  60493. protected _buildBlock(state: NodeMaterialBuildState): this;
  60494. serialize(): any;
  60495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60496. }
  60497. }
  60498. declare module BABYLON {
  60499. /**
  60500. * Class used to store a color step for the GradientBlock
  60501. */
  60502. export class GradientBlockColorStep {
  60503. /**
  60504. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60505. */
  60506. step: number;
  60507. /**
  60508. * Gets or sets the color associated with this step
  60509. */
  60510. color: Color3;
  60511. /**
  60512. * Creates a new GradientBlockColorStep
  60513. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60514. * @param color defines the color associated with this step
  60515. */
  60516. constructor(
  60517. /**
  60518. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60519. */
  60520. step: number,
  60521. /**
  60522. * Gets or sets the color associated with this step
  60523. */
  60524. color: Color3);
  60525. }
  60526. /**
  60527. * Block used to return a color from a gradient based on an input value between 0 and 1
  60528. */
  60529. export class GradientBlock extends NodeMaterialBlock {
  60530. /**
  60531. * Gets or sets the list of color steps
  60532. */
  60533. colorSteps: GradientBlockColorStep[];
  60534. /**
  60535. * Creates a new GradientBlock
  60536. * @param name defines the block name
  60537. */
  60538. constructor(name: string);
  60539. /**
  60540. * Gets the current class name
  60541. * @returns the class name
  60542. */
  60543. getClassName(): string;
  60544. /**
  60545. * Gets the gradient input component
  60546. */
  60547. get gradient(): NodeMaterialConnectionPoint;
  60548. /**
  60549. * Gets the output component
  60550. */
  60551. get output(): NodeMaterialConnectionPoint;
  60552. private _writeColorConstant;
  60553. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60554. serialize(): any;
  60555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60556. protected _dumpPropertiesCode(): string;
  60557. }
  60558. }
  60559. declare module BABYLON {
  60560. /**
  60561. * Block used to normalize lerp between 2 values
  60562. */
  60563. export class NLerpBlock extends NodeMaterialBlock {
  60564. /**
  60565. * Creates a new NLerpBlock
  60566. * @param name defines the block name
  60567. */
  60568. constructor(name: string);
  60569. /**
  60570. * Gets the current class name
  60571. * @returns the class name
  60572. */
  60573. getClassName(): string;
  60574. /**
  60575. * Gets the left operand input component
  60576. */
  60577. get left(): NodeMaterialConnectionPoint;
  60578. /**
  60579. * Gets the right operand input component
  60580. */
  60581. get right(): NodeMaterialConnectionPoint;
  60582. /**
  60583. * Gets the gradient operand input component
  60584. */
  60585. get gradient(): NodeMaterialConnectionPoint;
  60586. /**
  60587. * Gets the output component
  60588. */
  60589. get output(): NodeMaterialConnectionPoint;
  60590. protected _buildBlock(state: NodeMaterialBuildState): this;
  60591. }
  60592. }
  60593. declare module BABYLON {
  60594. /**
  60595. * block used to Generate a Worley Noise 3D Noise Pattern
  60596. */
  60597. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60598. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60599. manhattanDistance: boolean;
  60600. /**
  60601. * Creates a new WorleyNoise3DBlock
  60602. * @param name defines the block name
  60603. */
  60604. constructor(name: string);
  60605. /**
  60606. * Gets the current class name
  60607. * @returns the class name
  60608. */
  60609. getClassName(): string;
  60610. /**
  60611. * Gets the seed input component
  60612. */
  60613. get seed(): NodeMaterialConnectionPoint;
  60614. /**
  60615. * Gets the jitter input component
  60616. */
  60617. get jitter(): NodeMaterialConnectionPoint;
  60618. /**
  60619. * Gets the output component
  60620. */
  60621. get output(): NodeMaterialConnectionPoint;
  60622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60623. /**
  60624. * Exposes the properties to the UI?
  60625. */
  60626. protected _dumpPropertiesCode(): string;
  60627. /**
  60628. * Exposes the properties to the Seralize?
  60629. */
  60630. serialize(): any;
  60631. /**
  60632. * Exposes the properties to the deseralize?
  60633. */
  60634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60635. }
  60636. }
  60637. declare module BABYLON {
  60638. /**
  60639. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60640. */
  60641. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60642. /**
  60643. * Creates a new SimplexPerlin3DBlock
  60644. * @param name defines the block name
  60645. */
  60646. constructor(name: string);
  60647. /**
  60648. * Gets the current class name
  60649. * @returns the class name
  60650. */
  60651. getClassName(): string;
  60652. /**
  60653. * Gets the seed operand input component
  60654. */
  60655. get seed(): NodeMaterialConnectionPoint;
  60656. /**
  60657. * Gets the output component
  60658. */
  60659. get output(): NodeMaterialConnectionPoint;
  60660. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60661. }
  60662. }
  60663. declare module BABYLON {
  60664. /**
  60665. * Block used to blend normals
  60666. */
  60667. export class NormalBlendBlock extends NodeMaterialBlock {
  60668. /**
  60669. * Creates a new NormalBlendBlock
  60670. * @param name defines the block name
  60671. */
  60672. constructor(name: string);
  60673. /**
  60674. * Gets the current class name
  60675. * @returns the class name
  60676. */
  60677. getClassName(): string;
  60678. /**
  60679. * Gets the first input component
  60680. */
  60681. get normalMap0(): NodeMaterialConnectionPoint;
  60682. /**
  60683. * Gets the second input component
  60684. */
  60685. get normalMap1(): NodeMaterialConnectionPoint;
  60686. /**
  60687. * Gets the output component
  60688. */
  60689. get output(): NodeMaterialConnectionPoint;
  60690. protected _buildBlock(state: NodeMaterialBuildState): this;
  60691. }
  60692. }
  60693. declare module BABYLON {
  60694. /**
  60695. * Block used to rotate a 2d vector by a given angle
  60696. */
  60697. export class Rotate2dBlock extends NodeMaterialBlock {
  60698. /**
  60699. * Creates a new Rotate2dBlock
  60700. * @param name defines the block name
  60701. */
  60702. constructor(name: string);
  60703. /**
  60704. * Gets the current class name
  60705. * @returns the class name
  60706. */
  60707. getClassName(): string;
  60708. /**
  60709. * Gets the input vector
  60710. */
  60711. get input(): NodeMaterialConnectionPoint;
  60712. /**
  60713. * Gets the input angle
  60714. */
  60715. get angle(): NodeMaterialConnectionPoint;
  60716. /**
  60717. * Gets the output component
  60718. */
  60719. get output(): NodeMaterialConnectionPoint;
  60720. autoConfigure(material: NodeMaterial): void;
  60721. protected _buildBlock(state: NodeMaterialBuildState): this;
  60722. }
  60723. }
  60724. declare module BABYLON {
  60725. /**
  60726. * Block used to get the reflected vector from a direction and a normal
  60727. */
  60728. export class ReflectBlock extends NodeMaterialBlock {
  60729. /**
  60730. * Creates a new ReflectBlock
  60731. * @param name defines the block name
  60732. */
  60733. constructor(name: string);
  60734. /**
  60735. * Gets the current class name
  60736. * @returns the class name
  60737. */
  60738. getClassName(): string;
  60739. /**
  60740. * Gets the incident component
  60741. */
  60742. get incident(): NodeMaterialConnectionPoint;
  60743. /**
  60744. * Gets the normal component
  60745. */
  60746. get normal(): NodeMaterialConnectionPoint;
  60747. /**
  60748. * Gets the output component
  60749. */
  60750. get output(): NodeMaterialConnectionPoint;
  60751. protected _buildBlock(state: NodeMaterialBuildState): this;
  60752. }
  60753. }
  60754. declare module BABYLON {
  60755. /**
  60756. * Block used to get the refracted vector from a direction and a normal
  60757. */
  60758. export class RefractBlock extends NodeMaterialBlock {
  60759. /**
  60760. * Creates a new RefractBlock
  60761. * @param name defines the block name
  60762. */
  60763. constructor(name: string);
  60764. /**
  60765. * Gets the current class name
  60766. * @returns the class name
  60767. */
  60768. getClassName(): string;
  60769. /**
  60770. * Gets the incident component
  60771. */
  60772. get incident(): NodeMaterialConnectionPoint;
  60773. /**
  60774. * Gets the normal component
  60775. */
  60776. get normal(): NodeMaterialConnectionPoint;
  60777. /**
  60778. * Gets the index of refraction component
  60779. */
  60780. get ior(): NodeMaterialConnectionPoint;
  60781. /**
  60782. * Gets the output component
  60783. */
  60784. get output(): NodeMaterialConnectionPoint;
  60785. protected _buildBlock(state: NodeMaterialBuildState): this;
  60786. }
  60787. }
  60788. declare module BABYLON {
  60789. /**
  60790. * Block used to desaturate a color
  60791. */
  60792. export class DesaturateBlock extends NodeMaterialBlock {
  60793. /**
  60794. * Creates a new DesaturateBlock
  60795. * @param name defines the block name
  60796. */
  60797. constructor(name: string);
  60798. /**
  60799. * Gets the current class name
  60800. * @returns the class name
  60801. */
  60802. getClassName(): string;
  60803. /**
  60804. * Gets the color operand input component
  60805. */
  60806. get color(): NodeMaterialConnectionPoint;
  60807. /**
  60808. * Gets the level operand input component
  60809. */
  60810. get level(): NodeMaterialConnectionPoint;
  60811. /**
  60812. * Gets the output component
  60813. */
  60814. get output(): NodeMaterialConnectionPoint;
  60815. protected _buildBlock(state: NodeMaterialBuildState): this;
  60816. }
  60817. }
  60818. declare module BABYLON {
  60819. /**
  60820. * Effect Render Options
  60821. */
  60822. export interface IEffectRendererOptions {
  60823. /**
  60824. * Defines the vertices positions.
  60825. */
  60826. positions?: number[];
  60827. /**
  60828. * Defines the indices.
  60829. */
  60830. indices?: number[];
  60831. }
  60832. /**
  60833. * Helper class to render one or more effects.
  60834. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60835. */
  60836. export class EffectRenderer {
  60837. private engine;
  60838. private static _DefaultOptions;
  60839. private _vertexBuffers;
  60840. private _indexBuffer;
  60841. private _fullscreenViewport;
  60842. /**
  60843. * Creates an effect renderer
  60844. * @param engine the engine to use for rendering
  60845. * @param options defines the options of the effect renderer
  60846. */
  60847. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60848. /**
  60849. * Sets the current viewport in normalized coordinates 0-1
  60850. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60851. */
  60852. setViewport(viewport?: Viewport): void;
  60853. /**
  60854. * Binds the embedded attributes buffer to the effect.
  60855. * @param effect Defines the effect to bind the attributes for
  60856. */
  60857. bindBuffers(effect: Effect): void;
  60858. /**
  60859. * Sets the current effect wrapper to use during draw.
  60860. * The effect needs to be ready before calling this api.
  60861. * This also sets the default full screen position attribute.
  60862. * @param effectWrapper Defines the effect to draw with
  60863. */
  60864. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60865. /**
  60866. * Draws a full screen quad.
  60867. */
  60868. draw(): void;
  60869. private isRenderTargetTexture;
  60870. /**
  60871. * renders one or more effects to a specified texture
  60872. * @param effectWrapper the effect to renderer
  60873. * @param outputTexture texture to draw to, if null it will render to the screen.
  60874. */
  60875. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60876. /**
  60877. * Disposes of the effect renderer
  60878. */
  60879. dispose(): void;
  60880. }
  60881. /**
  60882. * Options to create an EffectWrapper
  60883. */
  60884. interface EffectWrapperCreationOptions {
  60885. /**
  60886. * Engine to use to create the effect
  60887. */
  60888. engine: ThinEngine;
  60889. /**
  60890. * Fragment shader for the effect
  60891. */
  60892. fragmentShader: string;
  60893. /**
  60894. * Vertex shader for the effect
  60895. */
  60896. vertexShader?: string;
  60897. /**
  60898. * Attributes to use in the shader
  60899. */
  60900. attributeNames?: Array<string>;
  60901. /**
  60902. * Uniforms to use in the shader
  60903. */
  60904. uniformNames?: Array<string>;
  60905. /**
  60906. * Texture sampler names to use in the shader
  60907. */
  60908. samplerNames?: Array<string>;
  60909. /**
  60910. * The friendly name of the effect displayed in Spector.
  60911. */
  60912. name?: string;
  60913. }
  60914. /**
  60915. * Wraps an effect to be used for rendering
  60916. */
  60917. export class EffectWrapper {
  60918. /**
  60919. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60920. */
  60921. onApplyObservable: Observable<{}>;
  60922. /**
  60923. * The underlying effect
  60924. */
  60925. effect: Effect;
  60926. /**
  60927. * Creates an effect to be renderer
  60928. * @param creationOptions options to create the effect
  60929. */
  60930. constructor(creationOptions: EffectWrapperCreationOptions);
  60931. /**
  60932. * Disposes of the effect wrapper
  60933. */
  60934. dispose(): void;
  60935. }
  60936. }
  60937. declare module BABYLON {
  60938. /**
  60939. * Helper class to push actions to a pool of workers.
  60940. */
  60941. export class WorkerPool implements IDisposable {
  60942. private _workerInfos;
  60943. private _pendingActions;
  60944. /**
  60945. * Constructor
  60946. * @param workers Array of workers to use for actions
  60947. */
  60948. constructor(workers: Array<Worker>);
  60949. /**
  60950. * Terminates all workers and clears any pending actions.
  60951. */
  60952. dispose(): void;
  60953. /**
  60954. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60955. * pended until a worker has completed its action.
  60956. * @param action The action to perform. Call onComplete when the action is complete.
  60957. */
  60958. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60959. private _execute;
  60960. }
  60961. }
  60962. declare module BABYLON {
  60963. /**
  60964. * Configuration for Draco compression
  60965. */
  60966. export interface IDracoCompressionConfiguration {
  60967. /**
  60968. * Configuration for the decoder.
  60969. */
  60970. decoder: {
  60971. /**
  60972. * The url to the WebAssembly module.
  60973. */
  60974. wasmUrl?: string;
  60975. /**
  60976. * The url to the WebAssembly binary.
  60977. */
  60978. wasmBinaryUrl?: string;
  60979. /**
  60980. * The url to the fallback JavaScript module.
  60981. */
  60982. fallbackUrl?: string;
  60983. };
  60984. }
  60985. /**
  60986. * Draco compression (https://google.github.io/draco/)
  60987. *
  60988. * This class wraps the Draco module.
  60989. *
  60990. * **Encoder**
  60991. *
  60992. * The encoder is not currently implemented.
  60993. *
  60994. * **Decoder**
  60995. *
  60996. * 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.
  60997. *
  60998. * To update the configuration, use the following code:
  60999. * ```javascript
  61000. * DracoCompression.Configuration = {
  61001. * decoder: {
  61002. * wasmUrl: "<url to the WebAssembly library>",
  61003. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61004. * fallbackUrl: "<url to the fallback JavaScript library>",
  61005. * }
  61006. * };
  61007. * ```
  61008. *
  61009. * 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.
  61010. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61011. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61012. *
  61013. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61014. * ```javascript
  61015. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61016. * ```
  61017. *
  61018. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61019. */
  61020. export class DracoCompression implements IDisposable {
  61021. private _workerPoolPromise?;
  61022. private _decoderModulePromise?;
  61023. /**
  61024. * The configuration. Defaults to the following urls:
  61025. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61026. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61027. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61028. */
  61029. static Configuration: IDracoCompressionConfiguration;
  61030. /**
  61031. * Returns true if the decoder configuration is available.
  61032. */
  61033. static get DecoderAvailable(): boolean;
  61034. /**
  61035. * Default number of workers to create when creating the draco compression object.
  61036. */
  61037. static DefaultNumWorkers: number;
  61038. private static GetDefaultNumWorkers;
  61039. private static _Default;
  61040. /**
  61041. * Default instance for the draco compression object.
  61042. */
  61043. static get Default(): DracoCompression;
  61044. /**
  61045. * Constructor
  61046. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61047. */
  61048. constructor(numWorkers?: number);
  61049. /**
  61050. * Stop all async operations and release resources.
  61051. */
  61052. dispose(): void;
  61053. /**
  61054. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61055. * @returns a promise that resolves when ready
  61056. */
  61057. whenReadyAsync(): Promise<void>;
  61058. /**
  61059. * Decode Draco compressed mesh data to vertex data.
  61060. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61061. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61062. * @returns A promise that resolves with the decoded vertex data
  61063. */
  61064. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61065. [kind: string]: number;
  61066. }): Promise<VertexData>;
  61067. }
  61068. }
  61069. declare module BABYLON {
  61070. /**
  61071. * Class for building Constructive Solid Geometry
  61072. */
  61073. export class CSG {
  61074. private polygons;
  61075. /**
  61076. * The world matrix
  61077. */
  61078. matrix: Matrix;
  61079. /**
  61080. * Stores the position
  61081. */
  61082. position: Vector3;
  61083. /**
  61084. * Stores the rotation
  61085. */
  61086. rotation: Vector3;
  61087. /**
  61088. * Stores the rotation quaternion
  61089. */
  61090. rotationQuaternion: Nullable<Quaternion>;
  61091. /**
  61092. * Stores the scaling vector
  61093. */
  61094. scaling: Vector3;
  61095. /**
  61096. * Convert the Mesh to CSG
  61097. * @param mesh The Mesh to convert to CSG
  61098. * @returns A new CSG from the Mesh
  61099. */
  61100. static FromMesh(mesh: Mesh): CSG;
  61101. /**
  61102. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61103. * @param polygons Polygons used to construct a CSG solid
  61104. */
  61105. private static FromPolygons;
  61106. /**
  61107. * Clones, or makes a deep copy, of the CSG
  61108. * @returns A new CSG
  61109. */
  61110. clone(): CSG;
  61111. /**
  61112. * Unions this CSG with another CSG
  61113. * @param csg The CSG to union against this CSG
  61114. * @returns The unioned CSG
  61115. */
  61116. union(csg: CSG): CSG;
  61117. /**
  61118. * Unions this CSG with another CSG in place
  61119. * @param csg The CSG to union against this CSG
  61120. */
  61121. unionInPlace(csg: CSG): void;
  61122. /**
  61123. * Subtracts this CSG with another CSG
  61124. * @param csg The CSG to subtract against this CSG
  61125. * @returns A new CSG
  61126. */
  61127. subtract(csg: CSG): CSG;
  61128. /**
  61129. * Subtracts this CSG with another CSG in place
  61130. * @param csg The CSG to subtact against this CSG
  61131. */
  61132. subtractInPlace(csg: CSG): void;
  61133. /**
  61134. * Intersect this CSG with another CSG
  61135. * @param csg The CSG to intersect against this CSG
  61136. * @returns A new CSG
  61137. */
  61138. intersect(csg: CSG): CSG;
  61139. /**
  61140. * Intersects this CSG with another CSG in place
  61141. * @param csg The CSG to intersect against this CSG
  61142. */
  61143. intersectInPlace(csg: CSG): void;
  61144. /**
  61145. * Return a new CSG solid with solid and empty space switched. This solid is
  61146. * not modified.
  61147. * @returns A new CSG solid with solid and empty space switched
  61148. */
  61149. inverse(): CSG;
  61150. /**
  61151. * Inverses the CSG in place
  61152. */
  61153. inverseInPlace(): void;
  61154. /**
  61155. * This is used to keep meshes transformations so they can be restored
  61156. * when we build back a Babylon Mesh
  61157. * NB : All CSG operations are performed in world coordinates
  61158. * @param csg The CSG to copy the transform attributes from
  61159. * @returns This CSG
  61160. */
  61161. copyTransformAttributes(csg: CSG): CSG;
  61162. /**
  61163. * Build Raw mesh from CSG
  61164. * Coordinates here are in world space
  61165. * @param name The name of the mesh geometry
  61166. * @param scene The Scene
  61167. * @param keepSubMeshes Specifies if the submeshes should be kept
  61168. * @returns A new Mesh
  61169. */
  61170. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61171. /**
  61172. * Build Mesh from CSG taking material and transforms into account
  61173. * @param name The name of the Mesh
  61174. * @param material The material of the Mesh
  61175. * @param scene The Scene
  61176. * @param keepSubMeshes Specifies if submeshes should be kept
  61177. * @returns The new Mesh
  61178. */
  61179. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61180. }
  61181. }
  61182. declare module BABYLON {
  61183. /**
  61184. * Class used to create a trail following a mesh
  61185. */
  61186. export class TrailMesh extends Mesh {
  61187. private _generator;
  61188. private _autoStart;
  61189. private _running;
  61190. private _diameter;
  61191. private _length;
  61192. private _sectionPolygonPointsCount;
  61193. private _sectionVectors;
  61194. private _sectionNormalVectors;
  61195. private _beforeRenderObserver;
  61196. /**
  61197. * @constructor
  61198. * @param name The value used by scene.getMeshByName() to do a lookup.
  61199. * @param generator The mesh or transform node to generate a trail.
  61200. * @param scene The scene to add this mesh to.
  61201. * @param diameter Diameter of trailing mesh. Default is 1.
  61202. * @param length Length of trailing mesh. Default is 60.
  61203. * @param autoStart Automatically start trailing mesh. Default true.
  61204. */
  61205. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61206. /**
  61207. * "TrailMesh"
  61208. * @returns "TrailMesh"
  61209. */
  61210. getClassName(): string;
  61211. private _createMesh;
  61212. /**
  61213. * Start trailing mesh.
  61214. */
  61215. start(): void;
  61216. /**
  61217. * Stop trailing mesh.
  61218. */
  61219. stop(): void;
  61220. /**
  61221. * Update trailing mesh geometry.
  61222. */
  61223. update(): void;
  61224. /**
  61225. * Returns a new TrailMesh object.
  61226. * @param name is a string, the name given to the new mesh
  61227. * @param newGenerator use new generator object for cloned trail mesh
  61228. * @returns a new mesh
  61229. */
  61230. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61231. /**
  61232. * Serializes this trail mesh
  61233. * @param serializationObject object to write serialization to
  61234. */
  61235. serialize(serializationObject: any): void;
  61236. /**
  61237. * Parses a serialized trail mesh
  61238. * @param parsedMesh the serialized mesh
  61239. * @param scene the scene to create the trail mesh in
  61240. * @returns the created trail mesh
  61241. */
  61242. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61243. }
  61244. }
  61245. declare module BABYLON {
  61246. /**
  61247. * Class containing static functions to help procedurally build meshes
  61248. */
  61249. export class TiledBoxBuilder {
  61250. /**
  61251. * Creates a box mesh
  61252. * 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)
  61253. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61255. * * 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
  61256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61257. * @param name defines the name of the mesh
  61258. * @param options defines the options used to create the mesh
  61259. * @param scene defines the hosting scene
  61260. * @returns the box mesh
  61261. */
  61262. static CreateTiledBox(name: string, options: {
  61263. pattern?: number;
  61264. width?: number;
  61265. height?: number;
  61266. depth?: number;
  61267. tileSize?: number;
  61268. tileWidth?: number;
  61269. tileHeight?: number;
  61270. alignHorizontal?: number;
  61271. alignVertical?: number;
  61272. faceUV?: Vector4[];
  61273. faceColors?: Color4[];
  61274. sideOrientation?: number;
  61275. updatable?: boolean;
  61276. }, scene?: Nullable<Scene>): Mesh;
  61277. }
  61278. }
  61279. declare module BABYLON {
  61280. /**
  61281. * Class containing static functions to help procedurally build meshes
  61282. */
  61283. export class TorusKnotBuilder {
  61284. /**
  61285. * Creates a torus knot mesh
  61286. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61287. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61288. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61289. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61291. * * 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
  61292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61293. * @param name defines the name of the mesh
  61294. * @param options defines the options used to create the mesh
  61295. * @param scene defines the hosting scene
  61296. * @returns the torus knot mesh
  61297. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61298. */
  61299. static CreateTorusKnot(name: string, options: {
  61300. radius?: number;
  61301. tube?: number;
  61302. radialSegments?: number;
  61303. tubularSegments?: number;
  61304. p?: number;
  61305. q?: number;
  61306. updatable?: boolean;
  61307. sideOrientation?: number;
  61308. frontUVs?: Vector4;
  61309. backUVs?: Vector4;
  61310. }, scene: any): Mesh;
  61311. }
  61312. }
  61313. declare module BABYLON {
  61314. /**
  61315. * Polygon
  61316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61317. */
  61318. export class Polygon {
  61319. /**
  61320. * Creates a rectangle
  61321. * @param xmin bottom X coord
  61322. * @param ymin bottom Y coord
  61323. * @param xmax top X coord
  61324. * @param ymax top Y coord
  61325. * @returns points that make the resulting rectation
  61326. */
  61327. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61328. /**
  61329. * Creates a circle
  61330. * @param radius radius of circle
  61331. * @param cx scale in x
  61332. * @param cy scale in y
  61333. * @param numberOfSides number of sides that make up the circle
  61334. * @returns points that make the resulting circle
  61335. */
  61336. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61337. /**
  61338. * Creates a polygon from input string
  61339. * @param input Input polygon data
  61340. * @returns the parsed points
  61341. */
  61342. static Parse(input: string): Vector2[];
  61343. /**
  61344. * Starts building a polygon from x and y coordinates
  61345. * @param x x coordinate
  61346. * @param y y coordinate
  61347. * @returns the started path2
  61348. */
  61349. static StartingAt(x: number, y: number): Path2;
  61350. }
  61351. /**
  61352. * Builds a polygon
  61353. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61354. */
  61355. export class PolygonMeshBuilder {
  61356. private _points;
  61357. private _outlinepoints;
  61358. private _holes;
  61359. private _name;
  61360. private _scene;
  61361. private _epoints;
  61362. private _eholes;
  61363. private _addToepoint;
  61364. /**
  61365. * Babylon reference to the earcut plugin.
  61366. */
  61367. bjsEarcut: any;
  61368. /**
  61369. * Creates a PolygonMeshBuilder
  61370. * @param name name of the builder
  61371. * @param contours Path of the polygon
  61372. * @param scene scene to add to when creating the mesh
  61373. * @param earcutInjection can be used to inject your own earcut reference
  61374. */
  61375. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61376. /**
  61377. * Adds a whole within the polygon
  61378. * @param hole Array of points defining the hole
  61379. * @returns this
  61380. */
  61381. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61382. /**
  61383. * Creates the polygon
  61384. * @param updatable If the mesh should be updatable
  61385. * @param depth The depth of the mesh created
  61386. * @returns the created mesh
  61387. */
  61388. build(updatable?: boolean, depth?: number): Mesh;
  61389. /**
  61390. * Creates the polygon
  61391. * @param depth The depth of the mesh created
  61392. * @returns the created VertexData
  61393. */
  61394. buildVertexData(depth?: number): VertexData;
  61395. /**
  61396. * Adds a side to the polygon
  61397. * @param positions points that make the polygon
  61398. * @param normals normals of the polygon
  61399. * @param uvs uvs of the polygon
  61400. * @param indices indices of the polygon
  61401. * @param bounds bounds of the polygon
  61402. * @param points points of the polygon
  61403. * @param depth depth of the polygon
  61404. * @param flip flip of the polygon
  61405. */
  61406. private addSide;
  61407. }
  61408. }
  61409. declare module BABYLON {
  61410. /**
  61411. * Class containing static functions to help procedurally build meshes
  61412. */
  61413. export class PolygonBuilder {
  61414. /**
  61415. * Creates a polygon mesh
  61416. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61417. * * 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
  61418. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61420. * * 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)
  61421. * * Remember you can only change the shape positions, not their number when updating a polygon
  61422. * @param name defines the name of the mesh
  61423. * @param options defines the options used to create the mesh
  61424. * @param scene defines the hosting scene
  61425. * @param earcutInjection can be used to inject your own earcut reference
  61426. * @returns the polygon mesh
  61427. */
  61428. static CreatePolygon(name: string, options: {
  61429. shape: Vector3[];
  61430. holes?: Vector3[][];
  61431. depth?: number;
  61432. faceUV?: Vector4[];
  61433. faceColors?: Color4[];
  61434. updatable?: boolean;
  61435. sideOrientation?: number;
  61436. frontUVs?: Vector4;
  61437. backUVs?: Vector4;
  61438. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61439. /**
  61440. * Creates an extruded polygon mesh, with depth in the Y direction.
  61441. * * 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)
  61442. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61443. * @param name defines the name of the mesh
  61444. * @param options defines the options used to create the mesh
  61445. * @param scene defines the hosting scene
  61446. * @param earcutInjection can be used to inject your own earcut reference
  61447. * @returns the polygon mesh
  61448. */
  61449. static ExtrudePolygon(name: string, options: {
  61450. shape: Vector3[];
  61451. holes?: Vector3[][];
  61452. depth?: number;
  61453. faceUV?: Vector4[];
  61454. faceColors?: Color4[];
  61455. updatable?: boolean;
  61456. sideOrientation?: number;
  61457. frontUVs?: Vector4;
  61458. backUVs?: Vector4;
  61459. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61460. }
  61461. }
  61462. declare module BABYLON {
  61463. /**
  61464. * Class containing static functions to help procedurally build meshes
  61465. */
  61466. export class LatheBuilder {
  61467. /**
  61468. * Creates lathe mesh.
  61469. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61470. * * 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
  61471. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61472. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61473. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61474. * * 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
  61475. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61476. * * 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
  61477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61478. * * 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
  61479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61481. * @param name defines the name of the mesh
  61482. * @param options defines the options used to create the mesh
  61483. * @param scene defines the hosting scene
  61484. * @returns the lathe mesh
  61485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61486. */
  61487. static CreateLathe(name: string, options: {
  61488. shape: Vector3[];
  61489. radius?: number;
  61490. tessellation?: number;
  61491. clip?: number;
  61492. arc?: number;
  61493. closed?: boolean;
  61494. updatable?: boolean;
  61495. sideOrientation?: number;
  61496. frontUVs?: Vector4;
  61497. backUVs?: Vector4;
  61498. cap?: number;
  61499. invertUV?: boolean;
  61500. }, scene?: Nullable<Scene>): Mesh;
  61501. }
  61502. }
  61503. declare module BABYLON {
  61504. /**
  61505. * Class containing static functions to help procedurally build meshes
  61506. */
  61507. export class TiledPlaneBuilder {
  61508. /**
  61509. * Creates a tiled plane mesh
  61510. * * The parameter `pattern` will, depending on value, do nothing or
  61511. * * * flip (reflect about central vertical) alternate tiles across and up
  61512. * * * flip every tile on alternate rows
  61513. * * * rotate (180 degs) alternate tiles across and up
  61514. * * * rotate every tile on alternate rows
  61515. * * * flip and rotate alternate tiles across and up
  61516. * * * flip and rotate every tile on alternate rows
  61517. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61518. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61519. * * 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
  61520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61521. * * 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)
  61522. * * 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)
  61523. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61524. * @param name defines the name of the mesh
  61525. * @param options defines the options used to create the mesh
  61526. * @param scene defines the hosting scene
  61527. * @returns the box mesh
  61528. */
  61529. static CreateTiledPlane(name: string, options: {
  61530. pattern?: number;
  61531. tileSize?: number;
  61532. tileWidth?: number;
  61533. tileHeight?: number;
  61534. size?: number;
  61535. width?: number;
  61536. height?: number;
  61537. alignHorizontal?: number;
  61538. alignVertical?: number;
  61539. sideOrientation?: number;
  61540. frontUVs?: Vector4;
  61541. backUVs?: Vector4;
  61542. updatable?: boolean;
  61543. }, scene?: Nullable<Scene>): Mesh;
  61544. }
  61545. }
  61546. declare module BABYLON {
  61547. /**
  61548. * Class containing static functions to help procedurally build meshes
  61549. */
  61550. export class TubeBuilder {
  61551. /**
  61552. * Creates a tube mesh.
  61553. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61554. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61555. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61556. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61557. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61558. * * 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)
  61559. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61560. * * 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
  61561. * * 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
  61562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61563. * * 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
  61564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61566. * @param name defines the name of the mesh
  61567. * @param options defines the options used to create the mesh
  61568. * @param scene defines the hosting scene
  61569. * @returns the tube mesh
  61570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61571. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61572. */
  61573. static CreateTube(name: string, options: {
  61574. path: Vector3[];
  61575. radius?: number;
  61576. tessellation?: number;
  61577. radiusFunction?: {
  61578. (i: number, distance: number): number;
  61579. };
  61580. cap?: number;
  61581. arc?: number;
  61582. updatable?: boolean;
  61583. sideOrientation?: number;
  61584. frontUVs?: Vector4;
  61585. backUVs?: Vector4;
  61586. instance?: Mesh;
  61587. invertUV?: boolean;
  61588. }, scene?: Nullable<Scene>): Mesh;
  61589. }
  61590. }
  61591. declare module BABYLON {
  61592. /**
  61593. * Class containing static functions to help procedurally build meshes
  61594. */
  61595. export class IcoSphereBuilder {
  61596. /**
  61597. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61598. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61599. * * 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`)
  61600. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61601. * * 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
  61602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61603. * * 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
  61604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61605. * @param name defines the name of the mesh
  61606. * @param options defines the options used to create the mesh
  61607. * @param scene defines the hosting scene
  61608. * @returns the icosahedron mesh
  61609. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61610. */
  61611. static CreateIcoSphere(name: string, options: {
  61612. radius?: number;
  61613. radiusX?: number;
  61614. radiusY?: number;
  61615. radiusZ?: number;
  61616. flat?: boolean;
  61617. subdivisions?: number;
  61618. sideOrientation?: number;
  61619. frontUVs?: Vector4;
  61620. backUVs?: Vector4;
  61621. updatable?: boolean;
  61622. }, scene?: Nullable<Scene>): Mesh;
  61623. }
  61624. }
  61625. declare module BABYLON {
  61626. /**
  61627. * Class containing static functions to help procedurally build meshes
  61628. */
  61629. export class DecalBuilder {
  61630. /**
  61631. * Creates a decal mesh.
  61632. * 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
  61633. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61634. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61635. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61636. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61637. * @param name defines the name of the mesh
  61638. * @param sourceMesh defines the mesh where the decal must be applied
  61639. * @param options defines the options used to create the mesh
  61640. * @param scene defines the hosting scene
  61641. * @returns the decal mesh
  61642. * @see https://doc.babylonjs.com/how_to/decals
  61643. */
  61644. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61645. position?: Vector3;
  61646. normal?: Vector3;
  61647. size?: Vector3;
  61648. angle?: number;
  61649. }): Mesh;
  61650. }
  61651. }
  61652. declare module BABYLON {
  61653. /**
  61654. * Class containing static functions to help procedurally build meshes
  61655. */
  61656. export class MeshBuilder {
  61657. /**
  61658. * Creates a box mesh
  61659. * * The parameter `size` sets the size (float) of each box side (default 1)
  61660. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61661. * * 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)
  61662. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61664. * * 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
  61665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61666. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61667. * @param name defines the name of the mesh
  61668. * @param options defines the options used to create the mesh
  61669. * @param scene defines the hosting scene
  61670. * @returns the box mesh
  61671. */
  61672. static CreateBox(name: string, options: {
  61673. size?: number;
  61674. width?: number;
  61675. height?: number;
  61676. depth?: number;
  61677. faceUV?: Vector4[];
  61678. faceColors?: Color4[];
  61679. sideOrientation?: number;
  61680. frontUVs?: Vector4;
  61681. backUVs?: Vector4;
  61682. wrap?: boolean;
  61683. topBaseAt?: number;
  61684. bottomBaseAt?: number;
  61685. updatable?: boolean;
  61686. }, scene?: Nullable<Scene>): Mesh;
  61687. /**
  61688. * Creates a tiled box mesh
  61689. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61691. * @param name defines the name of the mesh
  61692. * @param options defines the options used to create the mesh
  61693. * @param scene defines the hosting scene
  61694. * @returns the tiled box mesh
  61695. */
  61696. static CreateTiledBox(name: string, options: {
  61697. pattern?: number;
  61698. size?: number;
  61699. width?: number;
  61700. height?: number;
  61701. depth: number;
  61702. tileSize?: number;
  61703. tileWidth?: number;
  61704. tileHeight?: number;
  61705. faceUV?: Vector4[];
  61706. faceColors?: Color4[];
  61707. alignHorizontal?: number;
  61708. alignVertical?: number;
  61709. sideOrientation?: number;
  61710. updatable?: boolean;
  61711. }, scene?: Nullable<Scene>): Mesh;
  61712. /**
  61713. * Creates a sphere mesh
  61714. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61715. * * 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`)
  61716. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61717. * * 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
  61718. * * 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)
  61719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61720. * * 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
  61721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61722. * @param name defines the name of the mesh
  61723. * @param options defines the options used to create the mesh
  61724. * @param scene defines the hosting scene
  61725. * @returns the sphere mesh
  61726. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61727. */
  61728. static CreateSphere(name: string, options: {
  61729. segments?: number;
  61730. diameter?: number;
  61731. diameterX?: number;
  61732. diameterY?: number;
  61733. diameterZ?: number;
  61734. arc?: number;
  61735. slice?: number;
  61736. sideOrientation?: number;
  61737. frontUVs?: Vector4;
  61738. backUVs?: Vector4;
  61739. updatable?: boolean;
  61740. }, scene?: Nullable<Scene>): Mesh;
  61741. /**
  61742. * Creates a plane polygonal mesh. By default, this is a disc
  61743. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61744. * * 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
  61745. * * 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
  61746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61747. * * 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
  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 plane polygonal mesh
  61753. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61754. */
  61755. static CreateDisc(name: string, options: {
  61756. radius?: number;
  61757. tessellation?: number;
  61758. arc?: number;
  61759. updatable?: boolean;
  61760. sideOrientation?: number;
  61761. frontUVs?: Vector4;
  61762. backUVs?: Vector4;
  61763. }, scene?: Nullable<Scene>): Mesh;
  61764. /**
  61765. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61766. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61767. * * 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`)
  61768. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61769. * * 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
  61770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61771. * * 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
  61772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61773. * @param name defines the name of the mesh
  61774. * @param options defines the options used to create the mesh
  61775. * @param scene defines the hosting scene
  61776. * @returns the icosahedron mesh
  61777. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61778. */
  61779. static CreateIcoSphere(name: string, options: {
  61780. radius?: number;
  61781. radiusX?: number;
  61782. radiusY?: number;
  61783. radiusZ?: number;
  61784. flat?: boolean;
  61785. subdivisions?: number;
  61786. sideOrientation?: number;
  61787. frontUVs?: Vector4;
  61788. backUVs?: Vector4;
  61789. updatable?: boolean;
  61790. }, scene?: Nullable<Scene>): Mesh;
  61791. /**
  61792. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61793. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61794. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61795. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61796. * * 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
  61797. * * 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
  61798. * * 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
  61799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61800. * * 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
  61801. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61802. * * 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
  61803. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61804. * * 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
  61805. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61807. * @param name defines the name of the mesh
  61808. * @param options defines the options used to create the mesh
  61809. * @param scene defines the hosting scene
  61810. * @returns the ribbon mesh
  61811. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61812. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61813. */
  61814. static CreateRibbon(name: string, options: {
  61815. pathArray: Vector3[][];
  61816. closeArray?: boolean;
  61817. closePath?: boolean;
  61818. offset?: number;
  61819. updatable?: boolean;
  61820. sideOrientation?: number;
  61821. frontUVs?: Vector4;
  61822. backUVs?: Vector4;
  61823. instance?: Mesh;
  61824. invertUV?: boolean;
  61825. uvs?: Vector2[];
  61826. colors?: Color4[];
  61827. }, scene?: Nullable<Scene>): Mesh;
  61828. /**
  61829. * Creates a cylinder or a cone mesh
  61830. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61831. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61832. * * 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.
  61833. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61834. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61835. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61836. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61837. * * 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).
  61838. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61839. * * 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).
  61840. * * 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
  61841. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61842. * * 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
  61843. * * 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.
  61844. * * If `enclose` is false, a ring surface is one element.
  61845. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61846. * * 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
  61847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61848. * * 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
  61849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61850. * @param name defines the name of the mesh
  61851. * @param options defines the options used to create the mesh
  61852. * @param scene defines the hosting scene
  61853. * @returns the cylinder mesh
  61854. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61855. */
  61856. static CreateCylinder(name: string, options: {
  61857. height?: number;
  61858. diameterTop?: number;
  61859. diameterBottom?: number;
  61860. diameter?: number;
  61861. tessellation?: number;
  61862. subdivisions?: number;
  61863. arc?: number;
  61864. faceColors?: Color4[];
  61865. faceUV?: Vector4[];
  61866. updatable?: boolean;
  61867. hasRings?: boolean;
  61868. enclose?: boolean;
  61869. cap?: number;
  61870. sideOrientation?: number;
  61871. frontUVs?: Vector4;
  61872. backUVs?: Vector4;
  61873. }, scene?: Nullable<Scene>): Mesh;
  61874. /**
  61875. * Creates a torus mesh
  61876. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61877. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61878. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61880. * * 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
  61881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61882. * @param name defines the name of the mesh
  61883. * @param options defines the options used to create the mesh
  61884. * @param scene defines the hosting scene
  61885. * @returns the torus mesh
  61886. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61887. */
  61888. static CreateTorus(name: string, options: {
  61889. diameter?: number;
  61890. thickness?: number;
  61891. tessellation?: number;
  61892. updatable?: boolean;
  61893. sideOrientation?: number;
  61894. frontUVs?: Vector4;
  61895. backUVs?: Vector4;
  61896. }, scene?: Nullable<Scene>): Mesh;
  61897. /**
  61898. * Creates a torus knot mesh
  61899. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61900. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61901. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61902. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61904. * * 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
  61905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61906. * @param name defines the name of the mesh
  61907. * @param options defines the options used to create the mesh
  61908. * @param scene defines the hosting scene
  61909. * @returns the torus knot mesh
  61910. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61911. */
  61912. static CreateTorusKnot(name: string, options: {
  61913. radius?: number;
  61914. tube?: number;
  61915. radialSegments?: number;
  61916. tubularSegments?: number;
  61917. p?: number;
  61918. q?: number;
  61919. updatable?: boolean;
  61920. sideOrientation?: number;
  61921. frontUVs?: Vector4;
  61922. backUVs?: Vector4;
  61923. }, scene?: Nullable<Scene>): Mesh;
  61924. /**
  61925. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61926. * * 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
  61927. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61928. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61929. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61930. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61931. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61932. * * 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
  61933. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61935. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61936. * @param name defines the name of the new line system
  61937. * @param options defines the options used to create the line system
  61938. * @param scene defines the hosting scene
  61939. * @returns a new line system mesh
  61940. */
  61941. static CreateLineSystem(name: string, options: {
  61942. lines: Vector3[][];
  61943. updatable?: boolean;
  61944. instance?: Nullable<LinesMesh>;
  61945. colors?: Nullable<Color4[][]>;
  61946. useVertexAlpha?: boolean;
  61947. }, scene: Nullable<Scene>): LinesMesh;
  61948. /**
  61949. * Creates a line mesh
  61950. * 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
  61951. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61952. * * The parameter `points` is an array successive Vector3
  61953. * * 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
  61954. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61955. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61956. * * When updating an instance, remember that only point positions can change, not the number of points
  61957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61959. * @param name defines the name of the new line system
  61960. * @param options defines the options used to create the line system
  61961. * @param scene defines the hosting scene
  61962. * @returns a new line mesh
  61963. */
  61964. static CreateLines(name: string, options: {
  61965. points: Vector3[];
  61966. updatable?: boolean;
  61967. instance?: Nullable<LinesMesh>;
  61968. colors?: Color4[];
  61969. useVertexAlpha?: boolean;
  61970. }, scene?: Nullable<Scene>): LinesMesh;
  61971. /**
  61972. * Creates a dashed line mesh
  61973. * * 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
  61974. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61975. * * The parameter `points` is an array successive Vector3
  61976. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61977. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61978. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61979. * * 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
  61980. * * When updating an instance, remember that only point positions can change, not the number of points
  61981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61982. * @param name defines the name of the mesh
  61983. * @param options defines the options used to create the mesh
  61984. * @param scene defines the hosting scene
  61985. * @returns the dashed line mesh
  61986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61987. */
  61988. static CreateDashedLines(name: string, options: {
  61989. points: Vector3[];
  61990. dashSize?: number;
  61991. gapSize?: number;
  61992. dashNb?: number;
  61993. updatable?: boolean;
  61994. instance?: LinesMesh;
  61995. }, scene?: Nullable<Scene>): LinesMesh;
  61996. /**
  61997. * 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.
  61998. * * 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.
  61999. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62000. * * 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.
  62001. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62002. * * 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
  62003. * * 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
  62004. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62006. * * 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
  62007. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62009. * @param name defines the name of the mesh
  62010. * @param options defines the options used to create the mesh
  62011. * @param scene defines the hosting scene
  62012. * @returns the extruded shape mesh
  62013. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62015. */
  62016. static ExtrudeShape(name: string, options: {
  62017. shape: Vector3[];
  62018. path: Vector3[];
  62019. scale?: number;
  62020. rotation?: number;
  62021. cap?: number;
  62022. updatable?: boolean;
  62023. sideOrientation?: number;
  62024. frontUVs?: Vector4;
  62025. backUVs?: Vector4;
  62026. instance?: Mesh;
  62027. invertUV?: boolean;
  62028. }, scene?: Nullable<Scene>): Mesh;
  62029. /**
  62030. * Creates an custom extruded shape mesh.
  62031. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62032. * * 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.
  62033. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62034. * * 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
  62035. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62036. * * 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
  62037. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62038. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62039. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62040. * * 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
  62041. * * 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
  62042. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62044. * * 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
  62045. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62047. * @param name defines the name of the mesh
  62048. * @param options defines the options used to create the mesh
  62049. * @param scene defines the hosting scene
  62050. * @returns the custom extruded shape mesh
  62051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62052. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62054. */
  62055. static ExtrudeShapeCustom(name: string, options: {
  62056. shape: Vector3[];
  62057. path: Vector3[];
  62058. scaleFunction?: any;
  62059. rotationFunction?: any;
  62060. ribbonCloseArray?: boolean;
  62061. ribbonClosePath?: boolean;
  62062. cap?: number;
  62063. updatable?: boolean;
  62064. sideOrientation?: number;
  62065. frontUVs?: Vector4;
  62066. backUVs?: Vector4;
  62067. instance?: Mesh;
  62068. invertUV?: boolean;
  62069. }, scene?: Nullable<Scene>): Mesh;
  62070. /**
  62071. * Creates lathe mesh.
  62072. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62073. * * 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
  62074. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62075. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62076. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62077. * * 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
  62078. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62079. * * 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
  62080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62081. * * 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
  62082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62084. * @param name defines the name of the mesh
  62085. * @param options defines the options used to create the mesh
  62086. * @param scene defines the hosting scene
  62087. * @returns the lathe mesh
  62088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62089. */
  62090. static CreateLathe(name: string, options: {
  62091. shape: Vector3[];
  62092. radius?: number;
  62093. tessellation?: number;
  62094. clip?: number;
  62095. arc?: number;
  62096. closed?: boolean;
  62097. updatable?: boolean;
  62098. sideOrientation?: number;
  62099. frontUVs?: Vector4;
  62100. backUVs?: Vector4;
  62101. cap?: number;
  62102. invertUV?: boolean;
  62103. }, scene?: Nullable<Scene>): Mesh;
  62104. /**
  62105. * Creates a tiled plane mesh
  62106. * * You can set a limited pattern arrangement with the tiles
  62107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62108. * * 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
  62109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62110. * @param name defines the name of the mesh
  62111. * @param options defines the options used to create the mesh
  62112. * @param scene defines the hosting scene
  62113. * @returns the plane mesh
  62114. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62115. */
  62116. static CreateTiledPlane(name: string, options: {
  62117. pattern?: number;
  62118. tileSize?: number;
  62119. tileWidth?: number;
  62120. tileHeight?: number;
  62121. size?: number;
  62122. width?: number;
  62123. height?: number;
  62124. alignHorizontal?: number;
  62125. alignVertical?: number;
  62126. sideOrientation?: number;
  62127. frontUVs?: Vector4;
  62128. backUVs?: Vector4;
  62129. updatable?: boolean;
  62130. }, scene?: Nullable<Scene>): Mesh;
  62131. /**
  62132. * Creates a plane mesh
  62133. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62134. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62135. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62137. * * 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
  62138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62139. * @param name defines the name of the mesh
  62140. * @param options defines the options used to create the mesh
  62141. * @param scene defines the hosting scene
  62142. * @returns the plane mesh
  62143. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62144. */
  62145. static CreatePlane(name: string, options: {
  62146. size?: number;
  62147. width?: number;
  62148. height?: number;
  62149. sideOrientation?: number;
  62150. frontUVs?: Vector4;
  62151. backUVs?: Vector4;
  62152. updatable?: boolean;
  62153. sourcePlane?: Plane;
  62154. }, scene?: Nullable<Scene>): Mesh;
  62155. /**
  62156. * Creates a ground mesh
  62157. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62158. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62160. * @param name defines the name of the mesh
  62161. * @param options defines the options used to create the mesh
  62162. * @param scene defines the hosting scene
  62163. * @returns the ground mesh
  62164. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62165. */
  62166. static CreateGround(name: string, options: {
  62167. width?: number;
  62168. height?: number;
  62169. subdivisions?: number;
  62170. subdivisionsX?: number;
  62171. subdivisionsY?: number;
  62172. updatable?: boolean;
  62173. }, scene?: Nullable<Scene>): Mesh;
  62174. /**
  62175. * Creates a tiled ground mesh
  62176. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62177. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62178. * * 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
  62179. * * 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
  62180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62181. * @param name defines the name of the mesh
  62182. * @param options defines the options used to create the mesh
  62183. * @param scene defines the hosting scene
  62184. * @returns the tiled ground mesh
  62185. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62186. */
  62187. static CreateTiledGround(name: string, options: {
  62188. xmin: number;
  62189. zmin: number;
  62190. xmax: number;
  62191. zmax: number;
  62192. subdivisions?: {
  62193. w: number;
  62194. h: number;
  62195. };
  62196. precision?: {
  62197. w: number;
  62198. h: number;
  62199. };
  62200. updatable?: boolean;
  62201. }, scene?: Nullable<Scene>): Mesh;
  62202. /**
  62203. * Creates a ground mesh from a height map
  62204. * * The parameter `url` sets the URL of the height map image resource.
  62205. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62206. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62207. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62208. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62209. * * 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.
  62210. * * 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).
  62211. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62213. * @param name defines the name of the mesh
  62214. * @param url defines the url to the height map
  62215. * @param options defines the options used to create the mesh
  62216. * @param scene defines the hosting scene
  62217. * @returns the ground mesh
  62218. * @see https://doc.babylonjs.com/babylon101/height_map
  62219. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62220. */
  62221. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62222. width?: number;
  62223. height?: number;
  62224. subdivisions?: number;
  62225. minHeight?: number;
  62226. maxHeight?: number;
  62227. colorFilter?: Color3;
  62228. alphaFilter?: number;
  62229. updatable?: boolean;
  62230. onReady?: (mesh: GroundMesh) => void;
  62231. }, scene?: Nullable<Scene>): GroundMesh;
  62232. /**
  62233. * Creates a polygon mesh
  62234. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62235. * * 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
  62236. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62238. * * 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)
  62239. * * Remember you can only change the shape positions, not their number when updating a polygon
  62240. * @param name defines the name of the mesh
  62241. * @param options defines the options used to create the mesh
  62242. * @param scene defines the hosting scene
  62243. * @param earcutInjection can be used to inject your own earcut reference
  62244. * @returns the polygon mesh
  62245. */
  62246. static CreatePolygon(name: string, options: {
  62247. shape: Vector3[];
  62248. holes?: Vector3[][];
  62249. depth?: number;
  62250. faceUV?: Vector4[];
  62251. faceColors?: Color4[];
  62252. updatable?: boolean;
  62253. sideOrientation?: number;
  62254. frontUVs?: Vector4;
  62255. backUVs?: Vector4;
  62256. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62257. /**
  62258. * Creates an extruded polygon mesh, with depth in the Y direction.
  62259. * * 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)
  62260. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62261. * @param name defines the name of the mesh
  62262. * @param options defines the options used to create the mesh
  62263. * @param scene defines the hosting scene
  62264. * @param earcutInjection can be used to inject your own earcut reference
  62265. * @returns the polygon mesh
  62266. */
  62267. static ExtrudePolygon(name: string, options: {
  62268. shape: Vector3[];
  62269. holes?: Vector3[][];
  62270. depth?: number;
  62271. faceUV?: Vector4[];
  62272. faceColors?: Color4[];
  62273. updatable?: boolean;
  62274. sideOrientation?: number;
  62275. frontUVs?: Vector4;
  62276. backUVs?: Vector4;
  62277. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62278. /**
  62279. * Creates a tube mesh.
  62280. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62281. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62282. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62283. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62284. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62285. * * 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)
  62286. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62287. * * 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
  62288. * * 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
  62289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62290. * * 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
  62291. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62293. * @param name defines the name of the mesh
  62294. * @param options defines the options used to create the mesh
  62295. * @param scene defines the hosting scene
  62296. * @returns the tube mesh
  62297. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62298. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62299. */
  62300. static CreateTube(name: string, options: {
  62301. path: Vector3[];
  62302. radius?: number;
  62303. tessellation?: number;
  62304. radiusFunction?: {
  62305. (i: number, distance: number): number;
  62306. };
  62307. cap?: number;
  62308. arc?: number;
  62309. updatable?: boolean;
  62310. sideOrientation?: number;
  62311. frontUVs?: Vector4;
  62312. backUVs?: Vector4;
  62313. instance?: Mesh;
  62314. invertUV?: boolean;
  62315. }, scene?: Nullable<Scene>): Mesh;
  62316. /**
  62317. * Creates a polyhedron mesh
  62318. * * 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
  62319. * * The parameter `size` (positive float, default 1) sets the polygon size
  62320. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62321. * * 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`
  62322. * * 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
  62323. * * 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)`)
  62324. * * 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
  62325. * * 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
  62326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62327. * * 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
  62328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62329. * @param name defines the name of the mesh
  62330. * @param options defines the options used to create the mesh
  62331. * @param scene defines the hosting scene
  62332. * @returns the polyhedron mesh
  62333. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62334. */
  62335. static CreatePolyhedron(name: string, options: {
  62336. type?: number;
  62337. size?: number;
  62338. sizeX?: number;
  62339. sizeY?: number;
  62340. sizeZ?: number;
  62341. custom?: any;
  62342. faceUV?: Vector4[];
  62343. faceColors?: Color4[];
  62344. flat?: boolean;
  62345. updatable?: boolean;
  62346. sideOrientation?: number;
  62347. frontUVs?: Vector4;
  62348. backUVs?: Vector4;
  62349. }, scene?: Nullable<Scene>): Mesh;
  62350. /**
  62351. * Creates a decal mesh.
  62352. * 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
  62353. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62354. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62355. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62356. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62357. * @param name defines the name of the mesh
  62358. * @param sourceMesh defines the mesh where the decal must be applied
  62359. * @param options defines the options used to create the mesh
  62360. * @param scene defines the hosting scene
  62361. * @returns the decal mesh
  62362. * @see https://doc.babylonjs.com/how_to/decals
  62363. */
  62364. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62365. position?: Vector3;
  62366. normal?: Vector3;
  62367. size?: Vector3;
  62368. angle?: number;
  62369. }): Mesh;
  62370. }
  62371. }
  62372. declare module BABYLON {
  62373. /**
  62374. * A simplifier interface for future simplification implementations
  62375. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62376. */
  62377. export interface ISimplifier {
  62378. /**
  62379. * Simplification of a given mesh according to the given settings.
  62380. * Since this requires computation, it is assumed that the function runs async.
  62381. * @param settings The settings of the simplification, including quality and distance
  62382. * @param successCallback A callback that will be called after the mesh was simplified.
  62383. * @param errorCallback in case of an error, this callback will be called. optional.
  62384. */
  62385. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62386. }
  62387. /**
  62388. * Expected simplification settings.
  62389. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62390. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62391. */
  62392. export interface ISimplificationSettings {
  62393. /**
  62394. * Gets or sets the expected quality
  62395. */
  62396. quality: number;
  62397. /**
  62398. * Gets or sets the distance when this optimized version should be used
  62399. */
  62400. distance: number;
  62401. /**
  62402. * Gets an already optimized mesh
  62403. */
  62404. optimizeMesh?: boolean;
  62405. }
  62406. /**
  62407. * Class used to specify simplification options
  62408. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62409. */
  62410. export class SimplificationSettings implements ISimplificationSettings {
  62411. /** expected quality */
  62412. quality: number;
  62413. /** distance when this optimized version should be used */
  62414. distance: number;
  62415. /** already optimized mesh */
  62416. optimizeMesh?: boolean | undefined;
  62417. /**
  62418. * Creates a SimplificationSettings
  62419. * @param quality expected quality
  62420. * @param distance distance when this optimized version should be used
  62421. * @param optimizeMesh already optimized mesh
  62422. */
  62423. constructor(
  62424. /** expected quality */
  62425. quality: number,
  62426. /** distance when this optimized version should be used */
  62427. distance: number,
  62428. /** already optimized mesh */
  62429. optimizeMesh?: boolean | undefined);
  62430. }
  62431. /**
  62432. * Interface used to define a simplification task
  62433. */
  62434. export interface ISimplificationTask {
  62435. /**
  62436. * Array of settings
  62437. */
  62438. settings: Array<ISimplificationSettings>;
  62439. /**
  62440. * Simplification type
  62441. */
  62442. simplificationType: SimplificationType;
  62443. /**
  62444. * Mesh to simplify
  62445. */
  62446. mesh: Mesh;
  62447. /**
  62448. * Callback called on success
  62449. */
  62450. successCallback?: () => void;
  62451. /**
  62452. * Defines if parallel processing can be used
  62453. */
  62454. parallelProcessing: boolean;
  62455. }
  62456. /**
  62457. * Queue used to order the simplification tasks
  62458. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62459. */
  62460. export class SimplificationQueue {
  62461. private _simplificationArray;
  62462. /**
  62463. * Gets a boolean indicating that the process is still running
  62464. */
  62465. running: boolean;
  62466. /**
  62467. * Creates a new queue
  62468. */
  62469. constructor();
  62470. /**
  62471. * Adds a new simplification task
  62472. * @param task defines a task to add
  62473. */
  62474. addTask(task: ISimplificationTask): void;
  62475. /**
  62476. * Execute next task
  62477. */
  62478. executeNext(): void;
  62479. /**
  62480. * Execute a simplification task
  62481. * @param task defines the task to run
  62482. */
  62483. runSimplification(task: ISimplificationTask): void;
  62484. private getSimplifier;
  62485. }
  62486. /**
  62487. * The implemented types of simplification
  62488. * At the moment only Quadratic Error Decimation is implemented
  62489. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62490. */
  62491. export enum SimplificationType {
  62492. /** Quadratic error decimation */
  62493. QUADRATIC = 0
  62494. }
  62495. /**
  62496. * An implementation of the Quadratic Error simplification algorithm.
  62497. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62498. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62499. * @author RaananW
  62500. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62501. */
  62502. export class QuadraticErrorSimplification implements ISimplifier {
  62503. private _mesh;
  62504. private triangles;
  62505. private vertices;
  62506. private references;
  62507. private _reconstructedMesh;
  62508. /** Gets or sets the number pf sync interations */
  62509. syncIterations: number;
  62510. /** Gets or sets the aggressiveness of the simplifier */
  62511. aggressiveness: number;
  62512. /** Gets or sets the number of allowed iterations for decimation */
  62513. decimationIterations: number;
  62514. /** Gets or sets the espilon to use for bounding box computation */
  62515. boundingBoxEpsilon: number;
  62516. /**
  62517. * Creates a new QuadraticErrorSimplification
  62518. * @param _mesh defines the target mesh
  62519. */
  62520. constructor(_mesh: Mesh);
  62521. /**
  62522. * Simplification of a given mesh according to the given settings.
  62523. * Since this requires computation, it is assumed that the function runs async.
  62524. * @param settings The settings of the simplification, including quality and distance
  62525. * @param successCallback A callback that will be called after the mesh was simplified.
  62526. */
  62527. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62528. private runDecimation;
  62529. private initWithMesh;
  62530. private init;
  62531. private reconstructMesh;
  62532. private initDecimatedMesh;
  62533. private isFlipped;
  62534. private updateTriangles;
  62535. private identifyBorder;
  62536. private updateMesh;
  62537. private vertexError;
  62538. private calculateError;
  62539. }
  62540. }
  62541. declare module BABYLON {
  62542. interface Scene {
  62543. /** @hidden (Backing field) */
  62544. _simplificationQueue: SimplificationQueue;
  62545. /**
  62546. * Gets or sets the simplification queue attached to the scene
  62547. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62548. */
  62549. simplificationQueue: SimplificationQueue;
  62550. }
  62551. interface Mesh {
  62552. /**
  62553. * Simplify the mesh according to the given array of settings.
  62554. * Function will return immediately and will simplify async
  62555. * @param settings a collection of simplification settings
  62556. * @param parallelProcessing should all levels calculate parallel or one after the other
  62557. * @param simplificationType the type of simplification to run
  62558. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62559. * @returns the current mesh
  62560. */
  62561. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62562. }
  62563. /**
  62564. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62565. * created in a scene
  62566. */
  62567. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62568. /**
  62569. * The component name helpfull to identify the component in the list of scene components.
  62570. */
  62571. readonly name: string;
  62572. /**
  62573. * The scene the component belongs to.
  62574. */
  62575. scene: Scene;
  62576. /**
  62577. * Creates a new instance of the component for the given scene
  62578. * @param scene Defines the scene to register the component in
  62579. */
  62580. constructor(scene: Scene);
  62581. /**
  62582. * Registers the component in a given scene
  62583. */
  62584. register(): void;
  62585. /**
  62586. * Rebuilds the elements related to this component in case of
  62587. * context lost for instance.
  62588. */
  62589. rebuild(): void;
  62590. /**
  62591. * Disposes the component and the associated ressources
  62592. */
  62593. dispose(): void;
  62594. private _beforeCameraUpdate;
  62595. }
  62596. }
  62597. declare module BABYLON {
  62598. /**
  62599. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62600. */
  62601. export interface INavigationEnginePlugin {
  62602. /**
  62603. * plugin name
  62604. */
  62605. name: string;
  62606. /**
  62607. * Creates a navigation mesh
  62608. * @param meshes array of all the geometry used to compute the navigatio mesh
  62609. * @param parameters bunch of parameters used to filter geometry
  62610. */
  62611. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62612. /**
  62613. * Create a navigation mesh debug mesh
  62614. * @param scene is where the mesh will be added
  62615. * @returns debug display mesh
  62616. */
  62617. createDebugNavMesh(scene: Scene): Mesh;
  62618. /**
  62619. * Get a navigation mesh constrained position, closest to the parameter position
  62620. * @param position world position
  62621. * @returns the closest point to position constrained by the navigation mesh
  62622. */
  62623. getClosestPoint(position: Vector3): Vector3;
  62624. /**
  62625. * Get a navigation mesh constrained position, closest to the parameter position
  62626. * @param position world position
  62627. * @param result output the closest point to position constrained by the navigation mesh
  62628. */
  62629. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62630. /**
  62631. * Get a navigation mesh constrained position, within a particular radius
  62632. * @param position world position
  62633. * @param maxRadius the maximum distance to the constrained world position
  62634. * @returns the closest point to position constrained by the navigation mesh
  62635. */
  62636. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62637. /**
  62638. * Get a navigation mesh constrained position, within a particular radius
  62639. * @param position world position
  62640. * @param maxRadius the maximum distance to the constrained world position
  62641. * @param result output the closest point to position constrained by the navigation mesh
  62642. */
  62643. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62644. /**
  62645. * Compute the final position from a segment made of destination-position
  62646. * @param position world position
  62647. * @param destination world position
  62648. * @returns the resulting point along the navmesh
  62649. */
  62650. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62651. /**
  62652. * Compute the final position from a segment made of destination-position
  62653. * @param position world position
  62654. * @param destination world position
  62655. * @param result output the resulting point along the navmesh
  62656. */
  62657. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62658. /**
  62659. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62660. * @param start world position
  62661. * @param end world position
  62662. * @returns array containing world position composing the path
  62663. */
  62664. computePath(start: Vector3, end: Vector3): Vector3[];
  62665. /**
  62666. * If this plugin is supported
  62667. * @returns true if plugin is supported
  62668. */
  62669. isSupported(): boolean;
  62670. /**
  62671. * Create a new Crowd so you can add agents
  62672. * @param maxAgents the maximum agent count in the crowd
  62673. * @param maxAgentRadius the maximum radius an agent can have
  62674. * @param scene to attach the crowd to
  62675. * @returns the crowd you can add agents to
  62676. */
  62677. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62678. /**
  62679. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62680. * The queries will try to find a solution within those bounds
  62681. * default is (1,1,1)
  62682. * @param extent x,y,z value that define the extent around the queries point of reference
  62683. */
  62684. setDefaultQueryExtent(extent: Vector3): void;
  62685. /**
  62686. * Get the Bounding box extent specified by setDefaultQueryExtent
  62687. * @returns the box extent values
  62688. */
  62689. getDefaultQueryExtent(): Vector3;
  62690. /**
  62691. * build the navmesh from a previously saved state using getNavmeshData
  62692. * @param data the Uint8Array returned by getNavmeshData
  62693. */
  62694. buildFromNavmeshData(data: Uint8Array): void;
  62695. /**
  62696. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62697. * @returns data the Uint8Array that can be saved and reused
  62698. */
  62699. getNavmeshData(): Uint8Array;
  62700. /**
  62701. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62702. * @param result output the box extent values
  62703. */
  62704. getDefaultQueryExtentToRef(result: Vector3): void;
  62705. /**
  62706. * Release all resources
  62707. */
  62708. dispose(): void;
  62709. }
  62710. /**
  62711. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62712. */
  62713. export interface ICrowd {
  62714. /**
  62715. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62716. * You can attach anything to that node. The node position is updated in the scene update tick.
  62717. * @param pos world position that will be constrained by the navigation mesh
  62718. * @param parameters agent parameters
  62719. * @param transform hooked to the agent that will be update by the scene
  62720. * @returns agent index
  62721. */
  62722. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62723. /**
  62724. * Returns the agent position in world space
  62725. * @param index agent index returned by addAgent
  62726. * @returns world space position
  62727. */
  62728. getAgentPosition(index: number): Vector3;
  62729. /**
  62730. * Gets the agent position result in world space
  62731. * @param index agent index returned by addAgent
  62732. * @param result output world space position
  62733. */
  62734. getAgentPositionToRef(index: number, result: Vector3): void;
  62735. /**
  62736. * Gets the agent velocity in world space
  62737. * @param index agent index returned by addAgent
  62738. * @returns world space velocity
  62739. */
  62740. getAgentVelocity(index: number): Vector3;
  62741. /**
  62742. * Gets the agent velocity result in world space
  62743. * @param index agent index returned by addAgent
  62744. * @param result output world space velocity
  62745. */
  62746. getAgentVelocityToRef(index: number, result: Vector3): void;
  62747. /**
  62748. * remove a particular agent previously created
  62749. * @param index agent index returned by addAgent
  62750. */
  62751. removeAgent(index: number): void;
  62752. /**
  62753. * get the list of all agents attached to this crowd
  62754. * @returns list of agent indices
  62755. */
  62756. getAgents(): number[];
  62757. /**
  62758. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62759. * @param deltaTime in seconds
  62760. */
  62761. update(deltaTime: number): void;
  62762. /**
  62763. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62764. * @param index agent index returned by addAgent
  62765. * @param destination targeted world position
  62766. */
  62767. agentGoto(index: number, destination: Vector3): void;
  62768. /**
  62769. * Teleport the agent to a new position
  62770. * @param index agent index returned by addAgent
  62771. * @param destination targeted world position
  62772. */
  62773. agentTeleport(index: number, destination: Vector3): void;
  62774. /**
  62775. * Update agent parameters
  62776. * @param index agent index returned by addAgent
  62777. * @param parameters agent parameters
  62778. */
  62779. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62780. /**
  62781. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62782. * The queries will try to find a solution within those bounds
  62783. * default is (1,1,1)
  62784. * @param extent x,y,z value that define the extent around the queries point of reference
  62785. */
  62786. setDefaultQueryExtent(extent: Vector3): void;
  62787. /**
  62788. * Get the Bounding box extent specified by setDefaultQueryExtent
  62789. * @returns the box extent values
  62790. */
  62791. getDefaultQueryExtent(): Vector3;
  62792. /**
  62793. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62794. * @param result output the box extent values
  62795. */
  62796. getDefaultQueryExtentToRef(result: Vector3): void;
  62797. /**
  62798. * Release all resources
  62799. */
  62800. dispose(): void;
  62801. }
  62802. /**
  62803. * Configures an agent
  62804. */
  62805. export interface IAgentParameters {
  62806. /**
  62807. * Agent radius. [Limit: >= 0]
  62808. */
  62809. radius: number;
  62810. /**
  62811. * Agent height. [Limit: > 0]
  62812. */
  62813. height: number;
  62814. /**
  62815. * Maximum allowed acceleration. [Limit: >= 0]
  62816. */
  62817. maxAcceleration: number;
  62818. /**
  62819. * Maximum allowed speed. [Limit: >= 0]
  62820. */
  62821. maxSpeed: number;
  62822. /**
  62823. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62824. */
  62825. collisionQueryRange: number;
  62826. /**
  62827. * The path visibility optimization range. [Limit: > 0]
  62828. */
  62829. pathOptimizationRange: number;
  62830. /**
  62831. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62832. */
  62833. separationWeight: number;
  62834. }
  62835. /**
  62836. * Configures the navigation mesh creation
  62837. */
  62838. export interface INavMeshParameters {
  62839. /**
  62840. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62841. */
  62842. cs: number;
  62843. /**
  62844. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62845. */
  62846. ch: number;
  62847. /**
  62848. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62849. */
  62850. walkableSlopeAngle: number;
  62851. /**
  62852. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62853. * be considered walkable. [Limit: >= 3] [Units: vx]
  62854. */
  62855. walkableHeight: number;
  62856. /**
  62857. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62858. */
  62859. walkableClimb: number;
  62860. /**
  62861. * The distance to erode/shrink the walkable area of the heightfield away from
  62862. * obstructions. [Limit: >=0] [Units: vx]
  62863. */
  62864. walkableRadius: number;
  62865. /**
  62866. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62867. */
  62868. maxEdgeLen: number;
  62869. /**
  62870. * The maximum distance a simplfied contour's border edges should deviate
  62871. * the original raw contour. [Limit: >=0] [Units: vx]
  62872. */
  62873. maxSimplificationError: number;
  62874. /**
  62875. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62876. */
  62877. minRegionArea: number;
  62878. /**
  62879. * Any regions with a span count smaller than this value will, if possible,
  62880. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62881. */
  62882. mergeRegionArea: number;
  62883. /**
  62884. * The maximum number of vertices allowed for polygons generated during the
  62885. * contour to polygon conversion process. [Limit: >= 3]
  62886. */
  62887. maxVertsPerPoly: number;
  62888. /**
  62889. * Sets the sampling distance to use when generating the detail mesh.
  62890. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62891. */
  62892. detailSampleDist: number;
  62893. /**
  62894. * The maximum distance the detail mesh surface should deviate from heightfield
  62895. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62896. */
  62897. detailSampleMaxError: number;
  62898. }
  62899. }
  62900. declare module BABYLON {
  62901. /**
  62902. * RecastJS navigation plugin
  62903. */
  62904. export class RecastJSPlugin implements INavigationEnginePlugin {
  62905. /**
  62906. * Reference to the Recast library
  62907. */
  62908. bjsRECAST: any;
  62909. /**
  62910. * plugin name
  62911. */
  62912. name: string;
  62913. /**
  62914. * the first navmesh created. We might extend this to support multiple navmeshes
  62915. */
  62916. navMesh: any;
  62917. /**
  62918. * Initializes the recastJS plugin
  62919. * @param recastInjection can be used to inject your own recast reference
  62920. */
  62921. constructor(recastInjection?: any);
  62922. /**
  62923. * Creates a navigation mesh
  62924. * @param meshes array of all the geometry used to compute the navigatio mesh
  62925. * @param parameters bunch of parameters used to filter geometry
  62926. */
  62927. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62928. /**
  62929. * Create a navigation mesh debug mesh
  62930. * @param scene is where the mesh will be added
  62931. * @returns debug display mesh
  62932. */
  62933. createDebugNavMesh(scene: Scene): Mesh;
  62934. /**
  62935. * Get a navigation mesh constrained position, closest to the parameter position
  62936. * @param position world position
  62937. * @returns the closest point to position constrained by the navigation mesh
  62938. */
  62939. getClosestPoint(position: Vector3): Vector3;
  62940. /**
  62941. * Get a navigation mesh constrained position, closest to the parameter position
  62942. * @param position world position
  62943. * @param result output the closest point to position constrained by the navigation mesh
  62944. */
  62945. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62946. /**
  62947. * Get a navigation mesh constrained position, within a particular radius
  62948. * @param position world position
  62949. * @param maxRadius the maximum distance to the constrained world position
  62950. * @returns the closest point to position constrained by the navigation mesh
  62951. */
  62952. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62953. /**
  62954. * Get a navigation mesh constrained position, within a particular radius
  62955. * @param position world position
  62956. * @param maxRadius the maximum distance to the constrained world position
  62957. * @param result output the closest point to position constrained by the navigation mesh
  62958. */
  62959. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62960. /**
  62961. * Compute the final position from a segment made of destination-position
  62962. * @param position world position
  62963. * @param destination world position
  62964. * @returns the resulting point along the navmesh
  62965. */
  62966. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62967. /**
  62968. * Compute the final position from a segment made of destination-position
  62969. * @param position world position
  62970. * @param destination world position
  62971. * @param result output the resulting point along the navmesh
  62972. */
  62973. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62974. /**
  62975. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62976. * @param start world position
  62977. * @param end world position
  62978. * @returns array containing world position composing the path
  62979. */
  62980. computePath(start: Vector3, end: Vector3): Vector3[];
  62981. /**
  62982. * Create a new Crowd so you can add agents
  62983. * @param maxAgents the maximum agent count in the crowd
  62984. * @param maxAgentRadius the maximum radius an agent can have
  62985. * @param scene to attach the crowd to
  62986. * @returns the crowd you can add agents to
  62987. */
  62988. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62989. /**
  62990. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62991. * The queries will try to find a solution within those bounds
  62992. * default is (1,1,1)
  62993. * @param extent x,y,z value that define the extent around the queries point of reference
  62994. */
  62995. setDefaultQueryExtent(extent: Vector3): void;
  62996. /**
  62997. * Get the Bounding box extent specified by setDefaultQueryExtent
  62998. * @returns the box extent values
  62999. */
  63000. getDefaultQueryExtent(): Vector3;
  63001. /**
  63002. * build the navmesh from a previously saved state using getNavmeshData
  63003. * @param data the Uint8Array returned by getNavmeshData
  63004. */
  63005. buildFromNavmeshData(data: Uint8Array): void;
  63006. /**
  63007. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63008. * @returns data the Uint8Array that can be saved and reused
  63009. */
  63010. getNavmeshData(): Uint8Array;
  63011. /**
  63012. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63013. * @param result output the box extent values
  63014. */
  63015. getDefaultQueryExtentToRef(result: Vector3): void;
  63016. /**
  63017. * Disposes
  63018. */
  63019. dispose(): void;
  63020. /**
  63021. * If this plugin is supported
  63022. * @returns true if plugin is supported
  63023. */
  63024. isSupported(): boolean;
  63025. }
  63026. /**
  63027. * Recast detour crowd implementation
  63028. */
  63029. export class RecastJSCrowd implements ICrowd {
  63030. /**
  63031. * Recast/detour plugin
  63032. */
  63033. bjsRECASTPlugin: RecastJSPlugin;
  63034. /**
  63035. * Link to the detour crowd
  63036. */
  63037. recastCrowd: any;
  63038. /**
  63039. * One transform per agent
  63040. */
  63041. transforms: TransformNode[];
  63042. /**
  63043. * All agents created
  63044. */
  63045. agents: number[];
  63046. /**
  63047. * Link to the scene is kept to unregister the crowd from the scene
  63048. */
  63049. private _scene;
  63050. /**
  63051. * Observer for crowd updates
  63052. */
  63053. private _onBeforeAnimationsObserver;
  63054. /**
  63055. * Constructor
  63056. * @param plugin recastJS plugin
  63057. * @param maxAgents the maximum agent count in the crowd
  63058. * @param maxAgentRadius the maximum radius an agent can have
  63059. * @param scene to attach the crowd to
  63060. * @returns the crowd you can add agents to
  63061. */
  63062. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63063. /**
  63064. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63065. * You can attach anything to that node. The node position is updated in the scene update tick.
  63066. * @param pos world position that will be constrained by the navigation mesh
  63067. * @param parameters agent parameters
  63068. * @param transform hooked to the agent that will be update by the scene
  63069. * @returns agent index
  63070. */
  63071. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63072. /**
  63073. * Returns the agent position in world space
  63074. * @param index agent index returned by addAgent
  63075. * @returns world space position
  63076. */
  63077. getAgentPosition(index: number): Vector3;
  63078. /**
  63079. * Returns the agent position result in world space
  63080. * @param index agent index returned by addAgent
  63081. * @param result output world space position
  63082. */
  63083. getAgentPositionToRef(index: number, result: Vector3): void;
  63084. /**
  63085. * Returns the agent velocity in world space
  63086. * @param index agent index returned by addAgent
  63087. * @returns world space velocity
  63088. */
  63089. getAgentVelocity(index: number): Vector3;
  63090. /**
  63091. * Returns the agent velocity result in world space
  63092. * @param index agent index returned by addAgent
  63093. * @param result output world space velocity
  63094. */
  63095. getAgentVelocityToRef(index: number, result: Vector3): void;
  63096. /**
  63097. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63098. * @param index agent index returned by addAgent
  63099. * @param destination targeted world position
  63100. */
  63101. agentGoto(index: number, destination: Vector3): void;
  63102. /**
  63103. * Teleport the agent to a new position
  63104. * @param index agent index returned by addAgent
  63105. * @param destination targeted world position
  63106. */
  63107. agentTeleport(index: number, destination: Vector3): void;
  63108. /**
  63109. * Update agent parameters
  63110. * @param index agent index returned by addAgent
  63111. * @param parameters agent parameters
  63112. */
  63113. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63114. /**
  63115. * remove a particular agent previously created
  63116. * @param index agent index returned by addAgent
  63117. */
  63118. removeAgent(index: number): void;
  63119. /**
  63120. * get the list of all agents attached to this crowd
  63121. * @returns list of agent indices
  63122. */
  63123. getAgents(): number[];
  63124. /**
  63125. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63126. * @param deltaTime in seconds
  63127. */
  63128. update(deltaTime: number): void;
  63129. /**
  63130. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63131. * The queries will try to find a solution within those bounds
  63132. * default is (1,1,1)
  63133. * @param extent x,y,z value that define the extent around the queries point of reference
  63134. */
  63135. setDefaultQueryExtent(extent: Vector3): void;
  63136. /**
  63137. * Get the Bounding box extent specified by setDefaultQueryExtent
  63138. * @returns the box extent values
  63139. */
  63140. getDefaultQueryExtent(): Vector3;
  63141. /**
  63142. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63143. * @param result output the box extent values
  63144. */
  63145. getDefaultQueryExtentToRef(result: Vector3): void;
  63146. /**
  63147. * Release all resources
  63148. */
  63149. dispose(): void;
  63150. }
  63151. }
  63152. declare module BABYLON {
  63153. /**
  63154. * Class used to enable access to IndexedDB
  63155. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63156. */
  63157. export class Database implements IOfflineProvider {
  63158. private _callbackManifestChecked;
  63159. private _currentSceneUrl;
  63160. private _db;
  63161. private _enableSceneOffline;
  63162. private _enableTexturesOffline;
  63163. private _manifestVersionFound;
  63164. private _mustUpdateRessources;
  63165. private _hasReachedQuota;
  63166. private _isSupported;
  63167. private _idbFactory;
  63168. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63169. private static IsUASupportingBlobStorage;
  63170. /**
  63171. * Gets a boolean indicating if Database storate is enabled (off by default)
  63172. */
  63173. static IDBStorageEnabled: boolean;
  63174. /**
  63175. * Gets a boolean indicating if scene must be saved in the database
  63176. */
  63177. get enableSceneOffline(): boolean;
  63178. /**
  63179. * Gets a boolean indicating if textures must be saved in the database
  63180. */
  63181. get enableTexturesOffline(): boolean;
  63182. /**
  63183. * Creates a new Database
  63184. * @param urlToScene defines the url to load the scene
  63185. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63186. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63187. */
  63188. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63189. private static _ParseURL;
  63190. private static _ReturnFullUrlLocation;
  63191. private _checkManifestFile;
  63192. /**
  63193. * Open the database and make it available
  63194. * @param successCallback defines the callback to call on success
  63195. * @param errorCallback defines the callback to call on error
  63196. */
  63197. open(successCallback: () => void, errorCallback: () => void): void;
  63198. /**
  63199. * Loads an image from the database
  63200. * @param url defines the url to load from
  63201. * @param image defines the target DOM image
  63202. */
  63203. loadImage(url: string, image: HTMLImageElement): void;
  63204. private _loadImageFromDBAsync;
  63205. private _saveImageIntoDBAsync;
  63206. private _checkVersionFromDB;
  63207. private _loadVersionFromDBAsync;
  63208. private _saveVersionIntoDBAsync;
  63209. /**
  63210. * Loads a file from database
  63211. * @param url defines the URL to load from
  63212. * @param sceneLoaded defines a callback to call on success
  63213. * @param progressCallBack defines a callback to call when progress changed
  63214. * @param errorCallback defines a callback to call on error
  63215. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63216. */
  63217. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63218. private _loadFileAsync;
  63219. private _saveFileAsync;
  63220. /**
  63221. * Validates if xhr data is correct
  63222. * @param xhr defines the request to validate
  63223. * @param dataType defines the expected data type
  63224. * @returns true if data is correct
  63225. */
  63226. private static _ValidateXHRData;
  63227. }
  63228. }
  63229. declare module BABYLON {
  63230. /** @hidden */
  63231. export var gpuUpdateParticlesPixelShader: {
  63232. name: string;
  63233. shader: string;
  63234. };
  63235. }
  63236. declare module BABYLON {
  63237. /** @hidden */
  63238. export var gpuUpdateParticlesVertexShader: {
  63239. name: string;
  63240. shader: string;
  63241. };
  63242. }
  63243. declare module BABYLON {
  63244. /** @hidden */
  63245. export var clipPlaneFragmentDeclaration2: {
  63246. name: string;
  63247. shader: string;
  63248. };
  63249. }
  63250. declare module BABYLON {
  63251. /** @hidden */
  63252. export var gpuRenderParticlesPixelShader: {
  63253. name: string;
  63254. shader: string;
  63255. };
  63256. }
  63257. declare module BABYLON {
  63258. /** @hidden */
  63259. export var clipPlaneVertexDeclaration2: {
  63260. name: string;
  63261. shader: string;
  63262. };
  63263. }
  63264. declare module BABYLON {
  63265. /** @hidden */
  63266. export var gpuRenderParticlesVertexShader: {
  63267. name: string;
  63268. shader: string;
  63269. };
  63270. }
  63271. declare module BABYLON {
  63272. /**
  63273. * This represents a GPU particle system in Babylon
  63274. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63275. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63276. */
  63277. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63278. /**
  63279. * The layer mask we are rendering the particles through.
  63280. */
  63281. layerMask: number;
  63282. private _capacity;
  63283. private _activeCount;
  63284. private _currentActiveCount;
  63285. private _accumulatedCount;
  63286. private _renderEffect;
  63287. private _updateEffect;
  63288. private _buffer0;
  63289. private _buffer1;
  63290. private _spriteBuffer;
  63291. private _updateVAO;
  63292. private _renderVAO;
  63293. private _targetIndex;
  63294. private _sourceBuffer;
  63295. private _targetBuffer;
  63296. private _engine;
  63297. private _currentRenderId;
  63298. private _started;
  63299. private _stopped;
  63300. private _timeDelta;
  63301. private _randomTexture;
  63302. private _randomTexture2;
  63303. private _attributesStrideSize;
  63304. private _updateEffectOptions;
  63305. private _randomTextureSize;
  63306. private _actualFrame;
  63307. private readonly _rawTextureWidth;
  63308. /**
  63309. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63310. */
  63311. static get IsSupported(): boolean;
  63312. /**
  63313. * An event triggered when the system is disposed.
  63314. */
  63315. onDisposeObservable: Observable<GPUParticleSystem>;
  63316. /**
  63317. * Gets the maximum number of particles active at the same time.
  63318. * @returns The max number of active particles.
  63319. */
  63320. getCapacity(): number;
  63321. /**
  63322. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63323. * to override the particles.
  63324. */
  63325. forceDepthWrite: boolean;
  63326. /**
  63327. * Gets or set the number of active particles
  63328. */
  63329. get activeParticleCount(): number;
  63330. set activeParticleCount(value: number);
  63331. private _preWarmDone;
  63332. /**
  63333. * Specifies if the particles are updated in emitter local space or world space.
  63334. * This is always false for GPU particles
  63335. */
  63336. get isLocal(): boolean;
  63337. set isLocal(value: boolean);
  63338. /**
  63339. * Is this system ready to be used/rendered
  63340. * @return true if the system is ready
  63341. */
  63342. isReady(): boolean;
  63343. /**
  63344. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63345. * @returns True if it has been started, otherwise false.
  63346. */
  63347. isStarted(): boolean;
  63348. /**
  63349. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63350. * @returns True if it has been stopped, otherwise false.
  63351. */
  63352. isStopped(): boolean;
  63353. /**
  63354. * Gets a boolean indicating that the system is stopping
  63355. * @returns true if the system is currently stopping
  63356. */
  63357. isStopping(): boolean;
  63358. /**
  63359. * Gets the number of particles active at the same time.
  63360. * @returns The number of active particles.
  63361. */
  63362. getActiveCount(): number;
  63363. /**
  63364. * Starts the particle system and begins to emit
  63365. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63366. */
  63367. start(delay?: number): void;
  63368. /**
  63369. * Stops the particle system.
  63370. */
  63371. stop(): void;
  63372. /**
  63373. * Remove all active particles
  63374. */
  63375. reset(): void;
  63376. /**
  63377. * Returns the string "GPUParticleSystem"
  63378. * @returns a string containing the class name
  63379. */
  63380. getClassName(): string;
  63381. private _colorGradientsTexture;
  63382. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63383. /**
  63384. * Adds a new color gradient
  63385. * @param gradient defines the gradient to use (between 0 and 1)
  63386. * @param color1 defines the color to affect to the specified gradient
  63387. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63388. * @returns the current particle system
  63389. */
  63390. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63391. private _refreshColorGradient;
  63392. /** Force the system to rebuild all gradients that need to be resync */
  63393. forceRefreshGradients(): void;
  63394. /**
  63395. * Remove a specific color gradient
  63396. * @param gradient defines the gradient to remove
  63397. * @returns the current particle system
  63398. */
  63399. removeColorGradient(gradient: number): GPUParticleSystem;
  63400. private _angularSpeedGradientsTexture;
  63401. private _sizeGradientsTexture;
  63402. private _velocityGradientsTexture;
  63403. private _limitVelocityGradientsTexture;
  63404. private _dragGradientsTexture;
  63405. private _addFactorGradient;
  63406. /**
  63407. * Adds a new size gradient
  63408. * @param gradient defines the gradient to use (between 0 and 1)
  63409. * @param factor defines the size factor to affect to the specified gradient
  63410. * @returns the current particle system
  63411. */
  63412. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63413. /**
  63414. * Remove a specific size gradient
  63415. * @param gradient defines the gradient to remove
  63416. * @returns the current particle system
  63417. */
  63418. removeSizeGradient(gradient: number): GPUParticleSystem;
  63419. private _refreshFactorGradient;
  63420. /**
  63421. * Adds a new angular speed gradient
  63422. * @param gradient defines the gradient to use (between 0 and 1)
  63423. * @param factor defines the angular speed to affect to the specified gradient
  63424. * @returns the current particle system
  63425. */
  63426. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63427. /**
  63428. * Remove a specific angular speed gradient
  63429. * @param gradient defines the gradient to remove
  63430. * @returns the current particle system
  63431. */
  63432. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63433. /**
  63434. * Adds a new velocity gradient
  63435. * @param gradient defines the gradient to use (between 0 and 1)
  63436. * @param factor defines the velocity to affect to the specified gradient
  63437. * @returns the current particle system
  63438. */
  63439. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63440. /**
  63441. * Remove a specific velocity gradient
  63442. * @param gradient defines the gradient to remove
  63443. * @returns the current particle system
  63444. */
  63445. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63446. /**
  63447. * Adds a new limit velocity gradient
  63448. * @param gradient defines the gradient to use (between 0 and 1)
  63449. * @param factor defines the limit velocity value to affect to the specified gradient
  63450. * @returns the current particle system
  63451. */
  63452. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63453. /**
  63454. * Remove a specific limit velocity gradient
  63455. * @param gradient defines the gradient to remove
  63456. * @returns the current particle system
  63457. */
  63458. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63459. /**
  63460. * Adds a new drag gradient
  63461. * @param gradient defines the gradient to use (between 0 and 1)
  63462. * @param factor defines the drag value to affect to the specified gradient
  63463. * @returns the current particle system
  63464. */
  63465. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63466. /**
  63467. * Remove a specific drag gradient
  63468. * @param gradient defines the gradient to remove
  63469. * @returns the current particle system
  63470. */
  63471. removeDragGradient(gradient: number): GPUParticleSystem;
  63472. /**
  63473. * Not supported by GPUParticleSystem
  63474. * @param gradient defines the gradient to use (between 0 and 1)
  63475. * @param factor defines the emit rate value to affect to the specified gradient
  63476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63477. * @returns the current particle system
  63478. */
  63479. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63480. /**
  63481. * Not supported by GPUParticleSystem
  63482. * @param gradient defines the gradient to remove
  63483. * @returns the current particle system
  63484. */
  63485. removeEmitRateGradient(gradient: number): IParticleSystem;
  63486. /**
  63487. * Not supported by GPUParticleSystem
  63488. * @param gradient defines the gradient to use (between 0 and 1)
  63489. * @param factor defines the start size value to affect to the specified gradient
  63490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63491. * @returns the current particle system
  63492. */
  63493. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63494. /**
  63495. * Not supported by GPUParticleSystem
  63496. * @param gradient defines the gradient to remove
  63497. * @returns the current particle system
  63498. */
  63499. removeStartSizeGradient(gradient: number): IParticleSystem;
  63500. /**
  63501. * Not supported by GPUParticleSystem
  63502. * @param gradient defines the gradient to use (between 0 and 1)
  63503. * @param min defines the color remap minimal range
  63504. * @param max defines the color remap maximal range
  63505. * @returns the current particle system
  63506. */
  63507. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63508. /**
  63509. * Not supported by GPUParticleSystem
  63510. * @param gradient defines the gradient to remove
  63511. * @returns the current particle system
  63512. */
  63513. removeColorRemapGradient(): IParticleSystem;
  63514. /**
  63515. * Not supported by GPUParticleSystem
  63516. * @param gradient defines the gradient to use (between 0 and 1)
  63517. * @param min defines the alpha remap minimal range
  63518. * @param max defines the alpha remap maximal range
  63519. * @returns the current particle system
  63520. */
  63521. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63522. /**
  63523. * Not supported by GPUParticleSystem
  63524. * @param gradient defines the gradient to remove
  63525. * @returns the current particle system
  63526. */
  63527. removeAlphaRemapGradient(): IParticleSystem;
  63528. /**
  63529. * Not supported by GPUParticleSystem
  63530. * @param gradient defines the gradient to use (between 0 and 1)
  63531. * @param color defines the color to affect to the specified gradient
  63532. * @returns the current particle system
  63533. */
  63534. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63535. /**
  63536. * Not supported by GPUParticleSystem
  63537. * @param gradient defines the gradient to remove
  63538. * @returns the current particle system
  63539. */
  63540. removeRampGradient(): IParticleSystem;
  63541. /**
  63542. * Not supported by GPUParticleSystem
  63543. * @returns the list of ramp gradients
  63544. */
  63545. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63546. /**
  63547. * Not supported by GPUParticleSystem
  63548. * Gets or sets a boolean indicating that ramp gradients must be used
  63549. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63550. */
  63551. get useRampGradients(): boolean;
  63552. set useRampGradients(value: boolean);
  63553. /**
  63554. * Not supported by GPUParticleSystem
  63555. * @param gradient defines the gradient to use (between 0 and 1)
  63556. * @param factor defines the life time factor to affect to the specified gradient
  63557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63558. * @returns the current particle system
  63559. */
  63560. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63561. /**
  63562. * Not supported by GPUParticleSystem
  63563. * @param gradient defines the gradient to remove
  63564. * @returns the current particle system
  63565. */
  63566. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63567. /**
  63568. * Instantiates a GPU particle system.
  63569. * 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.
  63570. * @param name The name of the particle system
  63571. * @param options The options used to create the system
  63572. * @param scene The scene the particle system belongs to
  63573. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63574. */
  63575. constructor(name: string, options: Partial<{
  63576. capacity: number;
  63577. randomTextureSize: number;
  63578. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63579. protected _reset(): void;
  63580. private _createUpdateVAO;
  63581. private _createRenderVAO;
  63582. private _initialize;
  63583. /** @hidden */
  63584. _recreateUpdateEffect(): void;
  63585. /** @hidden */
  63586. _recreateRenderEffect(): void;
  63587. /**
  63588. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63589. * @param preWarm defines if we are in the pre-warmimg phase
  63590. */
  63591. animate(preWarm?: boolean): void;
  63592. private _createFactorGradientTexture;
  63593. private _createSizeGradientTexture;
  63594. private _createAngularSpeedGradientTexture;
  63595. private _createVelocityGradientTexture;
  63596. private _createLimitVelocityGradientTexture;
  63597. private _createDragGradientTexture;
  63598. private _createColorGradientTexture;
  63599. /**
  63600. * Renders the particle system in its current state
  63601. * @param preWarm defines if the system should only update the particles but not render them
  63602. * @returns the current number of particles
  63603. */
  63604. render(preWarm?: boolean): number;
  63605. /**
  63606. * Rebuilds the particle system
  63607. */
  63608. rebuild(): void;
  63609. private _releaseBuffers;
  63610. private _releaseVAOs;
  63611. /**
  63612. * Disposes the particle system and free the associated resources
  63613. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63614. */
  63615. dispose(disposeTexture?: boolean): void;
  63616. /**
  63617. * Clones the particle system.
  63618. * @param name The name of the cloned object
  63619. * @param newEmitter The new emitter to use
  63620. * @returns the cloned particle system
  63621. */
  63622. clone(name: string, newEmitter: any): GPUParticleSystem;
  63623. /**
  63624. * Serializes the particle system to a JSON object
  63625. * @param serializeTexture defines if the texture must be serialized as well
  63626. * @returns the JSON object
  63627. */
  63628. serialize(serializeTexture?: boolean): any;
  63629. /**
  63630. * Parses a JSON object to create a GPU particle system.
  63631. * @param parsedParticleSystem The JSON object to parse
  63632. * @param scene The scene to create the particle system in
  63633. * @param rootUrl The root url to use to load external dependencies like texture
  63634. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63635. * @returns the parsed GPU particle system
  63636. */
  63637. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63638. }
  63639. }
  63640. declare module BABYLON {
  63641. /**
  63642. * Represents a set of particle systems working together to create a specific effect
  63643. */
  63644. export class ParticleSystemSet implements IDisposable {
  63645. /**
  63646. * Gets or sets base Assets URL
  63647. */
  63648. static BaseAssetsUrl: string;
  63649. private _emitterCreationOptions;
  63650. private _emitterNode;
  63651. /**
  63652. * Gets the particle system list
  63653. */
  63654. systems: IParticleSystem[];
  63655. /**
  63656. * Gets the emitter node used with this set
  63657. */
  63658. get emitterNode(): Nullable<TransformNode>;
  63659. /**
  63660. * Creates a new emitter mesh as a sphere
  63661. * @param options defines the options used to create the sphere
  63662. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63663. * @param scene defines the hosting scene
  63664. */
  63665. setEmitterAsSphere(options: {
  63666. diameter: number;
  63667. segments: number;
  63668. color: Color3;
  63669. }, renderingGroupId: number, scene: Scene): void;
  63670. /**
  63671. * Starts all particle systems of the set
  63672. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63673. */
  63674. start(emitter?: AbstractMesh): void;
  63675. /**
  63676. * Release all associated resources
  63677. */
  63678. dispose(): void;
  63679. /**
  63680. * Serialize the set into a JSON compatible object
  63681. * @param serializeTexture defines if the texture must be serialized as well
  63682. * @returns a JSON compatible representation of the set
  63683. */
  63684. serialize(serializeTexture?: boolean): any;
  63685. /**
  63686. * Parse a new ParticleSystemSet from a serialized source
  63687. * @param data defines a JSON compatible representation of the set
  63688. * @param scene defines the hosting scene
  63689. * @param gpu defines if we want GPU particles or CPU particles
  63690. * @returns a new ParticleSystemSet
  63691. */
  63692. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63693. }
  63694. }
  63695. declare module BABYLON {
  63696. /**
  63697. * This class is made for on one-liner static method to help creating particle system set.
  63698. */
  63699. export class ParticleHelper {
  63700. /**
  63701. * Gets or sets base Assets URL
  63702. */
  63703. static BaseAssetsUrl: string;
  63704. /** Define the Url to load snippets */
  63705. static SnippetUrl: string;
  63706. /**
  63707. * Create a default particle system that you can tweak
  63708. * @param emitter defines the emitter to use
  63709. * @param capacity defines the system capacity (default is 500 particles)
  63710. * @param scene defines the hosting scene
  63711. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63712. * @returns the new Particle system
  63713. */
  63714. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63715. /**
  63716. * This is the main static method (one-liner) of this helper to create different particle systems
  63717. * @param type This string represents the type to the particle system to create
  63718. * @param scene The scene where the particle system should live
  63719. * @param gpu If the system will use gpu
  63720. * @returns the ParticleSystemSet created
  63721. */
  63722. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63723. /**
  63724. * Static function used to export a particle system to a ParticleSystemSet variable.
  63725. * Please note that the emitter shape is not exported
  63726. * @param systems defines the particle systems to export
  63727. * @returns the created particle system set
  63728. */
  63729. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63730. /**
  63731. * Creates a particle system from a snippet saved in a remote file
  63732. * @param name defines the name of the particle system to create
  63733. * @param url defines the url to load from
  63734. * @param scene defines the hosting scene
  63735. * @param gpu If the system will use gpu
  63736. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63737. * @returns a promise that will resolve to the new particle system
  63738. */
  63739. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63740. /**
  63741. * Creates a particle system from a snippet saved by the particle system editor
  63742. * @param snippetId defines the snippet to load
  63743. * @param scene defines the hosting scene
  63744. * @param gpu If the system will use gpu
  63745. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63746. * @returns a promise that will resolve to the new particle system
  63747. */
  63748. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63749. }
  63750. }
  63751. declare module BABYLON {
  63752. interface Engine {
  63753. /**
  63754. * Create an effect to use with particle systems.
  63755. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63756. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63757. * @param uniformsNames defines a list of attribute names
  63758. * @param samplers defines an array of string used to represent textures
  63759. * @param defines defines the string containing the defines to use to compile the shaders
  63760. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63761. * @param onCompiled defines a function to call when the effect creation is successful
  63762. * @param onError defines a function to call when the effect creation has failed
  63763. * @returns the new Effect
  63764. */
  63765. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63766. }
  63767. interface Mesh {
  63768. /**
  63769. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63770. * @returns an array of IParticleSystem
  63771. */
  63772. getEmittedParticleSystems(): IParticleSystem[];
  63773. /**
  63774. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63775. * @returns an array of IParticleSystem
  63776. */
  63777. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63778. }
  63779. /**
  63780. * @hidden
  63781. */
  63782. export var _IDoNeedToBeInTheBuild: number;
  63783. }
  63784. declare module BABYLON {
  63785. /** Defines the 4 color options */
  63786. export enum PointColor {
  63787. /** color value */
  63788. Color = 2,
  63789. /** uv value */
  63790. UV = 1,
  63791. /** random value */
  63792. Random = 0,
  63793. /** stated value */
  63794. Stated = 3
  63795. }
  63796. /**
  63797. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63798. * 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.
  63799. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63800. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63801. *
  63802. * Full documentation here : TO BE ENTERED
  63803. */
  63804. export class PointsCloudSystem implements IDisposable {
  63805. /**
  63806. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63807. * Example : var p = SPS.particles[i];
  63808. */
  63809. particles: CloudPoint[];
  63810. /**
  63811. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63812. */
  63813. nbParticles: number;
  63814. /**
  63815. * This a counter for your own usage. It's not set by any SPS functions.
  63816. */
  63817. counter: number;
  63818. /**
  63819. * The PCS name. This name is also given to the underlying mesh.
  63820. */
  63821. name: string;
  63822. /**
  63823. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63824. */
  63825. mesh: Mesh;
  63826. /**
  63827. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63828. * Please read :
  63829. */
  63830. vars: any;
  63831. /**
  63832. * @hidden
  63833. */
  63834. _size: number;
  63835. private _scene;
  63836. private _promises;
  63837. private _positions;
  63838. private _indices;
  63839. private _normals;
  63840. private _colors;
  63841. private _uvs;
  63842. private _indices32;
  63843. private _positions32;
  63844. private _colors32;
  63845. private _uvs32;
  63846. private _updatable;
  63847. private _isVisibilityBoxLocked;
  63848. private _alwaysVisible;
  63849. private _groups;
  63850. private _groupCounter;
  63851. private _computeParticleColor;
  63852. private _computeParticleTexture;
  63853. private _computeParticleRotation;
  63854. private _computeBoundingBox;
  63855. private _isReady;
  63856. /**
  63857. * Creates a PCS (Points Cloud System) object
  63858. * @param name (String) is the PCS name, this will be the underlying mesh name
  63859. * @param pointSize (number) is the size for each point
  63860. * @param scene (Scene) is the scene in which the PCS is added
  63861. * @param options defines the options of the PCS e.g.
  63862. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63863. */
  63864. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63865. updatable?: boolean;
  63866. });
  63867. /**
  63868. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63869. * If no points were added to the PCS, the returned mesh is just a single point.
  63870. * @returns a promise for the created mesh
  63871. */
  63872. buildMeshAsync(): Promise<Mesh>;
  63873. /**
  63874. * @hidden
  63875. */
  63876. private _buildMesh;
  63877. private _addParticle;
  63878. private _randomUnitVector;
  63879. private _getColorIndicesForCoord;
  63880. private _setPointsColorOrUV;
  63881. private _colorFromTexture;
  63882. private _calculateDensity;
  63883. /**
  63884. * Adds points to the PCS in random positions within a unit sphere
  63885. * @param nb (positive integer) the number of particles to be created from this model
  63886. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63887. * @returns the number of groups in the system
  63888. */
  63889. addPoints(nb: number, pointFunction?: any): number;
  63890. /**
  63891. * Adds points to the PCS from the surface of the model shape
  63892. * @param mesh is any Mesh object that will be used as a surface model for the points
  63893. * @param nb (positive integer) the number of particles to be created from this model
  63894. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63895. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63896. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63897. * @returns the number of groups in the system
  63898. */
  63899. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63900. /**
  63901. * Adds points to the PCS inside the model shape
  63902. * @param mesh is any Mesh object that will be used as a surface model for the points
  63903. * @param nb (positive integer) the number of particles to be created from this model
  63904. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63905. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63906. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63907. * @returns the number of groups in the system
  63908. */
  63909. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63910. /**
  63911. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63912. * This method calls `updateParticle()` for each particle of the SPS.
  63913. * For an animated SPS, it is usually called within the render loop.
  63914. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63915. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63916. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63917. * @returns the PCS.
  63918. */
  63919. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63920. /**
  63921. * Disposes the PCS.
  63922. */
  63923. dispose(): void;
  63924. /**
  63925. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63926. * doc :
  63927. * @returns the PCS.
  63928. */
  63929. refreshVisibleSize(): PointsCloudSystem;
  63930. /**
  63931. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63932. * @param size the size (float) of the visibility box
  63933. * note : this doesn't lock the PCS mesh bounding box.
  63934. * doc :
  63935. */
  63936. setVisibilityBox(size: number): void;
  63937. /**
  63938. * Gets whether the PCS is always visible or not
  63939. * doc :
  63940. */
  63941. get isAlwaysVisible(): boolean;
  63942. /**
  63943. * Sets the PCS as always visible or not
  63944. * doc :
  63945. */
  63946. set isAlwaysVisible(val: boolean);
  63947. /**
  63948. * Tells to `setParticles()` to compute the particle rotations or not
  63949. * Default value : false. The PCS is faster when it's set to false
  63950. * Note : particle rotations are only applied to parent particles
  63951. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63952. */
  63953. set computeParticleRotation(val: boolean);
  63954. /**
  63955. * Tells to `setParticles()` to compute the particle colors or not.
  63956. * Default value : true. The PCS is faster when it's set to false.
  63957. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63958. */
  63959. set computeParticleColor(val: boolean);
  63960. set computeParticleTexture(val: boolean);
  63961. /**
  63962. * Gets if `setParticles()` computes the particle colors or not.
  63963. * Default value : false. The PCS is faster when it's set to false.
  63964. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63965. */
  63966. get computeParticleColor(): boolean;
  63967. /**
  63968. * Gets if `setParticles()` computes the particle textures or not.
  63969. * Default value : false. The PCS is faster when it's set to false.
  63970. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63971. */
  63972. get computeParticleTexture(): boolean;
  63973. /**
  63974. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63975. */
  63976. set computeBoundingBox(val: boolean);
  63977. /**
  63978. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63979. */
  63980. get computeBoundingBox(): boolean;
  63981. /**
  63982. * This function does nothing. It may be overwritten to set all the particle first values.
  63983. * The PCS doesn't call this function, you may have to call it by your own.
  63984. * doc :
  63985. */
  63986. initParticles(): void;
  63987. /**
  63988. * This function does nothing. It may be overwritten to recycle a particle
  63989. * The PCS doesn't call this function, you can to call it
  63990. * doc :
  63991. * @param particle The particle to recycle
  63992. * @returns the recycled particle
  63993. */
  63994. recycleParticle(particle: CloudPoint): CloudPoint;
  63995. /**
  63996. * Updates a particle : this function should be overwritten by the user.
  63997. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63998. * doc :
  63999. * @example : just set a particle position or velocity and recycle conditions
  64000. * @param particle The particle to update
  64001. * @returns the updated particle
  64002. */
  64003. updateParticle(particle: CloudPoint): CloudPoint;
  64004. /**
  64005. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64006. * This does nothing and may be overwritten by the user.
  64007. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64008. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64009. * @param update the boolean update value actually passed to setParticles()
  64010. */
  64011. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64012. /**
  64013. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64014. * This will be passed three parameters.
  64015. * This does nothing and may be overwritten by the user.
  64016. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64017. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64018. * @param update the boolean update value actually passed to setParticles()
  64019. */
  64020. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64021. }
  64022. }
  64023. declare module BABYLON {
  64024. /**
  64025. * Represents one particle of a points cloud system.
  64026. */
  64027. export class CloudPoint {
  64028. /**
  64029. * particle global index
  64030. */
  64031. idx: number;
  64032. /**
  64033. * The color of the particle
  64034. */
  64035. color: Nullable<Color4>;
  64036. /**
  64037. * The world space position of the particle.
  64038. */
  64039. position: Vector3;
  64040. /**
  64041. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64042. */
  64043. rotation: Vector3;
  64044. /**
  64045. * The world space rotation quaternion of the particle.
  64046. */
  64047. rotationQuaternion: Nullable<Quaternion>;
  64048. /**
  64049. * The uv of the particle.
  64050. */
  64051. uv: Nullable<Vector2>;
  64052. /**
  64053. * The current speed of the particle.
  64054. */
  64055. velocity: Vector3;
  64056. /**
  64057. * The pivot point in the particle local space.
  64058. */
  64059. pivot: Vector3;
  64060. /**
  64061. * Must the particle be translated from its pivot point in its local space ?
  64062. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64063. * Default : false
  64064. */
  64065. translateFromPivot: boolean;
  64066. /**
  64067. * Index of this particle in the global "positions" array (Internal use)
  64068. * @hidden
  64069. */
  64070. _pos: number;
  64071. /**
  64072. * @hidden Index of this particle in the global "indices" array (Internal use)
  64073. */
  64074. _ind: number;
  64075. /**
  64076. * Group this particle belongs to
  64077. */
  64078. _group: PointsGroup;
  64079. /**
  64080. * Group id of this particle
  64081. */
  64082. groupId: number;
  64083. /**
  64084. * Index of the particle in its group id (Internal use)
  64085. */
  64086. idxInGroup: number;
  64087. /**
  64088. * @hidden Particle BoundingInfo object (Internal use)
  64089. */
  64090. _boundingInfo: BoundingInfo;
  64091. /**
  64092. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64093. */
  64094. _pcs: PointsCloudSystem;
  64095. /**
  64096. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64097. */
  64098. _stillInvisible: boolean;
  64099. /**
  64100. * @hidden Last computed particle rotation matrix
  64101. */
  64102. _rotationMatrix: number[];
  64103. /**
  64104. * Parent particle Id, if any.
  64105. * Default null.
  64106. */
  64107. parentId: Nullable<number>;
  64108. /**
  64109. * @hidden Internal global position in the PCS.
  64110. */
  64111. _globalPosition: Vector3;
  64112. /**
  64113. * Creates a Point Cloud object.
  64114. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64115. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64116. * @param group (PointsGroup) is the group the particle belongs to
  64117. * @param groupId (integer) is the group identifier in the PCS.
  64118. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64119. * @param pcs defines the PCS it is associated to
  64120. */
  64121. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64122. /**
  64123. * get point size
  64124. */
  64125. get size(): Vector3;
  64126. /**
  64127. * Set point size
  64128. */
  64129. set size(scale: Vector3);
  64130. /**
  64131. * Legacy support, changed quaternion to rotationQuaternion
  64132. */
  64133. get quaternion(): Nullable<Quaternion>;
  64134. /**
  64135. * Legacy support, changed quaternion to rotationQuaternion
  64136. */
  64137. set quaternion(q: Nullable<Quaternion>);
  64138. /**
  64139. * Returns a boolean. True if the particle intersects a mesh, else false
  64140. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64141. * @param target is the object (point or mesh) what the intersection is computed against
  64142. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64143. * @returns true if it intersects
  64144. */
  64145. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64146. /**
  64147. * get the rotation matrix of the particle
  64148. * @hidden
  64149. */
  64150. getRotationMatrix(m: Matrix): void;
  64151. }
  64152. /**
  64153. * Represents a group of points in a points cloud system
  64154. * * PCS internal tool, don't use it manually.
  64155. */
  64156. export class PointsGroup {
  64157. /**
  64158. * The group id
  64159. * @hidden
  64160. */
  64161. groupID: number;
  64162. /**
  64163. * image data for group (internal use)
  64164. * @hidden
  64165. */
  64166. _groupImageData: Nullable<ArrayBufferView>;
  64167. /**
  64168. * Image Width (internal use)
  64169. * @hidden
  64170. */
  64171. _groupImgWidth: number;
  64172. /**
  64173. * Image Height (internal use)
  64174. * @hidden
  64175. */
  64176. _groupImgHeight: number;
  64177. /**
  64178. * Custom position function (internal use)
  64179. * @hidden
  64180. */
  64181. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64182. /**
  64183. * density per facet for surface points
  64184. * @hidden
  64185. */
  64186. _groupDensity: number[];
  64187. /**
  64188. * Only when points are colored by texture carries pointer to texture list array
  64189. * @hidden
  64190. */
  64191. _textureNb: number;
  64192. /**
  64193. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64194. * PCS internal tool, don't use it manually.
  64195. * @hidden
  64196. */
  64197. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64198. }
  64199. }
  64200. declare module BABYLON {
  64201. interface Scene {
  64202. /** @hidden (Backing field) */
  64203. _physicsEngine: Nullable<IPhysicsEngine>;
  64204. /** @hidden */
  64205. _physicsTimeAccumulator: number;
  64206. /**
  64207. * Gets the current physics engine
  64208. * @returns a IPhysicsEngine or null if none attached
  64209. */
  64210. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64211. /**
  64212. * Enables physics to the current scene
  64213. * @param gravity defines the scene's gravity for the physics engine
  64214. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64215. * @return a boolean indicating if the physics engine was initialized
  64216. */
  64217. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64218. /**
  64219. * Disables and disposes the physics engine associated with the scene
  64220. */
  64221. disablePhysicsEngine(): void;
  64222. /**
  64223. * Gets a boolean indicating if there is an active physics engine
  64224. * @returns a boolean indicating if there is an active physics engine
  64225. */
  64226. isPhysicsEnabled(): boolean;
  64227. /**
  64228. * Deletes a physics compound impostor
  64229. * @param compound defines the compound to delete
  64230. */
  64231. deleteCompoundImpostor(compound: any): void;
  64232. /**
  64233. * An event triggered when physic simulation is about to be run
  64234. */
  64235. onBeforePhysicsObservable: Observable<Scene>;
  64236. /**
  64237. * An event triggered when physic simulation has been done
  64238. */
  64239. onAfterPhysicsObservable: Observable<Scene>;
  64240. }
  64241. interface AbstractMesh {
  64242. /** @hidden */
  64243. _physicsImpostor: Nullable<PhysicsImpostor>;
  64244. /**
  64245. * Gets or sets impostor used for physic simulation
  64246. * @see http://doc.babylonjs.com/features/physics_engine
  64247. */
  64248. physicsImpostor: Nullable<PhysicsImpostor>;
  64249. /**
  64250. * Gets the current physics impostor
  64251. * @see http://doc.babylonjs.com/features/physics_engine
  64252. * @returns a physics impostor or null
  64253. */
  64254. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64255. /** Apply a physic impulse to the mesh
  64256. * @param force defines the force to apply
  64257. * @param contactPoint defines where to apply the force
  64258. * @returns the current mesh
  64259. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64260. */
  64261. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64262. /**
  64263. * Creates a physic joint between two meshes
  64264. * @param otherMesh defines the other mesh to use
  64265. * @param pivot1 defines the pivot to use on this mesh
  64266. * @param pivot2 defines the pivot to use on the other mesh
  64267. * @param options defines additional options (can be plugin dependent)
  64268. * @returns the current mesh
  64269. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64270. */
  64271. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64272. /** @hidden */
  64273. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64274. }
  64275. /**
  64276. * Defines the physics engine scene component responsible to manage a physics engine
  64277. */
  64278. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64279. /**
  64280. * The component name helpful to identify the component in the list of scene components.
  64281. */
  64282. readonly name: string;
  64283. /**
  64284. * The scene the component belongs to.
  64285. */
  64286. scene: Scene;
  64287. /**
  64288. * Creates a new instance of the component for the given scene
  64289. * @param scene Defines the scene to register the component in
  64290. */
  64291. constructor(scene: Scene);
  64292. /**
  64293. * Registers the component in a given scene
  64294. */
  64295. register(): void;
  64296. /**
  64297. * Rebuilds the elements related to this component in case of
  64298. * context lost for instance.
  64299. */
  64300. rebuild(): void;
  64301. /**
  64302. * Disposes the component and the associated ressources
  64303. */
  64304. dispose(): void;
  64305. }
  64306. }
  64307. declare module BABYLON {
  64308. /**
  64309. * A helper for physics simulations
  64310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64311. */
  64312. export class PhysicsHelper {
  64313. private _scene;
  64314. private _physicsEngine;
  64315. /**
  64316. * Initializes the Physics helper
  64317. * @param scene Babylon.js scene
  64318. */
  64319. constructor(scene: Scene);
  64320. /**
  64321. * Applies a radial explosion impulse
  64322. * @param origin the origin of the explosion
  64323. * @param radiusOrEventOptions the radius or the options of radial explosion
  64324. * @param strength the explosion strength
  64325. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64326. * @returns A physics radial explosion event, or null
  64327. */
  64328. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64329. /**
  64330. * Applies a radial explosion force
  64331. * @param origin the origin of the explosion
  64332. * @param radiusOrEventOptions the radius or the options of radial explosion
  64333. * @param strength the explosion strength
  64334. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64335. * @returns A physics radial explosion event, or null
  64336. */
  64337. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64338. /**
  64339. * Creates a gravitational field
  64340. * @param origin the origin of the explosion
  64341. * @param radiusOrEventOptions the radius or the options of radial explosion
  64342. * @param strength the explosion strength
  64343. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64344. * @returns A physics gravitational field event, or null
  64345. */
  64346. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64347. /**
  64348. * Creates a physics updraft event
  64349. * @param origin the origin of the updraft
  64350. * @param radiusOrEventOptions the radius or the options of the updraft
  64351. * @param strength the strength of the updraft
  64352. * @param height the height of the updraft
  64353. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64354. * @returns A physics updraft event, or null
  64355. */
  64356. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64357. /**
  64358. * Creates a physics vortex event
  64359. * @param origin the of the vortex
  64360. * @param radiusOrEventOptions the radius or the options of the vortex
  64361. * @param strength the strength of the vortex
  64362. * @param height the height of the vortex
  64363. * @returns a Physics vortex event, or null
  64364. * A physics vortex event or null
  64365. */
  64366. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64367. }
  64368. /**
  64369. * Represents a physics radial explosion event
  64370. */
  64371. class PhysicsRadialExplosionEvent {
  64372. private _scene;
  64373. private _options;
  64374. private _sphere;
  64375. private _dataFetched;
  64376. /**
  64377. * Initializes a radial explosioin event
  64378. * @param _scene BabylonJS scene
  64379. * @param _options The options for the vortex event
  64380. */
  64381. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64382. /**
  64383. * Returns the data related to the radial explosion event (sphere).
  64384. * @returns The radial explosion event data
  64385. */
  64386. getData(): PhysicsRadialExplosionEventData;
  64387. /**
  64388. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64389. * @param impostor A physics imposter
  64390. * @param origin the origin of the explosion
  64391. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64392. */
  64393. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64394. /**
  64395. * Triggers affecterd impostors callbacks
  64396. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64397. */
  64398. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64399. /**
  64400. * Disposes the sphere.
  64401. * @param force Specifies if the sphere should be disposed by force
  64402. */
  64403. dispose(force?: boolean): void;
  64404. /*** Helpers ***/
  64405. private _prepareSphere;
  64406. private _intersectsWithSphere;
  64407. }
  64408. /**
  64409. * Represents a gravitational field event
  64410. */
  64411. class PhysicsGravitationalFieldEvent {
  64412. private _physicsHelper;
  64413. private _scene;
  64414. private _origin;
  64415. private _options;
  64416. private _tickCallback;
  64417. private _sphere;
  64418. private _dataFetched;
  64419. /**
  64420. * Initializes the physics gravitational field event
  64421. * @param _physicsHelper A physics helper
  64422. * @param _scene BabylonJS scene
  64423. * @param _origin The origin position of the gravitational field event
  64424. * @param _options The options for the vortex event
  64425. */
  64426. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64427. /**
  64428. * Returns the data related to the gravitational field event (sphere).
  64429. * @returns A gravitational field event
  64430. */
  64431. getData(): PhysicsGravitationalFieldEventData;
  64432. /**
  64433. * Enables the gravitational field.
  64434. */
  64435. enable(): void;
  64436. /**
  64437. * Disables the gravitational field.
  64438. */
  64439. disable(): void;
  64440. /**
  64441. * Disposes the sphere.
  64442. * @param force The force to dispose from the gravitational field event
  64443. */
  64444. dispose(force?: boolean): void;
  64445. private _tick;
  64446. }
  64447. /**
  64448. * Represents a physics updraft event
  64449. */
  64450. class PhysicsUpdraftEvent {
  64451. private _scene;
  64452. private _origin;
  64453. private _options;
  64454. private _physicsEngine;
  64455. private _originTop;
  64456. private _originDirection;
  64457. private _tickCallback;
  64458. private _cylinder;
  64459. private _cylinderPosition;
  64460. private _dataFetched;
  64461. /**
  64462. * Initializes the physics updraft event
  64463. * @param _scene BabylonJS scene
  64464. * @param _origin The origin position of the updraft
  64465. * @param _options The options for the updraft event
  64466. */
  64467. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64468. /**
  64469. * Returns the data related to the updraft event (cylinder).
  64470. * @returns A physics updraft event
  64471. */
  64472. getData(): PhysicsUpdraftEventData;
  64473. /**
  64474. * Enables the updraft.
  64475. */
  64476. enable(): void;
  64477. /**
  64478. * Disables the updraft.
  64479. */
  64480. disable(): void;
  64481. /**
  64482. * Disposes the cylinder.
  64483. * @param force Specifies if the updraft should be disposed by force
  64484. */
  64485. dispose(force?: boolean): void;
  64486. private getImpostorHitData;
  64487. private _tick;
  64488. /*** Helpers ***/
  64489. private _prepareCylinder;
  64490. private _intersectsWithCylinder;
  64491. }
  64492. /**
  64493. * Represents a physics vortex event
  64494. */
  64495. class PhysicsVortexEvent {
  64496. private _scene;
  64497. private _origin;
  64498. private _options;
  64499. private _physicsEngine;
  64500. private _originTop;
  64501. private _tickCallback;
  64502. private _cylinder;
  64503. private _cylinderPosition;
  64504. private _dataFetched;
  64505. /**
  64506. * Initializes the physics vortex event
  64507. * @param _scene The BabylonJS scene
  64508. * @param _origin The origin position of the vortex
  64509. * @param _options The options for the vortex event
  64510. */
  64511. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64512. /**
  64513. * Returns the data related to the vortex event (cylinder).
  64514. * @returns The physics vortex event data
  64515. */
  64516. getData(): PhysicsVortexEventData;
  64517. /**
  64518. * Enables the vortex.
  64519. */
  64520. enable(): void;
  64521. /**
  64522. * Disables the cortex.
  64523. */
  64524. disable(): void;
  64525. /**
  64526. * Disposes the sphere.
  64527. * @param force
  64528. */
  64529. dispose(force?: boolean): void;
  64530. private getImpostorHitData;
  64531. private _tick;
  64532. /*** Helpers ***/
  64533. private _prepareCylinder;
  64534. private _intersectsWithCylinder;
  64535. }
  64536. /**
  64537. * Options fot the radial explosion event
  64538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64539. */
  64540. export class PhysicsRadialExplosionEventOptions {
  64541. /**
  64542. * The radius of the sphere for the radial explosion.
  64543. */
  64544. radius: number;
  64545. /**
  64546. * The strenth of the explosion.
  64547. */
  64548. strength: number;
  64549. /**
  64550. * The strenght of the force in correspondence to the distance of the affected object
  64551. */
  64552. falloff: PhysicsRadialImpulseFalloff;
  64553. /**
  64554. * Sphere options for the radial explosion.
  64555. */
  64556. sphere: {
  64557. segments: number;
  64558. diameter: number;
  64559. };
  64560. /**
  64561. * Sphere options for the radial explosion.
  64562. */
  64563. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64564. }
  64565. /**
  64566. * Options fot the updraft event
  64567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64568. */
  64569. export class PhysicsUpdraftEventOptions {
  64570. /**
  64571. * The radius of the cylinder for the vortex
  64572. */
  64573. radius: number;
  64574. /**
  64575. * The strenth of the updraft.
  64576. */
  64577. strength: number;
  64578. /**
  64579. * The height of the cylinder for the updraft.
  64580. */
  64581. height: number;
  64582. /**
  64583. * The mode for the the updraft.
  64584. */
  64585. updraftMode: PhysicsUpdraftMode;
  64586. }
  64587. /**
  64588. * Options fot the vortex event
  64589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64590. */
  64591. export class PhysicsVortexEventOptions {
  64592. /**
  64593. * The radius of the cylinder for the vortex
  64594. */
  64595. radius: number;
  64596. /**
  64597. * The strenth of the vortex.
  64598. */
  64599. strength: number;
  64600. /**
  64601. * The height of the cylinder for the vortex.
  64602. */
  64603. height: number;
  64604. /**
  64605. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64606. */
  64607. centripetalForceThreshold: number;
  64608. /**
  64609. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64610. */
  64611. centripetalForceMultiplier: number;
  64612. /**
  64613. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64614. */
  64615. centrifugalForceMultiplier: number;
  64616. /**
  64617. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64618. */
  64619. updraftForceMultiplier: number;
  64620. }
  64621. /**
  64622. * The strenght of the force in correspondence to the distance of the affected object
  64623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64624. */
  64625. export enum PhysicsRadialImpulseFalloff {
  64626. /** Defines that impulse is constant in strength across it's whole radius */
  64627. Constant = 0,
  64628. /** Defines that impulse gets weaker if it's further from the origin */
  64629. Linear = 1
  64630. }
  64631. /**
  64632. * The strength of the force in correspondence to the distance of the affected object
  64633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64634. */
  64635. export enum PhysicsUpdraftMode {
  64636. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64637. Center = 0,
  64638. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64639. Perpendicular = 1
  64640. }
  64641. /**
  64642. * Interface for a physics hit data
  64643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64644. */
  64645. export interface PhysicsHitData {
  64646. /**
  64647. * The force applied at the contact point
  64648. */
  64649. force: Vector3;
  64650. /**
  64651. * The contact point
  64652. */
  64653. contactPoint: Vector3;
  64654. /**
  64655. * The distance from the origin to the contact point
  64656. */
  64657. distanceFromOrigin: number;
  64658. }
  64659. /**
  64660. * Interface for radial explosion event data
  64661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64662. */
  64663. export interface PhysicsRadialExplosionEventData {
  64664. /**
  64665. * A sphere used for the radial explosion event
  64666. */
  64667. sphere: Mesh;
  64668. }
  64669. /**
  64670. * Interface for gravitational field event data
  64671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64672. */
  64673. export interface PhysicsGravitationalFieldEventData {
  64674. /**
  64675. * A sphere mesh used for the gravitational field event
  64676. */
  64677. sphere: Mesh;
  64678. }
  64679. /**
  64680. * Interface for updraft event data
  64681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64682. */
  64683. export interface PhysicsUpdraftEventData {
  64684. /**
  64685. * A cylinder used for the updraft event
  64686. */
  64687. cylinder: Mesh;
  64688. }
  64689. /**
  64690. * Interface for vortex event data
  64691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64692. */
  64693. export interface PhysicsVortexEventData {
  64694. /**
  64695. * A cylinder used for the vortex event
  64696. */
  64697. cylinder: Mesh;
  64698. }
  64699. /**
  64700. * Interface for an affected physics impostor
  64701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64702. */
  64703. export interface PhysicsAffectedImpostorWithData {
  64704. /**
  64705. * The impostor affected by the effect
  64706. */
  64707. impostor: PhysicsImpostor;
  64708. /**
  64709. * The data about the hit/horce from the explosion
  64710. */
  64711. hitData: PhysicsHitData;
  64712. }
  64713. }
  64714. declare module BABYLON {
  64715. /** @hidden */
  64716. export var blackAndWhitePixelShader: {
  64717. name: string;
  64718. shader: string;
  64719. };
  64720. }
  64721. declare module BABYLON {
  64722. /**
  64723. * Post process used to render in black and white
  64724. */
  64725. export class BlackAndWhitePostProcess extends PostProcess {
  64726. /**
  64727. * Linear about to convert he result to black and white (default: 1)
  64728. */
  64729. degree: number;
  64730. /**
  64731. * Creates a black and white post process
  64732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64733. * @param name The name of the effect.
  64734. * @param options The required width/height ratio to downsize to before computing the render pass.
  64735. * @param camera The camera to apply the render pass to.
  64736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64737. * @param engine The engine which the post process will be applied. (default: current engine)
  64738. * @param reusable If the post process can be reused on the same frame. (default: false)
  64739. */
  64740. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64741. }
  64742. }
  64743. declare module BABYLON {
  64744. /**
  64745. * This represents a set of one or more post processes in Babylon.
  64746. * A post process can be used to apply a shader to a texture after it is rendered.
  64747. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64748. */
  64749. export class PostProcessRenderEffect {
  64750. private _postProcesses;
  64751. private _getPostProcesses;
  64752. private _singleInstance;
  64753. private _cameras;
  64754. private _indicesForCamera;
  64755. /**
  64756. * Name of the effect
  64757. * @hidden
  64758. */
  64759. _name: string;
  64760. /**
  64761. * Instantiates a post process render effect.
  64762. * A post process can be used to apply a shader to a texture after it is rendered.
  64763. * @param engine The engine the effect is tied to
  64764. * @param name The name of the effect
  64765. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64766. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64767. */
  64768. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64769. /**
  64770. * Checks if all the post processes in the effect are supported.
  64771. */
  64772. get isSupported(): boolean;
  64773. /**
  64774. * Updates the current state of the effect
  64775. * @hidden
  64776. */
  64777. _update(): void;
  64778. /**
  64779. * Attaches the effect on cameras
  64780. * @param cameras The camera to attach to.
  64781. * @hidden
  64782. */
  64783. _attachCameras(cameras: Camera): void;
  64784. /**
  64785. * Attaches the effect on cameras
  64786. * @param cameras The camera to attach to.
  64787. * @hidden
  64788. */
  64789. _attachCameras(cameras: Camera[]): void;
  64790. /**
  64791. * Detaches the effect on cameras
  64792. * @param cameras The camera to detatch from.
  64793. * @hidden
  64794. */
  64795. _detachCameras(cameras: Camera): void;
  64796. /**
  64797. * Detatches the effect on cameras
  64798. * @param cameras The camera to detatch from.
  64799. * @hidden
  64800. */
  64801. _detachCameras(cameras: Camera[]): void;
  64802. /**
  64803. * Enables the effect on given cameras
  64804. * @param cameras The camera to enable.
  64805. * @hidden
  64806. */
  64807. _enable(cameras: Camera): void;
  64808. /**
  64809. * Enables the effect on given cameras
  64810. * @param cameras The camera to enable.
  64811. * @hidden
  64812. */
  64813. _enable(cameras: Nullable<Camera[]>): void;
  64814. /**
  64815. * Disables the effect on the given cameras
  64816. * @param cameras The camera to disable.
  64817. * @hidden
  64818. */
  64819. _disable(cameras: Camera): void;
  64820. /**
  64821. * Disables the effect on the given cameras
  64822. * @param cameras The camera to disable.
  64823. * @hidden
  64824. */
  64825. _disable(cameras: Nullable<Camera[]>): void;
  64826. /**
  64827. * Gets a list of the post processes contained in the effect.
  64828. * @param camera The camera to get the post processes on.
  64829. * @returns The list of the post processes in the effect.
  64830. */
  64831. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64832. }
  64833. }
  64834. declare module BABYLON {
  64835. /** @hidden */
  64836. export var extractHighlightsPixelShader: {
  64837. name: string;
  64838. shader: string;
  64839. };
  64840. }
  64841. declare module BABYLON {
  64842. /**
  64843. * 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.
  64844. */
  64845. export class ExtractHighlightsPostProcess extends PostProcess {
  64846. /**
  64847. * The luminance threshold, pixels below this value will be set to black.
  64848. */
  64849. threshold: number;
  64850. /** @hidden */
  64851. _exposure: number;
  64852. /**
  64853. * Post process which has the input texture to be used when performing highlight extraction
  64854. * @hidden
  64855. */
  64856. _inputPostProcess: Nullable<PostProcess>;
  64857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64858. }
  64859. }
  64860. declare module BABYLON {
  64861. /** @hidden */
  64862. export var bloomMergePixelShader: {
  64863. name: string;
  64864. shader: string;
  64865. };
  64866. }
  64867. declare module BABYLON {
  64868. /**
  64869. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64870. */
  64871. export class BloomMergePostProcess extends PostProcess {
  64872. /** Weight of the bloom to be added to the original input. */
  64873. weight: number;
  64874. /**
  64875. * Creates a new instance of @see BloomMergePostProcess
  64876. * @param name The name of the effect.
  64877. * @param originalFromInput Post process which's input will be used for the merge.
  64878. * @param blurred Blurred highlights post process which's output will be used.
  64879. * @param weight Weight of the bloom to be added to the original input.
  64880. * @param options The required width/height ratio to downsize to before computing the render pass.
  64881. * @param camera The camera to apply the render pass to.
  64882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64883. * @param engine The engine which the post process will be applied. (default: current engine)
  64884. * @param reusable If the post process can be reused on the same frame. (default: false)
  64885. * @param textureType Type of textures used when performing the post process. (default: 0)
  64886. * @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)
  64887. */
  64888. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64889. /** Weight of the bloom to be added to the original input. */
  64890. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64891. }
  64892. }
  64893. declare module BABYLON {
  64894. /**
  64895. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64896. */
  64897. export class BloomEffect extends PostProcessRenderEffect {
  64898. private bloomScale;
  64899. /**
  64900. * @hidden Internal
  64901. */
  64902. _effects: Array<PostProcess>;
  64903. /**
  64904. * @hidden Internal
  64905. */
  64906. _downscale: ExtractHighlightsPostProcess;
  64907. private _blurX;
  64908. private _blurY;
  64909. private _merge;
  64910. /**
  64911. * The luminance threshold to find bright areas of the image to bloom.
  64912. */
  64913. get threshold(): number;
  64914. set threshold(value: number);
  64915. /**
  64916. * The strength of the bloom.
  64917. */
  64918. get weight(): number;
  64919. set weight(value: number);
  64920. /**
  64921. * Specifies the size of the bloom blur kernel, relative to the final output size
  64922. */
  64923. get kernel(): number;
  64924. set kernel(value: number);
  64925. /**
  64926. * Creates a new instance of @see BloomEffect
  64927. * @param scene The scene the effect belongs to.
  64928. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64929. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64930. * @param bloomWeight The the strength of bloom.
  64931. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64932. * @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)
  64933. */
  64934. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64935. /**
  64936. * Disposes each of the internal effects for a given camera.
  64937. * @param camera The camera to dispose the effect on.
  64938. */
  64939. disposeEffects(camera: Camera): void;
  64940. /**
  64941. * @hidden Internal
  64942. */
  64943. _updateEffects(): void;
  64944. /**
  64945. * Internal
  64946. * @returns if all the contained post processes are ready.
  64947. * @hidden
  64948. */
  64949. _isReady(): boolean;
  64950. }
  64951. }
  64952. declare module BABYLON {
  64953. /** @hidden */
  64954. export var chromaticAberrationPixelShader: {
  64955. name: string;
  64956. shader: string;
  64957. };
  64958. }
  64959. declare module BABYLON {
  64960. /**
  64961. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64962. */
  64963. export class ChromaticAberrationPostProcess extends PostProcess {
  64964. /**
  64965. * The amount of seperation of rgb channels (default: 30)
  64966. */
  64967. aberrationAmount: number;
  64968. /**
  64969. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64970. */
  64971. radialIntensity: number;
  64972. /**
  64973. * 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))
  64974. */
  64975. direction: Vector2;
  64976. /**
  64977. * 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))
  64978. */
  64979. centerPosition: Vector2;
  64980. /**
  64981. * Creates a new instance ChromaticAberrationPostProcess
  64982. * @param name The name of the effect.
  64983. * @param screenWidth The width of the screen to apply the effect on.
  64984. * @param screenHeight The height of the screen to apply the effect on.
  64985. * @param options The required width/height ratio to downsize to before computing the render pass.
  64986. * @param camera The camera to apply the render pass to.
  64987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64988. * @param engine The engine which the post process will be applied. (default: current engine)
  64989. * @param reusable If the post process can be reused on the same frame. (default: false)
  64990. * @param textureType Type of textures used when performing the post process. (default: 0)
  64991. * @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)
  64992. */
  64993. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64994. }
  64995. }
  64996. declare module BABYLON {
  64997. /** @hidden */
  64998. export var circleOfConfusionPixelShader: {
  64999. name: string;
  65000. shader: string;
  65001. };
  65002. }
  65003. declare module BABYLON {
  65004. /**
  65005. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65006. */
  65007. export class CircleOfConfusionPostProcess extends PostProcess {
  65008. /**
  65009. * 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.
  65010. */
  65011. lensSize: number;
  65012. /**
  65013. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65014. */
  65015. fStop: number;
  65016. /**
  65017. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65018. */
  65019. focusDistance: number;
  65020. /**
  65021. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65022. */
  65023. focalLength: number;
  65024. private _depthTexture;
  65025. /**
  65026. * Creates a new instance CircleOfConfusionPostProcess
  65027. * @param name The name of the effect.
  65028. * @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.
  65029. * @param options The required width/height ratio to downsize to before computing the render pass.
  65030. * @param camera The camera to apply the render pass to.
  65031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65032. * @param engine The engine which the post process will be applied. (default: current engine)
  65033. * @param reusable If the post process can be reused on the same frame. (default: false)
  65034. * @param textureType Type of textures used when performing the post process. (default: 0)
  65035. * @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)
  65036. */
  65037. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65038. /**
  65039. * 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.
  65040. */
  65041. set depthTexture(value: RenderTargetTexture);
  65042. }
  65043. }
  65044. declare module BABYLON {
  65045. /** @hidden */
  65046. export var colorCorrectionPixelShader: {
  65047. name: string;
  65048. shader: string;
  65049. };
  65050. }
  65051. declare module BABYLON {
  65052. /**
  65053. *
  65054. * This post-process allows the modification of rendered colors by using
  65055. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65056. *
  65057. * The object needs to be provided an url to a texture containing the color
  65058. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65059. * Use an image editing software to tweak the LUT to match your needs.
  65060. *
  65061. * For an example of a color LUT, see here:
  65062. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65063. * For explanations on color grading, see here:
  65064. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65065. *
  65066. */
  65067. export class ColorCorrectionPostProcess extends PostProcess {
  65068. private _colorTableTexture;
  65069. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65070. }
  65071. }
  65072. declare module BABYLON {
  65073. /** @hidden */
  65074. export var convolutionPixelShader: {
  65075. name: string;
  65076. shader: string;
  65077. };
  65078. }
  65079. declare module BABYLON {
  65080. /**
  65081. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65082. * input texture to perform effects such as edge detection or sharpening
  65083. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65084. */
  65085. export class ConvolutionPostProcess extends PostProcess {
  65086. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65087. kernel: number[];
  65088. /**
  65089. * Creates a new instance ConvolutionPostProcess
  65090. * @param name The name of the effect.
  65091. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65092. * @param options The required width/height ratio to downsize to before computing the render pass.
  65093. * @param camera The camera to apply the render pass to.
  65094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65095. * @param engine The engine which the post process will be applied. (default: current engine)
  65096. * @param reusable If the post process can be reused on the same frame. (default: false)
  65097. * @param textureType Type of textures used when performing the post process. (default: 0)
  65098. */
  65099. constructor(name: string,
  65100. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65101. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65102. /**
  65103. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65104. */
  65105. static EdgeDetect0Kernel: number[];
  65106. /**
  65107. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65108. */
  65109. static EdgeDetect1Kernel: number[];
  65110. /**
  65111. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65112. */
  65113. static EdgeDetect2Kernel: number[];
  65114. /**
  65115. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65116. */
  65117. static SharpenKernel: number[];
  65118. /**
  65119. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65120. */
  65121. static EmbossKernel: number[];
  65122. /**
  65123. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65124. */
  65125. static GaussianKernel: number[];
  65126. }
  65127. }
  65128. declare module BABYLON {
  65129. /**
  65130. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65131. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65132. * based on samples that have a large difference in distance than the center pixel.
  65133. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65134. */
  65135. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65136. direction: Vector2;
  65137. /**
  65138. * Creates a new instance CircleOfConfusionPostProcess
  65139. * @param name The name of the effect.
  65140. * @param scene The scene the effect belongs to.
  65141. * @param direction The direction the blur should be applied.
  65142. * @param kernel The size of the kernel used to blur.
  65143. * @param options The required width/height ratio to downsize to before computing the render pass.
  65144. * @param camera The camera to apply the render pass to.
  65145. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65146. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65148. * @param engine The engine which the post process will be applied. (default: current engine)
  65149. * @param reusable If the post process can be reused on the same frame. (default: false)
  65150. * @param textureType Type of textures used when performing the post process. (default: 0)
  65151. * @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)
  65152. */
  65153. 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);
  65154. }
  65155. }
  65156. declare module BABYLON {
  65157. /** @hidden */
  65158. export var depthOfFieldMergePixelShader: {
  65159. name: string;
  65160. shader: string;
  65161. };
  65162. }
  65163. declare module BABYLON {
  65164. /**
  65165. * Options to be set when merging outputs from the default pipeline.
  65166. */
  65167. export class DepthOfFieldMergePostProcessOptions {
  65168. /**
  65169. * The original image to merge on top of
  65170. */
  65171. originalFromInput: PostProcess;
  65172. /**
  65173. * Parameters to perform the merge of the depth of field effect
  65174. */
  65175. depthOfField?: {
  65176. circleOfConfusion: PostProcess;
  65177. blurSteps: Array<PostProcess>;
  65178. };
  65179. /**
  65180. * Parameters to perform the merge of bloom effect
  65181. */
  65182. bloom?: {
  65183. blurred: PostProcess;
  65184. weight: number;
  65185. };
  65186. }
  65187. /**
  65188. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65189. */
  65190. export class DepthOfFieldMergePostProcess extends PostProcess {
  65191. private blurSteps;
  65192. /**
  65193. * Creates a new instance of DepthOfFieldMergePostProcess
  65194. * @param name The name of the effect.
  65195. * @param originalFromInput Post process which's input will be used for the merge.
  65196. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65197. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65198. * @param options The required width/height ratio to downsize to before computing the render pass.
  65199. * @param camera The camera to apply the render pass to.
  65200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65201. * @param engine The engine which the post process will be applied. (default: current engine)
  65202. * @param reusable If the post process can be reused on the same frame. (default: false)
  65203. * @param textureType Type of textures used when performing the post process. (default: 0)
  65204. * @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)
  65205. */
  65206. 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);
  65207. /**
  65208. * Updates the effect with the current post process compile time values and recompiles the shader.
  65209. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65210. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65211. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65212. * @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
  65213. * @param onCompiled Called when the shader has been compiled.
  65214. * @param onError Called if there is an error when compiling a shader.
  65215. */
  65216. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65217. }
  65218. }
  65219. declare module BABYLON {
  65220. /**
  65221. * Specifies the level of max blur that should be applied when using the depth of field effect
  65222. */
  65223. export enum DepthOfFieldEffectBlurLevel {
  65224. /**
  65225. * Subtle blur
  65226. */
  65227. Low = 0,
  65228. /**
  65229. * Medium blur
  65230. */
  65231. Medium = 1,
  65232. /**
  65233. * Large blur
  65234. */
  65235. High = 2
  65236. }
  65237. /**
  65238. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65239. */
  65240. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65241. private _circleOfConfusion;
  65242. /**
  65243. * @hidden Internal, blurs from high to low
  65244. */
  65245. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65246. private _depthOfFieldBlurY;
  65247. private _dofMerge;
  65248. /**
  65249. * @hidden Internal post processes in depth of field effect
  65250. */
  65251. _effects: Array<PostProcess>;
  65252. /**
  65253. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65254. */
  65255. set focalLength(value: number);
  65256. get focalLength(): number;
  65257. /**
  65258. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65259. */
  65260. set fStop(value: number);
  65261. get fStop(): number;
  65262. /**
  65263. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65264. */
  65265. set focusDistance(value: number);
  65266. get focusDistance(): number;
  65267. /**
  65268. * 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.
  65269. */
  65270. set lensSize(value: number);
  65271. get lensSize(): number;
  65272. /**
  65273. * Creates a new instance DepthOfFieldEffect
  65274. * @param scene The scene the effect belongs to.
  65275. * @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.
  65276. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65277. * @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)
  65278. */
  65279. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65280. /**
  65281. * Get the current class name of the current effet
  65282. * @returns "DepthOfFieldEffect"
  65283. */
  65284. getClassName(): string;
  65285. /**
  65286. * 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.
  65287. */
  65288. set depthTexture(value: RenderTargetTexture);
  65289. /**
  65290. * Disposes each of the internal effects for a given camera.
  65291. * @param camera The camera to dispose the effect on.
  65292. */
  65293. disposeEffects(camera: Camera): void;
  65294. /**
  65295. * @hidden Internal
  65296. */
  65297. _updateEffects(): void;
  65298. /**
  65299. * Internal
  65300. * @returns if all the contained post processes are ready.
  65301. * @hidden
  65302. */
  65303. _isReady(): boolean;
  65304. }
  65305. }
  65306. declare module BABYLON {
  65307. /** @hidden */
  65308. export var displayPassPixelShader: {
  65309. name: string;
  65310. shader: string;
  65311. };
  65312. }
  65313. declare module BABYLON {
  65314. /**
  65315. * DisplayPassPostProcess which produces an output the same as it's input
  65316. */
  65317. export class DisplayPassPostProcess extends PostProcess {
  65318. /**
  65319. * Creates the DisplayPassPostProcess
  65320. * @param name The name of the effect.
  65321. * @param options The required width/height ratio to downsize to before computing the render pass.
  65322. * @param camera The camera to apply the render pass to.
  65323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65324. * @param engine The engine which the post process will be applied. (default: current engine)
  65325. * @param reusable If the post process can be reused on the same frame. (default: false)
  65326. */
  65327. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65328. }
  65329. }
  65330. declare module BABYLON {
  65331. /** @hidden */
  65332. export var filterPixelShader: {
  65333. name: string;
  65334. shader: string;
  65335. };
  65336. }
  65337. declare module BABYLON {
  65338. /**
  65339. * Applies a kernel filter to the image
  65340. */
  65341. export class FilterPostProcess extends PostProcess {
  65342. /** The matrix to be applied to the image */
  65343. kernelMatrix: Matrix;
  65344. /**
  65345. *
  65346. * @param name The name of the effect.
  65347. * @param kernelMatrix The matrix to be applied to the image
  65348. * @param options The required width/height ratio to downsize to before computing the render pass.
  65349. * @param camera The camera to apply the render pass to.
  65350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65351. * @param engine The engine which the post process will be applied. (default: current engine)
  65352. * @param reusable If the post process can be reused on the same frame. (default: false)
  65353. */
  65354. constructor(name: string,
  65355. /** The matrix to be applied to the image */
  65356. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65357. }
  65358. }
  65359. declare module BABYLON {
  65360. /** @hidden */
  65361. export var fxaaPixelShader: {
  65362. name: string;
  65363. shader: string;
  65364. };
  65365. }
  65366. declare module BABYLON {
  65367. /** @hidden */
  65368. export var fxaaVertexShader: {
  65369. name: string;
  65370. shader: string;
  65371. };
  65372. }
  65373. declare module BABYLON {
  65374. /**
  65375. * Fxaa post process
  65376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65377. */
  65378. export class FxaaPostProcess extends PostProcess {
  65379. /** @hidden */
  65380. texelWidth: number;
  65381. /** @hidden */
  65382. texelHeight: number;
  65383. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65384. private _getDefines;
  65385. }
  65386. }
  65387. declare module BABYLON {
  65388. /** @hidden */
  65389. export var grainPixelShader: {
  65390. name: string;
  65391. shader: string;
  65392. };
  65393. }
  65394. declare module BABYLON {
  65395. /**
  65396. * The GrainPostProcess adds noise to the image at mid luminance levels
  65397. */
  65398. export class GrainPostProcess extends PostProcess {
  65399. /**
  65400. * The intensity of the grain added (default: 30)
  65401. */
  65402. intensity: number;
  65403. /**
  65404. * If the grain should be randomized on every frame
  65405. */
  65406. animated: boolean;
  65407. /**
  65408. * Creates a new instance of @see GrainPostProcess
  65409. * @param name The name of the effect.
  65410. * @param options The required width/height ratio to downsize to before computing the render pass.
  65411. * @param camera The camera to apply the render pass to.
  65412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65413. * @param engine The engine which the post process will be applied. (default: current engine)
  65414. * @param reusable If the post process can be reused on the same frame. (default: false)
  65415. * @param textureType Type of textures used when performing the post process. (default: 0)
  65416. * @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)
  65417. */
  65418. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65419. }
  65420. }
  65421. declare module BABYLON {
  65422. /** @hidden */
  65423. export var highlightsPixelShader: {
  65424. name: string;
  65425. shader: string;
  65426. };
  65427. }
  65428. declare module BABYLON {
  65429. /**
  65430. * Extracts highlights from the image
  65431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65432. */
  65433. export class HighlightsPostProcess extends PostProcess {
  65434. /**
  65435. * Extracts highlights from the image
  65436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65437. * @param name The name of the effect.
  65438. * @param options The required width/height ratio to downsize to before computing the render pass.
  65439. * @param camera The camera to apply the render pass to.
  65440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65441. * @param engine The engine which the post process will be applied. (default: current engine)
  65442. * @param reusable If the post process can be reused on the same frame. (default: false)
  65443. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65444. */
  65445. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65446. }
  65447. }
  65448. declare module BABYLON {
  65449. /** @hidden */
  65450. export var mrtFragmentDeclaration: {
  65451. name: string;
  65452. shader: string;
  65453. };
  65454. }
  65455. declare module BABYLON {
  65456. /** @hidden */
  65457. export var geometryPixelShader: {
  65458. name: string;
  65459. shader: string;
  65460. };
  65461. }
  65462. declare module BABYLON {
  65463. /** @hidden */
  65464. export var geometryVertexShader: {
  65465. name: string;
  65466. shader: string;
  65467. };
  65468. }
  65469. declare module BABYLON {
  65470. /** @hidden */
  65471. interface ISavedTransformationMatrix {
  65472. world: Matrix;
  65473. viewProjection: Matrix;
  65474. }
  65475. /**
  65476. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65477. */
  65478. export class GeometryBufferRenderer {
  65479. /**
  65480. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65481. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65482. */
  65483. static readonly POSITION_TEXTURE_TYPE: number;
  65484. /**
  65485. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65486. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65487. */
  65488. static readonly VELOCITY_TEXTURE_TYPE: number;
  65489. /**
  65490. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65491. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65492. */
  65493. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65494. /**
  65495. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65496. * in order to compute objects velocities when enableVelocity is set to "true"
  65497. * @hidden
  65498. */
  65499. _previousTransformationMatrices: {
  65500. [index: number]: ISavedTransformationMatrix;
  65501. };
  65502. /**
  65503. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65504. * in order to compute objects velocities when enableVelocity is set to "true"
  65505. * @hidden
  65506. */
  65507. _previousBonesTransformationMatrices: {
  65508. [index: number]: Float32Array;
  65509. };
  65510. /**
  65511. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65512. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65513. */
  65514. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65515. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65516. renderTransparentMeshes: boolean;
  65517. private _scene;
  65518. private _multiRenderTarget;
  65519. private _ratio;
  65520. private _enablePosition;
  65521. private _enableVelocity;
  65522. private _enableReflectivity;
  65523. private _positionIndex;
  65524. private _velocityIndex;
  65525. private _reflectivityIndex;
  65526. protected _effect: Effect;
  65527. protected _cachedDefines: string;
  65528. /**
  65529. * Set the render list (meshes to be rendered) used in the G buffer.
  65530. */
  65531. set renderList(meshes: Mesh[]);
  65532. /**
  65533. * Gets wether or not G buffer are supported by the running hardware.
  65534. * This requires draw buffer supports
  65535. */
  65536. get isSupported(): boolean;
  65537. /**
  65538. * Returns the index of the given texture type in the G-Buffer textures array
  65539. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65540. * @returns the index of the given texture type in the G-Buffer textures array
  65541. */
  65542. getTextureIndex(textureType: number): number;
  65543. /**
  65544. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65545. */
  65546. get enablePosition(): boolean;
  65547. /**
  65548. * Sets whether or not objects positions are enabled for the G buffer.
  65549. */
  65550. set enablePosition(enable: boolean);
  65551. /**
  65552. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65553. */
  65554. get enableVelocity(): boolean;
  65555. /**
  65556. * Sets wether or not objects velocities are enabled for the G buffer.
  65557. */
  65558. set enableVelocity(enable: boolean);
  65559. /**
  65560. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65561. */
  65562. get enableReflectivity(): boolean;
  65563. /**
  65564. * Sets wether or not objects roughness are enabled for the G buffer.
  65565. */
  65566. set enableReflectivity(enable: boolean);
  65567. /**
  65568. * Gets the scene associated with the buffer.
  65569. */
  65570. get scene(): Scene;
  65571. /**
  65572. * Gets the ratio used by the buffer during its creation.
  65573. * How big is the buffer related to the main canvas.
  65574. */
  65575. get ratio(): number;
  65576. /** @hidden */
  65577. static _SceneComponentInitialization: (scene: Scene) => void;
  65578. /**
  65579. * Creates a new G Buffer for the scene
  65580. * @param scene The scene the buffer belongs to
  65581. * @param ratio How big is the buffer related to the main canvas.
  65582. */
  65583. constructor(scene: Scene, ratio?: number);
  65584. /**
  65585. * Checks wether everything is ready to render a submesh to the G buffer.
  65586. * @param subMesh the submesh to check readiness for
  65587. * @param useInstances is the mesh drawn using instance or not
  65588. * @returns true if ready otherwise false
  65589. */
  65590. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65591. /**
  65592. * Gets the current underlying G Buffer.
  65593. * @returns the buffer
  65594. */
  65595. getGBuffer(): MultiRenderTarget;
  65596. /**
  65597. * Gets the number of samples used to render the buffer (anti aliasing).
  65598. */
  65599. get samples(): number;
  65600. /**
  65601. * Sets the number of samples used to render the buffer (anti aliasing).
  65602. */
  65603. set samples(value: number);
  65604. /**
  65605. * Disposes the renderer and frees up associated resources.
  65606. */
  65607. dispose(): void;
  65608. protected _createRenderTargets(): void;
  65609. private _copyBonesTransformationMatrices;
  65610. }
  65611. }
  65612. declare module BABYLON {
  65613. interface Scene {
  65614. /** @hidden (Backing field) */
  65615. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65616. /**
  65617. * Gets or Sets the current geometry buffer associated to the scene.
  65618. */
  65619. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65620. /**
  65621. * Enables a GeometryBufferRender and associates it with the scene
  65622. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65623. * @returns the GeometryBufferRenderer
  65624. */
  65625. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65626. /**
  65627. * Disables the GeometryBufferRender associated with the scene
  65628. */
  65629. disableGeometryBufferRenderer(): void;
  65630. }
  65631. /**
  65632. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65633. * in several rendering techniques.
  65634. */
  65635. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65636. /**
  65637. * The component name helpful to identify the component in the list of scene components.
  65638. */
  65639. readonly name: string;
  65640. /**
  65641. * The scene the component belongs to.
  65642. */
  65643. scene: Scene;
  65644. /**
  65645. * Creates a new instance of the component for the given scene
  65646. * @param scene Defines the scene to register the component in
  65647. */
  65648. constructor(scene: Scene);
  65649. /**
  65650. * Registers the component in a given scene
  65651. */
  65652. register(): void;
  65653. /**
  65654. * Rebuilds the elements related to this component in case of
  65655. * context lost for instance.
  65656. */
  65657. rebuild(): void;
  65658. /**
  65659. * Disposes the component and the associated ressources
  65660. */
  65661. dispose(): void;
  65662. private _gatherRenderTargets;
  65663. }
  65664. }
  65665. declare module BABYLON {
  65666. /** @hidden */
  65667. export var motionBlurPixelShader: {
  65668. name: string;
  65669. shader: string;
  65670. };
  65671. }
  65672. declare module BABYLON {
  65673. /**
  65674. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65675. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65676. * As an example, all you have to do is to create the post-process:
  65677. * var mb = new BABYLON.MotionBlurPostProcess(
  65678. * 'mb', // The name of the effect.
  65679. * scene, // The scene containing the objects to blur according to their velocity.
  65680. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65681. * camera // The camera to apply the render pass to.
  65682. * );
  65683. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65684. */
  65685. export class MotionBlurPostProcess extends PostProcess {
  65686. /**
  65687. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65688. */
  65689. motionStrength: number;
  65690. /**
  65691. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65692. */
  65693. get motionBlurSamples(): number;
  65694. /**
  65695. * Sets the number of iterations to be used for motion blur quality
  65696. */
  65697. set motionBlurSamples(samples: number);
  65698. private _motionBlurSamples;
  65699. private _geometryBufferRenderer;
  65700. /**
  65701. * Creates a new instance MotionBlurPostProcess
  65702. * @param name The name of the effect.
  65703. * @param scene The scene containing the objects to blur according to their velocity.
  65704. * @param options The required width/height ratio to downsize to before computing the render pass.
  65705. * @param camera The camera to apply the render pass to.
  65706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65707. * @param engine The engine which the post process will be applied. (default: current engine)
  65708. * @param reusable If the post process can be reused on the same frame. (default: false)
  65709. * @param textureType Type of textures used when performing the post process. (default: 0)
  65710. * @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)
  65711. */
  65712. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65713. /**
  65714. * Excludes the given skinned mesh from computing bones velocities.
  65715. * 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.
  65716. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65717. */
  65718. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65719. /**
  65720. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65721. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65722. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65723. */
  65724. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65725. /**
  65726. * Disposes the post process.
  65727. * @param camera The camera to dispose the post process on.
  65728. */
  65729. dispose(camera?: Camera): void;
  65730. }
  65731. }
  65732. declare module BABYLON {
  65733. /** @hidden */
  65734. export var refractionPixelShader: {
  65735. name: string;
  65736. shader: string;
  65737. };
  65738. }
  65739. declare module BABYLON {
  65740. /**
  65741. * Post process which applies a refractin texture
  65742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65743. */
  65744. export class RefractionPostProcess extends PostProcess {
  65745. /** the base color of the refraction (used to taint the rendering) */
  65746. color: Color3;
  65747. /** simulated refraction depth */
  65748. depth: number;
  65749. /** the coefficient of the base color (0 to remove base color tainting) */
  65750. colorLevel: number;
  65751. private _refTexture;
  65752. private _ownRefractionTexture;
  65753. /**
  65754. * Gets or sets the refraction texture
  65755. * Please note that you are responsible for disposing the texture if you set it manually
  65756. */
  65757. get refractionTexture(): Texture;
  65758. set refractionTexture(value: Texture);
  65759. /**
  65760. * Initializes the RefractionPostProcess
  65761. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65762. * @param name The name of the effect.
  65763. * @param refractionTextureUrl Url of the refraction texture to use
  65764. * @param color the base color of the refraction (used to taint the rendering)
  65765. * @param depth simulated refraction depth
  65766. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65767. * @param camera The camera to apply the render pass to.
  65768. * @param options The required width/height ratio to downsize to before computing the render pass.
  65769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65770. * @param engine The engine which the post process will be applied. (default: current engine)
  65771. * @param reusable If the post process can be reused on the same frame. (default: false)
  65772. */
  65773. constructor(name: string, refractionTextureUrl: string,
  65774. /** the base color of the refraction (used to taint the rendering) */
  65775. color: Color3,
  65776. /** simulated refraction depth */
  65777. depth: number,
  65778. /** the coefficient of the base color (0 to remove base color tainting) */
  65779. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65780. /**
  65781. * Disposes of the post process
  65782. * @param camera Camera to dispose post process on
  65783. */
  65784. dispose(camera: Camera): void;
  65785. }
  65786. }
  65787. declare module BABYLON {
  65788. /** @hidden */
  65789. export var sharpenPixelShader: {
  65790. name: string;
  65791. shader: string;
  65792. };
  65793. }
  65794. declare module BABYLON {
  65795. /**
  65796. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65797. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65798. */
  65799. export class SharpenPostProcess extends PostProcess {
  65800. /**
  65801. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65802. */
  65803. colorAmount: number;
  65804. /**
  65805. * How much sharpness should be applied (default: 0.3)
  65806. */
  65807. edgeAmount: number;
  65808. /**
  65809. * Creates a new instance ConvolutionPostProcess
  65810. * @param name The name of the effect.
  65811. * @param options The required width/height ratio to downsize to before computing the render pass.
  65812. * @param camera The camera to apply the render pass to.
  65813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65814. * @param engine The engine which the post process will be applied. (default: current engine)
  65815. * @param reusable If the post process can be reused on the same frame. (default: false)
  65816. * @param textureType Type of textures used when performing the post process. (default: 0)
  65817. * @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)
  65818. */
  65819. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65820. }
  65821. }
  65822. declare module BABYLON {
  65823. /**
  65824. * PostProcessRenderPipeline
  65825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65826. */
  65827. export class PostProcessRenderPipeline {
  65828. private engine;
  65829. private _renderEffects;
  65830. private _renderEffectsForIsolatedPass;
  65831. /**
  65832. * List of inspectable custom properties (used by the Inspector)
  65833. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65834. */
  65835. inspectableCustomProperties: IInspectable[];
  65836. /**
  65837. * @hidden
  65838. */
  65839. protected _cameras: Camera[];
  65840. /** @hidden */
  65841. _name: string;
  65842. /**
  65843. * Gets pipeline name
  65844. */
  65845. get name(): string;
  65846. /** Gets the list of attached cameras */
  65847. get cameras(): Camera[];
  65848. /**
  65849. * Initializes a PostProcessRenderPipeline
  65850. * @param engine engine to add the pipeline to
  65851. * @param name name of the pipeline
  65852. */
  65853. constructor(engine: Engine, name: string);
  65854. /**
  65855. * Gets the class name
  65856. * @returns "PostProcessRenderPipeline"
  65857. */
  65858. getClassName(): string;
  65859. /**
  65860. * If all the render effects in the pipeline are supported
  65861. */
  65862. get isSupported(): boolean;
  65863. /**
  65864. * Adds an effect to the pipeline
  65865. * @param renderEffect the effect to add
  65866. */
  65867. addEffect(renderEffect: PostProcessRenderEffect): void;
  65868. /** @hidden */
  65869. _rebuild(): void;
  65870. /** @hidden */
  65871. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65872. /** @hidden */
  65873. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65874. /** @hidden */
  65875. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65876. /** @hidden */
  65877. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65878. /** @hidden */
  65879. _attachCameras(cameras: Camera, unique: boolean): void;
  65880. /** @hidden */
  65881. _attachCameras(cameras: Camera[], unique: boolean): void;
  65882. /** @hidden */
  65883. _detachCameras(cameras: Camera): void;
  65884. /** @hidden */
  65885. _detachCameras(cameras: Nullable<Camera[]>): void;
  65886. /** @hidden */
  65887. _update(): void;
  65888. /** @hidden */
  65889. _reset(): void;
  65890. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65891. /**
  65892. * Disposes of the pipeline
  65893. */
  65894. dispose(): void;
  65895. }
  65896. }
  65897. declare module BABYLON {
  65898. /**
  65899. * PostProcessRenderPipelineManager class
  65900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65901. */
  65902. export class PostProcessRenderPipelineManager {
  65903. private _renderPipelines;
  65904. /**
  65905. * Initializes a PostProcessRenderPipelineManager
  65906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65907. */
  65908. constructor();
  65909. /**
  65910. * Gets the list of supported render pipelines
  65911. */
  65912. get supportedPipelines(): PostProcessRenderPipeline[];
  65913. /**
  65914. * Adds a pipeline to the manager
  65915. * @param renderPipeline The pipeline to add
  65916. */
  65917. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65918. /**
  65919. * Attaches a camera to the pipeline
  65920. * @param renderPipelineName The name of the pipeline to attach to
  65921. * @param cameras the camera to attach
  65922. * @param unique if the camera can be attached multiple times to the pipeline
  65923. */
  65924. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65925. /**
  65926. * Detaches a camera from the pipeline
  65927. * @param renderPipelineName The name of the pipeline to detach from
  65928. * @param cameras the camera to detach
  65929. */
  65930. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65931. /**
  65932. * Enables an effect by name on a pipeline
  65933. * @param renderPipelineName the name of the pipeline to enable the effect in
  65934. * @param renderEffectName the name of the effect to enable
  65935. * @param cameras the cameras that the effect should be enabled on
  65936. */
  65937. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65938. /**
  65939. * Disables an effect by name on a pipeline
  65940. * @param renderPipelineName the name of the pipeline to disable the effect in
  65941. * @param renderEffectName the name of the effect to disable
  65942. * @param cameras the cameras that the effect should be disabled on
  65943. */
  65944. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65945. /**
  65946. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65947. */
  65948. update(): void;
  65949. /** @hidden */
  65950. _rebuild(): void;
  65951. /**
  65952. * Disposes of the manager and pipelines
  65953. */
  65954. dispose(): void;
  65955. }
  65956. }
  65957. declare module BABYLON {
  65958. interface Scene {
  65959. /** @hidden (Backing field) */
  65960. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65961. /**
  65962. * Gets the postprocess render pipeline manager
  65963. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65964. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65965. */
  65966. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65967. }
  65968. /**
  65969. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65970. */
  65971. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65972. /**
  65973. * The component name helpfull to identify the component in the list of scene components.
  65974. */
  65975. readonly name: string;
  65976. /**
  65977. * The scene the component belongs to.
  65978. */
  65979. scene: Scene;
  65980. /**
  65981. * Creates a new instance of the component for the given scene
  65982. * @param scene Defines the scene to register the component in
  65983. */
  65984. constructor(scene: Scene);
  65985. /**
  65986. * Registers the component in a given scene
  65987. */
  65988. register(): void;
  65989. /**
  65990. * Rebuilds the elements related to this component in case of
  65991. * context lost for instance.
  65992. */
  65993. rebuild(): void;
  65994. /**
  65995. * Disposes the component and the associated ressources
  65996. */
  65997. dispose(): void;
  65998. private _gatherRenderTargets;
  65999. }
  66000. }
  66001. declare module BABYLON {
  66002. /**
  66003. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66004. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66005. */
  66006. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66007. private _scene;
  66008. private _camerasToBeAttached;
  66009. /**
  66010. * ID of the sharpen post process,
  66011. */
  66012. private readonly SharpenPostProcessId;
  66013. /**
  66014. * @ignore
  66015. * ID of the image processing post process;
  66016. */
  66017. readonly ImageProcessingPostProcessId: string;
  66018. /**
  66019. * @ignore
  66020. * ID of the Fast Approximate Anti-Aliasing post process;
  66021. */
  66022. readonly FxaaPostProcessId: string;
  66023. /**
  66024. * ID of the chromatic aberration post process,
  66025. */
  66026. private readonly ChromaticAberrationPostProcessId;
  66027. /**
  66028. * ID of the grain post process
  66029. */
  66030. private readonly GrainPostProcessId;
  66031. /**
  66032. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66033. */
  66034. sharpen: SharpenPostProcess;
  66035. private _sharpenEffect;
  66036. private bloom;
  66037. /**
  66038. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66039. */
  66040. depthOfField: DepthOfFieldEffect;
  66041. /**
  66042. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66043. */
  66044. fxaa: FxaaPostProcess;
  66045. /**
  66046. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66047. */
  66048. imageProcessing: ImageProcessingPostProcess;
  66049. /**
  66050. * Chromatic aberration post process which will shift rgb colors in the image
  66051. */
  66052. chromaticAberration: ChromaticAberrationPostProcess;
  66053. private _chromaticAberrationEffect;
  66054. /**
  66055. * Grain post process which add noise to the image
  66056. */
  66057. grain: GrainPostProcess;
  66058. private _grainEffect;
  66059. /**
  66060. * Glow post process which adds a glow to emissive areas of the image
  66061. */
  66062. private _glowLayer;
  66063. /**
  66064. * Animations which can be used to tweak settings over a period of time
  66065. */
  66066. animations: Animation[];
  66067. private _imageProcessingConfigurationObserver;
  66068. private _sharpenEnabled;
  66069. private _bloomEnabled;
  66070. private _depthOfFieldEnabled;
  66071. private _depthOfFieldBlurLevel;
  66072. private _fxaaEnabled;
  66073. private _imageProcessingEnabled;
  66074. private _defaultPipelineTextureType;
  66075. private _bloomScale;
  66076. private _chromaticAberrationEnabled;
  66077. private _grainEnabled;
  66078. private _buildAllowed;
  66079. /**
  66080. * Gets active scene
  66081. */
  66082. get scene(): Scene;
  66083. /**
  66084. * Enable or disable the sharpen process from the pipeline
  66085. */
  66086. set sharpenEnabled(enabled: boolean);
  66087. get sharpenEnabled(): boolean;
  66088. private _resizeObserver;
  66089. private _hardwareScaleLevel;
  66090. private _bloomKernel;
  66091. /**
  66092. * Specifies the size of the bloom blur kernel, relative to the final output size
  66093. */
  66094. get bloomKernel(): number;
  66095. set bloomKernel(value: number);
  66096. /**
  66097. * Specifies the weight of the bloom in the final rendering
  66098. */
  66099. private _bloomWeight;
  66100. /**
  66101. * Specifies the luma threshold for the area that will be blurred by the bloom
  66102. */
  66103. private _bloomThreshold;
  66104. private _hdr;
  66105. /**
  66106. * The strength of the bloom.
  66107. */
  66108. set bloomWeight(value: number);
  66109. get bloomWeight(): number;
  66110. /**
  66111. * The strength of the bloom.
  66112. */
  66113. set bloomThreshold(value: number);
  66114. get bloomThreshold(): number;
  66115. /**
  66116. * The scale of the bloom, lower value will provide better performance.
  66117. */
  66118. set bloomScale(value: number);
  66119. get bloomScale(): number;
  66120. /**
  66121. * Enable or disable the bloom from the pipeline
  66122. */
  66123. set bloomEnabled(enabled: boolean);
  66124. get bloomEnabled(): boolean;
  66125. private _rebuildBloom;
  66126. /**
  66127. * If the depth of field is enabled.
  66128. */
  66129. get depthOfFieldEnabled(): boolean;
  66130. set depthOfFieldEnabled(enabled: boolean);
  66131. /**
  66132. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66133. */
  66134. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66135. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66136. /**
  66137. * If the anti aliasing is enabled.
  66138. */
  66139. set fxaaEnabled(enabled: boolean);
  66140. get fxaaEnabled(): boolean;
  66141. private _samples;
  66142. /**
  66143. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66144. */
  66145. set samples(sampleCount: number);
  66146. get samples(): number;
  66147. /**
  66148. * If image processing is enabled.
  66149. */
  66150. set imageProcessingEnabled(enabled: boolean);
  66151. get imageProcessingEnabled(): boolean;
  66152. /**
  66153. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66154. */
  66155. set glowLayerEnabled(enabled: boolean);
  66156. get glowLayerEnabled(): boolean;
  66157. /**
  66158. * Gets the glow layer (or null if not defined)
  66159. */
  66160. get glowLayer(): Nullable<GlowLayer>;
  66161. /**
  66162. * Enable or disable the chromaticAberration process from the pipeline
  66163. */
  66164. set chromaticAberrationEnabled(enabled: boolean);
  66165. get chromaticAberrationEnabled(): boolean;
  66166. /**
  66167. * Enable or disable the grain process from the pipeline
  66168. */
  66169. set grainEnabled(enabled: boolean);
  66170. get grainEnabled(): boolean;
  66171. /**
  66172. * @constructor
  66173. * @param name - The rendering pipeline name (default: "")
  66174. * @param hdr - If high dynamic range textures should be used (default: true)
  66175. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66176. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66177. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66178. */
  66179. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66180. /**
  66181. * Get the class name
  66182. * @returns "DefaultRenderingPipeline"
  66183. */
  66184. getClassName(): string;
  66185. /**
  66186. * Force the compilation of the entire pipeline.
  66187. */
  66188. prepare(): void;
  66189. private _hasCleared;
  66190. private _prevPostProcess;
  66191. private _prevPrevPostProcess;
  66192. private _setAutoClearAndTextureSharing;
  66193. private _depthOfFieldSceneObserver;
  66194. private _buildPipeline;
  66195. private _disposePostProcesses;
  66196. /**
  66197. * Adds a camera to the pipeline
  66198. * @param camera the camera to be added
  66199. */
  66200. addCamera(camera: Camera): void;
  66201. /**
  66202. * Removes a camera from the pipeline
  66203. * @param camera the camera to remove
  66204. */
  66205. removeCamera(camera: Camera): void;
  66206. /**
  66207. * Dispose of the pipeline and stop all post processes
  66208. */
  66209. dispose(): void;
  66210. /**
  66211. * Serialize the rendering pipeline (Used when exporting)
  66212. * @returns the serialized object
  66213. */
  66214. serialize(): any;
  66215. /**
  66216. * Parse the serialized pipeline
  66217. * @param source Source pipeline.
  66218. * @param scene The scene to load the pipeline to.
  66219. * @param rootUrl The URL of the serialized pipeline.
  66220. * @returns An instantiated pipeline from the serialized object.
  66221. */
  66222. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66223. }
  66224. }
  66225. declare module BABYLON {
  66226. /** @hidden */
  66227. export var lensHighlightsPixelShader: {
  66228. name: string;
  66229. shader: string;
  66230. };
  66231. }
  66232. declare module BABYLON {
  66233. /** @hidden */
  66234. export var depthOfFieldPixelShader: {
  66235. name: string;
  66236. shader: string;
  66237. };
  66238. }
  66239. declare module BABYLON {
  66240. /**
  66241. * BABYLON.JS Chromatic Aberration GLSL Shader
  66242. * Author: Olivier Guyot
  66243. * Separates very slightly R, G and B colors on the edges of the screen
  66244. * Inspired by Francois Tarlier & Martins Upitis
  66245. */
  66246. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66247. /**
  66248. * @ignore
  66249. * The chromatic aberration PostProcess id in the pipeline
  66250. */
  66251. LensChromaticAberrationEffect: string;
  66252. /**
  66253. * @ignore
  66254. * The highlights enhancing PostProcess id in the pipeline
  66255. */
  66256. HighlightsEnhancingEffect: string;
  66257. /**
  66258. * @ignore
  66259. * The depth-of-field PostProcess id in the pipeline
  66260. */
  66261. LensDepthOfFieldEffect: string;
  66262. private _scene;
  66263. private _depthTexture;
  66264. private _grainTexture;
  66265. private _chromaticAberrationPostProcess;
  66266. private _highlightsPostProcess;
  66267. private _depthOfFieldPostProcess;
  66268. private _edgeBlur;
  66269. private _grainAmount;
  66270. private _chromaticAberration;
  66271. private _distortion;
  66272. private _highlightsGain;
  66273. private _highlightsThreshold;
  66274. private _dofDistance;
  66275. private _dofAperture;
  66276. private _dofDarken;
  66277. private _dofPentagon;
  66278. private _blurNoise;
  66279. /**
  66280. * @constructor
  66281. *
  66282. * Effect parameters are as follow:
  66283. * {
  66284. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66285. * edge_blur: number; // from 0 to x (1 for realism)
  66286. * distortion: number; // from 0 to x (1 for realism)
  66287. * grain_amount: number; // from 0 to 1
  66288. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66289. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66290. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66291. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66292. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66293. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66294. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66295. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66296. * }
  66297. * Note: if an effect parameter is unset, effect is disabled
  66298. *
  66299. * @param name The rendering pipeline name
  66300. * @param parameters - An object containing all parameters (see above)
  66301. * @param scene The scene linked to this pipeline
  66302. * @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)
  66303. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66304. */
  66305. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66306. /**
  66307. * Get the class name
  66308. * @returns "LensRenderingPipeline"
  66309. */
  66310. getClassName(): string;
  66311. /**
  66312. * Gets associated scene
  66313. */
  66314. get scene(): Scene;
  66315. /**
  66316. * Gets or sets the edge blur
  66317. */
  66318. get edgeBlur(): number;
  66319. set edgeBlur(value: number);
  66320. /**
  66321. * Gets or sets the grain amount
  66322. */
  66323. get grainAmount(): number;
  66324. set grainAmount(value: number);
  66325. /**
  66326. * Gets or sets the chromatic aberration amount
  66327. */
  66328. get chromaticAberration(): number;
  66329. set chromaticAberration(value: number);
  66330. /**
  66331. * Gets or sets the depth of field aperture
  66332. */
  66333. get dofAperture(): number;
  66334. set dofAperture(value: number);
  66335. /**
  66336. * Gets or sets the edge distortion
  66337. */
  66338. get edgeDistortion(): number;
  66339. set edgeDistortion(value: number);
  66340. /**
  66341. * Gets or sets the depth of field distortion
  66342. */
  66343. get dofDistortion(): number;
  66344. set dofDistortion(value: number);
  66345. /**
  66346. * Gets or sets the darken out of focus amount
  66347. */
  66348. get darkenOutOfFocus(): number;
  66349. set darkenOutOfFocus(value: number);
  66350. /**
  66351. * Gets or sets a boolean indicating if blur noise is enabled
  66352. */
  66353. get blurNoise(): boolean;
  66354. set blurNoise(value: boolean);
  66355. /**
  66356. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66357. */
  66358. get pentagonBokeh(): boolean;
  66359. set pentagonBokeh(value: boolean);
  66360. /**
  66361. * Gets or sets the highlight grain amount
  66362. */
  66363. get highlightsGain(): number;
  66364. set highlightsGain(value: number);
  66365. /**
  66366. * Gets or sets the highlight threshold
  66367. */
  66368. get highlightsThreshold(): number;
  66369. set highlightsThreshold(value: number);
  66370. /**
  66371. * Sets the amount of blur at the edges
  66372. * @param amount blur amount
  66373. */
  66374. setEdgeBlur(amount: number): void;
  66375. /**
  66376. * Sets edge blur to 0
  66377. */
  66378. disableEdgeBlur(): void;
  66379. /**
  66380. * Sets the amout of grain
  66381. * @param amount Amount of grain
  66382. */
  66383. setGrainAmount(amount: number): void;
  66384. /**
  66385. * Set grain amount to 0
  66386. */
  66387. disableGrain(): void;
  66388. /**
  66389. * Sets the chromatic aberration amount
  66390. * @param amount amount of chromatic aberration
  66391. */
  66392. setChromaticAberration(amount: number): void;
  66393. /**
  66394. * Sets chromatic aberration amount to 0
  66395. */
  66396. disableChromaticAberration(): void;
  66397. /**
  66398. * Sets the EdgeDistortion amount
  66399. * @param amount amount of EdgeDistortion
  66400. */
  66401. setEdgeDistortion(amount: number): void;
  66402. /**
  66403. * Sets edge distortion to 0
  66404. */
  66405. disableEdgeDistortion(): void;
  66406. /**
  66407. * Sets the FocusDistance amount
  66408. * @param amount amount of FocusDistance
  66409. */
  66410. setFocusDistance(amount: number): void;
  66411. /**
  66412. * Disables depth of field
  66413. */
  66414. disableDepthOfField(): void;
  66415. /**
  66416. * Sets the Aperture amount
  66417. * @param amount amount of Aperture
  66418. */
  66419. setAperture(amount: number): void;
  66420. /**
  66421. * Sets the DarkenOutOfFocus amount
  66422. * @param amount amount of DarkenOutOfFocus
  66423. */
  66424. setDarkenOutOfFocus(amount: number): void;
  66425. private _pentagonBokehIsEnabled;
  66426. /**
  66427. * Creates a pentagon bokeh effect
  66428. */
  66429. enablePentagonBokeh(): void;
  66430. /**
  66431. * Disables the pentagon bokeh effect
  66432. */
  66433. disablePentagonBokeh(): void;
  66434. /**
  66435. * Enables noise blur
  66436. */
  66437. enableNoiseBlur(): void;
  66438. /**
  66439. * Disables noise blur
  66440. */
  66441. disableNoiseBlur(): void;
  66442. /**
  66443. * Sets the HighlightsGain amount
  66444. * @param amount amount of HighlightsGain
  66445. */
  66446. setHighlightsGain(amount: number): void;
  66447. /**
  66448. * Sets the HighlightsThreshold amount
  66449. * @param amount amount of HighlightsThreshold
  66450. */
  66451. setHighlightsThreshold(amount: number): void;
  66452. /**
  66453. * Disables highlights
  66454. */
  66455. disableHighlights(): void;
  66456. /**
  66457. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66458. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66459. */
  66460. dispose(disableDepthRender?: boolean): void;
  66461. private _createChromaticAberrationPostProcess;
  66462. private _createHighlightsPostProcess;
  66463. private _createDepthOfFieldPostProcess;
  66464. private _createGrainTexture;
  66465. }
  66466. }
  66467. declare module BABYLON {
  66468. /** @hidden */
  66469. export var ssao2PixelShader: {
  66470. name: string;
  66471. shader: string;
  66472. };
  66473. }
  66474. declare module BABYLON {
  66475. /** @hidden */
  66476. export var ssaoCombinePixelShader: {
  66477. name: string;
  66478. shader: string;
  66479. };
  66480. }
  66481. declare module BABYLON {
  66482. /**
  66483. * Render pipeline to produce ssao effect
  66484. */
  66485. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66486. /**
  66487. * @ignore
  66488. * The PassPostProcess id in the pipeline that contains the original scene color
  66489. */
  66490. SSAOOriginalSceneColorEffect: string;
  66491. /**
  66492. * @ignore
  66493. * The SSAO PostProcess id in the pipeline
  66494. */
  66495. SSAORenderEffect: string;
  66496. /**
  66497. * @ignore
  66498. * The horizontal blur PostProcess id in the pipeline
  66499. */
  66500. SSAOBlurHRenderEffect: string;
  66501. /**
  66502. * @ignore
  66503. * The vertical blur PostProcess id in the pipeline
  66504. */
  66505. SSAOBlurVRenderEffect: string;
  66506. /**
  66507. * @ignore
  66508. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66509. */
  66510. SSAOCombineRenderEffect: string;
  66511. /**
  66512. * The output strength of the SSAO post-process. Default value is 1.0.
  66513. */
  66514. totalStrength: number;
  66515. /**
  66516. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66517. */
  66518. maxZ: number;
  66519. /**
  66520. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66521. */
  66522. minZAspect: number;
  66523. private _samples;
  66524. /**
  66525. * Number of samples used for the SSAO calculations. Default value is 8
  66526. */
  66527. set samples(n: number);
  66528. get samples(): number;
  66529. private _textureSamples;
  66530. /**
  66531. * Number of samples to use for antialiasing
  66532. */
  66533. set textureSamples(n: number);
  66534. get textureSamples(): number;
  66535. /**
  66536. * Ratio object used for SSAO ratio and blur ratio
  66537. */
  66538. private _ratio;
  66539. /**
  66540. * Dynamically generated sphere sampler.
  66541. */
  66542. private _sampleSphere;
  66543. /**
  66544. * Blur filter offsets
  66545. */
  66546. private _samplerOffsets;
  66547. private _expensiveBlur;
  66548. /**
  66549. * If bilateral blur should be used
  66550. */
  66551. set expensiveBlur(b: boolean);
  66552. get expensiveBlur(): boolean;
  66553. /**
  66554. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66555. */
  66556. radius: number;
  66557. /**
  66558. * The base color of the SSAO post-process
  66559. * The final result is "base + ssao" between [0, 1]
  66560. */
  66561. base: number;
  66562. /**
  66563. * Support test.
  66564. */
  66565. static get IsSupported(): boolean;
  66566. private _scene;
  66567. private _depthTexture;
  66568. private _normalTexture;
  66569. private _randomTexture;
  66570. private _originalColorPostProcess;
  66571. private _ssaoPostProcess;
  66572. private _blurHPostProcess;
  66573. private _blurVPostProcess;
  66574. private _ssaoCombinePostProcess;
  66575. /**
  66576. * Gets active scene
  66577. */
  66578. get scene(): Scene;
  66579. /**
  66580. * @constructor
  66581. * @param name The rendering pipeline name
  66582. * @param scene The scene linked to this pipeline
  66583. * @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 }
  66584. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66585. */
  66586. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66587. /**
  66588. * Get the class name
  66589. * @returns "SSAO2RenderingPipeline"
  66590. */
  66591. getClassName(): string;
  66592. /**
  66593. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66594. */
  66595. dispose(disableGeometryBufferRenderer?: boolean): void;
  66596. private _createBlurPostProcess;
  66597. /** @hidden */
  66598. _rebuild(): void;
  66599. private _bits;
  66600. private _radicalInverse_VdC;
  66601. private _hammersley;
  66602. private _hemisphereSample_uniform;
  66603. private _generateHemisphere;
  66604. private _createSSAOPostProcess;
  66605. private _createSSAOCombinePostProcess;
  66606. private _createRandomTexture;
  66607. /**
  66608. * Serialize the rendering pipeline (Used when exporting)
  66609. * @returns the serialized object
  66610. */
  66611. serialize(): any;
  66612. /**
  66613. * Parse the serialized pipeline
  66614. * @param source Source pipeline.
  66615. * @param scene The scene to load the pipeline to.
  66616. * @param rootUrl The URL of the serialized pipeline.
  66617. * @returns An instantiated pipeline from the serialized object.
  66618. */
  66619. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66620. }
  66621. }
  66622. declare module BABYLON {
  66623. /** @hidden */
  66624. export var ssaoPixelShader: {
  66625. name: string;
  66626. shader: string;
  66627. };
  66628. }
  66629. declare module BABYLON {
  66630. /**
  66631. * Render pipeline to produce ssao effect
  66632. */
  66633. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66634. /**
  66635. * @ignore
  66636. * The PassPostProcess id in the pipeline that contains the original scene color
  66637. */
  66638. SSAOOriginalSceneColorEffect: string;
  66639. /**
  66640. * @ignore
  66641. * The SSAO PostProcess id in the pipeline
  66642. */
  66643. SSAORenderEffect: string;
  66644. /**
  66645. * @ignore
  66646. * The horizontal blur PostProcess id in the pipeline
  66647. */
  66648. SSAOBlurHRenderEffect: string;
  66649. /**
  66650. * @ignore
  66651. * The vertical blur PostProcess id in the pipeline
  66652. */
  66653. SSAOBlurVRenderEffect: string;
  66654. /**
  66655. * @ignore
  66656. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66657. */
  66658. SSAOCombineRenderEffect: string;
  66659. /**
  66660. * The output strength of the SSAO post-process. Default value is 1.0.
  66661. */
  66662. totalStrength: number;
  66663. /**
  66664. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66665. */
  66666. radius: number;
  66667. /**
  66668. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66669. * Must not be equal to fallOff and superior to fallOff.
  66670. * Default value is 0.0075
  66671. */
  66672. area: number;
  66673. /**
  66674. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66675. * Must not be equal to area and inferior to area.
  66676. * Default value is 0.000001
  66677. */
  66678. fallOff: number;
  66679. /**
  66680. * The base color of the SSAO post-process
  66681. * The final result is "base + ssao" between [0, 1]
  66682. */
  66683. base: number;
  66684. private _scene;
  66685. private _depthTexture;
  66686. private _randomTexture;
  66687. private _originalColorPostProcess;
  66688. private _ssaoPostProcess;
  66689. private _blurHPostProcess;
  66690. private _blurVPostProcess;
  66691. private _ssaoCombinePostProcess;
  66692. private _firstUpdate;
  66693. /**
  66694. * Gets active scene
  66695. */
  66696. get scene(): Scene;
  66697. /**
  66698. * @constructor
  66699. * @param name - The rendering pipeline name
  66700. * @param scene - The scene linked to this pipeline
  66701. * @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 }
  66702. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66703. */
  66704. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66705. /**
  66706. * Get the class name
  66707. * @returns "SSAORenderingPipeline"
  66708. */
  66709. getClassName(): string;
  66710. /**
  66711. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66712. */
  66713. dispose(disableDepthRender?: boolean): void;
  66714. private _createBlurPostProcess;
  66715. /** @hidden */
  66716. _rebuild(): void;
  66717. private _createSSAOPostProcess;
  66718. private _createSSAOCombinePostProcess;
  66719. private _createRandomTexture;
  66720. }
  66721. }
  66722. declare module BABYLON {
  66723. /** @hidden */
  66724. export var screenSpaceReflectionPixelShader: {
  66725. name: string;
  66726. shader: string;
  66727. };
  66728. }
  66729. declare module BABYLON {
  66730. /**
  66731. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66732. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66733. */
  66734. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66735. /**
  66736. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66737. */
  66738. threshold: number;
  66739. /**
  66740. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66741. */
  66742. strength: number;
  66743. /**
  66744. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66745. */
  66746. reflectionSpecularFalloffExponent: number;
  66747. /**
  66748. * 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]
  66749. */
  66750. step: number;
  66751. /**
  66752. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66753. */
  66754. roughnessFactor: number;
  66755. private _geometryBufferRenderer;
  66756. private _enableSmoothReflections;
  66757. private _reflectionSamples;
  66758. private _smoothSteps;
  66759. /**
  66760. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66761. * @param name The name of the effect.
  66762. * @param scene The scene containing the objects to calculate reflections.
  66763. * @param options The required width/height ratio to downsize to before computing the render pass.
  66764. * @param camera The camera to apply the render pass to.
  66765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66766. * @param engine The engine which the post process will be applied. (default: current engine)
  66767. * @param reusable If the post process can be reused on the same frame. (default: false)
  66768. * @param textureType Type of textures used when performing the post process. (default: 0)
  66769. * @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)
  66770. */
  66771. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66772. /**
  66773. * Gets wether or not smoothing reflections is enabled.
  66774. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66775. */
  66776. get enableSmoothReflections(): boolean;
  66777. /**
  66778. * Sets wether or not smoothing reflections is enabled.
  66779. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66780. */
  66781. set enableSmoothReflections(enabled: boolean);
  66782. /**
  66783. * Gets the number of samples taken while computing reflections. More samples count is high,
  66784. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66785. */
  66786. get reflectionSamples(): number;
  66787. /**
  66788. * Sets the number of samples taken while computing reflections. More samples count is high,
  66789. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66790. */
  66791. set reflectionSamples(samples: number);
  66792. /**
  66793. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66794. * more the post-process will require GPU power and can generate a drop in FPS.
  66795. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66796. */
  66797. get smoothSteps(): number;
  66798. set smoothSteps(steps: number);
  66799. private _updateEffectDefines;
  66800. }
  66801. }
  66802. declare module BABYLON {
  66803. /** @hidden */
  66804. export var standardPixelShader: {
  66805. name: string;
  66806. shader: string;
  66807. };
  66808. }
  66809. declare module BABYLON {
  66810. /**
  66811. * Standard rendering pipeline
  66812. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66813. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66814. */
  66815. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66816. /**
  66817. * Public members
  66818. */
  66819. /**
  66820. * Post-process which contains the original scene color before the pipeline applies all the effects
  66821. */
  66822. originalPostProcess: Nullable<PostProcess>;
  66823. /**
  66824. * Post-process used to down scale an image x4
  66825. */
  66826. downSampleX4PostProcess: Nullable<PostProcess>;
  66827. /**
  66828. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66829. */
  66830. brightPassPostProcess: Nullable<PostProcess>;
  66831. /**
  66832. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66833. */
  66834. blurHPostProcesses: PostProcess[];
  66835. /**
  66836. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66837. */
  66838. blurVPostProcesses: PostProcess[];
  66839. /**
  66840. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66841. */
  66842. textureAdderPostProcess: Nullable<PostProcess>;
  66843. /**
  66844. * Post-process used to create volumetric lighting effect
  66845. */
  66846. volumetricLightPostProcess: Nullable<PostProcess>;
  66847. /**
  66848. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66849. */
  66850. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66851. /**
  66852. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66853. */
  66854. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66855. /**
  66856. * Post-process used to merge the volumetric light effect and the real scene color
  66857. */
  66858. volumetricLightMergePostProces: Nullable<PostProcess>;
  66859. /**
  66860. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66861. */
  66862. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66863. /**
  66864. * Base post-process used to calculate the average luminance of the final image for HDR
  66865. */
  66866. luminancePostProcess: Nullable<PostProcess>;
  66867. /**
  66868. * Post-processes used to create down sample post-processes in order to get
  66869. * the average luminance of the final image for HDR
  66870. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66871. */
  66872. luminanceDownSamplePostProcesses: PostProcess[];
  66873. /**
  66874. * Post-process used to create a HDR effect (light adaptation)
  66875. */
  66876. hdrPostProcess: Nullable<PostProcess>;
  66877. /**
  66878. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66879. */
  66880. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66881. /**
  66882. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66883. */
  66884. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66885. /**
  66886. * Post-process used to merge the final HDR post-process and the real scene color
  66887. */
  66888. hdrFinalPostProcess: Nullable<PostProcess>;
  66889. /**
  66890. * Post-process used to create a lens flare effect
  66891. */
  66892. lensFlarePostProcess: Nullable<PostProcess>;
  66893. /**
  66894. * Post-process that merges the result of the lens flare post-process and the real scene color
  66895. */
  66896. lensFlareComposePostProcess: Nullable<PostProcess>;
  66897. /**
  66898. * Post-process used to create a motion blur effect
  66899. */
  66900. motionBlurPostProcess: Nullable<PostProcess>;
  66901. /**
  66902. * Post-process used to create a depth of field effect
  66903. */
  66904. depthOfFieldPostProcess: Nullable<PostProcess>;
  66905. /**
  66906. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66907. */
  66908. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66909. /**
  66910. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66911. */
  66912. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66913. /**
  66914. * Represents the brightness threshold in order to configure the illuminated surfaces
  66915. */
  66916. brightThreshold: number;
  66917. /**
  66918. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66919. */
  66920. blurWidth: number;
  66921. /**
  66922. * Sets if the blur for highlighted surfaces must be only horizontal
  66923. */
  66924. horizontalBlur: boolean;
  66925. /**
  66926. * Gets the overall exposure used by the pipeline
  66927. */
  66928. get exposure(): number;
  66929. /**
  66930. * Sets the overall exposure used by the pipeline
  66931. */
  66932. set exposure(value: number);
  66933. /**
  66934. * Texture used typically to simulate "dirty" on camera lens
  66935. */
  66936. lensTexture: Nullable<Texture>;
  66937. /**
  66938. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66939. */
  66940. volumetricLightCoefficient: number;
  66941. /**
  66942. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66943. */
  66944. volumetricLightPower: number;
  66945. /**
  66946. * Used the set the blur intensity to smooth the volumetric lights
  66947. */
  66948. volumetricLightBlurScale: number;
  66949. /**
  66950. * Light (spot or directional) used to generate the volumetric lights rays
  66951. * The source light must have a shadow generate so the pipeline can get its
  66952. * depth map
  66953. */
  66954. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66955. /**
  66956. * For eye adaptation, represents the minimum luminance the eye can see
  66957. */
  66958. hdrMinimumLuminance: number;
  66959. /**
  66960. * For eye adaptation, represents the decrease luminance speed
  66961. */
  66962. hdrDecreaseRate: number;
  66963. /**
  66964. * For eye adaptation, represents the increase luminance speed
  66965. */
  66966. hdrIncreaseRate: number;
  66967. /**
  66968. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66969. */
  66970. get hdrAutoExposure(): boolean;
  66971. /**
  66972. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66973. */
  66974. set hdrAutoExposure(value: boolean);
  66975. /**
  66976. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66977. */
  66978. lensColorTexture: Nullable<Texture>;
  66979. /**
  66980. * The overall strengh for the lens flare effect
  66981. */
  66982. lensFlareStrength: number;
  66983. /**
  66984. * Dispersion coefficient for lens flare ghosts
  66985. */
  66986. lensFlareGhostDispersal: number;
  66987. /**
  66988. * Main lens flare halo width
  66989. */
  66990. lensFlareHaloWidth: number;
  66991. /**
  66992. * Based on the lens distortion effect, defines how much the lens flare result
  66993. * is distorted
  66994. */
  66995. lensFlareDistortionStrength: number;
  66996. /**
  66997. * Configures the blur intensity used for for lens flare (halo)
  66998. */
  66999. lensFlareBlurWidth: number;
  67000. /**
  67001. * Lens star texture must be used to simulate rays on the flares and is available
  67002. * in the documentation
  67003. */
  67004. lensStarTexture: Nullable<Texture>;
  67005. /**
  67006. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67007. * flare effect by taking account of the dirt texture
  67008. */
  67009. lensFlareDirtTexture: Nullable<Texture>;
  67010. /**
  67011. * Represents the focal length for the depth of field effect
  67012. */
  67013. depthOfFieldDistance: number;
  67014. /**
  67015. * Represents the blur intensity for the blurred part of the depth of field effect
  67016. */
  67017. depthOfFieldBlurWidth: number;
  67018. /**
  67019. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67020. */
  67021. get motionStrength(): number;
  67022. /**
  67023. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67024. */
  67025. set motionStrength(strength: number);
  67026. /**
  67027. * Gets wether or not the motion blur post-process is object based or screen based.
  67028. */
  67029. get objectBasedMotionBlur(): boolean;
  67030. /**
  67031. * Sets wether or not the motion blur post-process should be object based or screen based
  67032. */
  67033. set objectBasedMotionBlur(value: boolean);
  67034. /**
  67035. * List of animations for the pipeline (IAnimatable implementation)
  67036. */
  67037. animations: Animation[];
  67038. /**
  67039. * Private members
  67040. */
  67041. private _scene;
  67042. private _currentDepthOfFieldSource;
  67043. private _basePostProcess;
  67044. private _fixedExposure;
  67045. private _currentExposure;
  67046. private _hdrAutoExposure;
  67047. private _hdrCurrentLuminance;
  67048. private _motionStrength;
  67049. private _isObjectBasedMotionBlur;
  67050. private _floatTextureType;
  67051. private _camerasToBeAttached;
  67052. private _ratio;
  67053. private _bloomEnabled;
  67054. private _depthOfFieldEnabled;
  67055. private _vlsEnabled;
  67056. private _lensFlareEnabled;
  67057. private _hdrEnabled;
  67058. private _motionBlurEnabled;
  67059. private _fxaaEnabled;
  67060. private _screenSpaceReflectionsEnabled;
  67061. private _motionBlurSamples;
  67062. private _volumetricLightStepsCount;
  67063. private _samples;
  67064. /**
  67065. * @ignore
  67066. * Specifies if the bloom pipeline is enabled
  67067. */
  67068. get BloomEnabled(): boolean;
  67069. set BloomEnabled(enabled: boolean);
  67070. /**
  67071. * @ignore
  67072. * Specifies if the depth of field pipeline is enabed
  67073. */
  67074. get DepthOfFieldEnabled(): boolean;
  67075. set DepthOfFieldEnabled(enabled: boolean);
  67076. /**
  67077. * @ignore
  67078. * Specifies if the lens flare pipeline is enabed
  67079. */
  67080. get LensFlareEnabled(): boolean;
  67081. set LensFlareEnabled(enabled: boolean);
  67082. /**
  67083. * @ignore
  67084. * Specifies if the HDR pipeline is enabled
  67085. */
  67086. get HDREnabled(): boolean;
  67087. set HDREnabled(enabled: boolean);
  67088. /**
  67089. * @ignore
  67090. * Specifies if the volumetric lights scattering effect is enabled
  67091. */
  67092. get VLSEnabled(): boolean;
  67093. set VLSEnabled(enabled: boolean);
  67094. /**
  67095. * @ignore
  67096. * Specifies if the motion blur effect is enabled
  67097. */
  67098. get MotionBlurEnabled(): boolean;
  67099. set MotionBlurEnabled(enabled: boolean);
  67100. /**
  67101. * Specifies if anti-aliasing is enabled
  67102. */
  67103. get fxaaEnabled(): boolean;
  67104. set fxaaEnabled(enabled: boolean);
  67105. /**
  67106. * Specifies if screen space reflections are enabled.
  67107. */
  67108. get screenSpaceReflectionsEnabled(): boolean;
  67109. set screenSpaceReflectionsEnabled(enabled: boolean);
  67110. /**
  67111. * Specifies the number of steps used to calculate the volumetric lights
  67112. * Typically in interval [50, 200]
  67113. */
  67114. get volumetricLightStepsCount(): number;
  67115. set volumetricLightStepsCount(count: number);
  67116. /**
  67117. * Specifies the number of samples used for the motion blur effect
  67118. * Typically in interval [16, 64]
  67119. */
  67120. get motionBlurSamples(): number;
  67121. set motionBlurSamples(samples: number);
  67122. /**
  67123. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67124. */
  67125. get samples(): number;
  67126. set samples(sampleCount: number);
  67127. /**
  67128. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67129. * @constructor
  67130. * @param name The rendering pipeline name
  67131. * @param scene The scene linked to this pipeline
  67132. * @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)
  67133. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67134. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67135. */
  67136. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67137. private _buildPipeline;
  67138. private _createDownSampleX4PostProcess;
  67139. private _createBrightPassPostProcess;
  67140. private _createBlurPostProcesses;
  67141. private _createTextureAdderPostProcess;
  67142. private _createVolumetricLightPostProcess;
  67143. private _createLuminancePostProcesses;
  67144. private _createHdrPostProcess;
  67145. private _createLensFlarePostProcess;
  67146. private _createDepthOfFieldPostProcess;
  67147. private _createMotionBlurPostProcess;
  67148. private _getDepthTexture;
  67149. private _disposePostProcesses;
  67150. /**
  67151. * Dispose of the pipeline and stop all post processes
  67152. */
  67153. dispose(): void;
  67154. /**
  67155. * Serialize the rendering pipeline (Used when exporting)
  67156. * @returns the serialized object
  67157. */
  67158. serialize(): any;
  67159. /**
  67160. * Parse the serialized pipeline
  67161. * @param source Source pipeline.
  67162. * @param scene The scene to load the pipeline to.
  67163. * @param rootUrl The URL of the serialized pipeline.
  67164. * @returns An instantiated pipeline from the serialized object.
  67165. */
  67166. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67167. /**
  67168. * Luminance steps
  67169. */
  67170. static LuminanceSteps: number;
  67171. }
  67172. }
  67173. declare module BABYLON {
  67174. /** @hidden */
  67175. export var tonemapPixelShader: {
  67176. name: string;
  67177. shader: string;
  67178. };
  67179. }
  67180. declare module BABYLON {
  67181. /** Defines operator used for tonemapping */
  67182. export enum TonemappingOperator {
  67183. /** Hable */
  67184. Hable = 0,
  67185. /** Reinhard */
  67186. Reinhard = 1,
  67187. /** HejiDawson */
  67188. HejiDawson = 2,
  67189. /** Photographic */
  67190. Photographic = 3
  67191. }
  67192. /**
  67193. * Defines a post process to apply tone mapping
  67194. */
  67195. export class TonemapPostProcess extends PostProcess {
  67196. private _operator;
  67197. /** Defines the required exposure adjustement */
  67198. exposureAdjustment: number;
  67199. /**
  67200. * Creates a new TonemapPostProcess
  67201. * @param name defines the name of the postprocess
  67202. * @param _operator defines the operator to use
  67203. * @param exposureAdjustment defines the required exposure adjustement
  67204. * @param camera defines the camera to use (can be null)
  67205. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67206. * @param engine defines the hosting engine (can be ignore if camera is set)
  67207. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67208. */
  67209. constructor(name: string, _operator: TonemappingOperator,
  67210. /** Defines the required exposure adjustement */
  67211. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67212. }
  67213. }
  67214. declare module BABYLON {
  67215. /** @hidden */
  67216. export var volumetricLightScatteringPixelShader: {
  67217. name: string;
  67218. shader: string;
  67219. };
  67220. }
  67221. declare module BABYLON {
  67222. /** @hidden */
  67223. export var volumetricLightScatteringPassVertexShader: {
  67224. name: string;
  67225. shader: string;
  67226. };
  67227. }
  67228. declare module BABYLON {
  67229. /** @hidden */
  67230. export var volumetricLightScatteringPassPixelShader: {
  67231. name: string;
  67232. shader: string;
  67233. };
  67234. }
  67235. declare module BABYLON {
  67236. /**
  67237. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67238. */
  67239. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67240. private _volumetricLightScatteringPass;
  67241. private _volumetricLightScatteringRTT;
  67242. private _viewPort;
  67243. private _screenCoordinates;
  67244. private _cachedDefines;
  67245. /**
  67246. * If not undefined, the mesh position is computed from the attached node position
  67247. */
  67248. attachedNode: {
  67249. position: Vector3;
  67250. };
  67251. /**
  67252. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67253. */
  67254. customMeshPosition: Vector3;
  67255. /**
  67256. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67257. */
  67258. useCustomMeshPosition: boolean;
  67259. /**
  67260. * If the post-process should inverse the light scattering direction
  67261. */
  67262. invert: boolean;
  67263. /**
  67264. * The internal mesh used by the post-process
  67265. */
  67266. mesh: Mesh;
  67267. /**
  67268. * @hidden
  67269. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67270. */
  67271. get useDiffuseColor(): boolean;
  67272. set useDiffuseColor(useDiffuseColor: boolean);
  67273. /**
  67274. * Array containing the excluded meshes not rendered in the internal pass
  67275. */
  67276. excludedMeshes: AbstractMesh[];
  67277. /**
  67278. * Controls the overall intensity of the post-process
  67279. */
  67280. exposure: number;
  67281. /**
  67282. * Dissipates each sample's contribution in range [0, 1]
  67283. */
  67284. decay: number;
  67285. /**
  67286. * Controls the overall intensity of each sample
  67287. */
  67288. weight: number;
  67289. /**
  67290. * Controls the density of each sample
  67291. */
  67292. density: number;
  67293. /**
  67294. * @constructor
  67295. * @param name The post-process name
  67296. * @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)
  67297. * @param camera The camera that the post-process will be attached to
  67298. * @param mesh The mesh used to create the light scattering
  67299. * @param samples The post-process quality, default 100
  67300. * @param samplingModeThe post-process filtering mode
  67301. * @param engine The babylon engine
  67302. * @param reusable If the post-process is reusable
  67303. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67304. */
  67305. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67306. /**
  67307. * Returns the string "VolumetricLightScatteringPostProcess"
  67308. * @returns "VolumetricLightScatteringPostProcess"
  67309. */
  67310. getClassName(): string;
  67311. private _isReady;
  67312. /**
  67313. * Sets the new light position for light scattering effect
  67314. * @param position The new custom light position
  67315. */
  67316. setCustomMeshPosition(position: Vector3): void;
  67317. /**
  67318. * Returns the light position for light scattering effect
  67319. * @return Vector3 The custom light position
  67320. */
  67321. getCustomMeshPosition(): Vector3;
  67322. /**
  67323. * Disposes the internal assets and detaches the post-process from the camera
  67324. */
  67325. dispose(camera: Camera): void;
  67326. /**
  67327. * Returns the render target texture used by the post-process
  67328. * @return the render target texture used by the post-process
  67329. */
  67330. getPass(): RenderTargetTexture;
  67331. private _meshExcluded;
  67332. private _createPass;
  67333. private _updateMeshScreenCoordinates;
  67334. /**
  67335. * Creates a default mesh for the Volumeric Light Scattering post-process
  67336. * @param name The mesh name
  67337. * @param scene The scene where to create the mesh
  67338. * @return the default mesh
  67339. */
  67340. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67341. }
  67342. }
  67343. declare module BABYLON {
  67344. interface Scene {
  67345. /** @hidden (Backing field) */
  67346. _boundingBoxRenderer: BoundingBoxRenderer;
  67347. /** @hidden (Backing field) */
  67348. _forceShowBoundingBoxes: boolean;
  67349. /**
  67350. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67351. */
  67352. forceShowBoundingBoxes: boolean;
  67353. /**
  67354. * Gets the bounding box renderer associated with the scene
  67355. * @returns a BoundingBoxRenderer
  67356. */
  67357. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67358. }
  67359. interface AbstractMesh {
  67360. /** @hidden (Backing field) */
  67361. _showBoundingBox: boolean;
  67362. /**
  67363. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67364. */
  67365. showBoundingBox: boolean;
  67366. }
  67367. /**
  67368. * Component responsible of rendering the bounding box of the meshes in a scene.
  67369. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67370. */
  67371. export class BoundingBoxRenderer implements ISceneComponent {
  67372. /**
  67373. * The component name helpfull to identify the component in the list of scene components.
  67374. */
  67375. readonly name: string;
  67376. /**
  67377. * The scene the component belongs to.
  67378. */
  67379. scene: Scene;
  67380. /**
  67381. * Color of the bounding box lines placed in front of an object
  67382. */
  67383. frontColor: Color3;
  67384. /**
  67385. * Color of the bounding box lines placed behind an object
  67386. */
  67387. backColor: Color3;
  67388. /**
  67389. * Defines if the renderer should show the back lines or not
  67390. */
  67391. showBackLines: boolean;
  67392. /**
  67393. * @hidden
  67394. */
  67395. renderList: SmartArray<BoundingBox>;
  67396. private _colorShader;
  67397. private _vertexBuffers;
  67398. private _indexBuffer;
  67399. private _fillIndexBuffer;
  67400. private _fillIndexData;
  67401. /**
  67402. * Instantiates a new bounding box renderer in a scene.
  67403. * @param scene the scene the renderer renders in
  67404. */
  67405. constructor(scene: Scene);
  67406. /**
  67407. * Registers the component in a given scene
  67408. */
  67409. register(): void;
  67410. private _evaluateSubMesh;
  67411. private _activeMesh;
  67412. private _prepareRessources;
  67413. private _createIndexBuffer;
  67414. /**
  67415. * Rebuilds the elements related to this component in case of
  67416. * context lost for instance.
  67417. */
  67418. rebuild(): void;
  67419. /**
  67420. * @hidden
  67421. */
  67422. reset(): void;
  67423. /**
  67424. * Render the bounding boxes of a specific rendering group
  67425. * @param renderingGroupId defines the rendering group to render
  67426. */
  67427. render(renderingGroupId: number): void;
  67428. /**
  67429. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67430. * @param mesh Define the mesh to render the occlusion bounding box for
  67431. */
  67432. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67433. /**
  67434. * Dispose and release the resources attached to this renderer.
  67435. */
  67436. dispose(): void;
  67437. }
  67438. }
  67439. declare module BABYLON {
  67440. interface Scene {
  67441. /** @hidden (Backing field) */
  67442. _depthRenderer: {
  67443. [id: string]: DepthRenderer;
  67444. };
  67445. /**
  67446. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67447. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67448. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67449. * @returns the created depth renderer
  67450. */
  67451. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67452. /**
  67453. * Disables a depth renderer for a given camera
  67454. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67455. */
  67456. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67457. }
  67458. /**
  67459. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67460. * in several rendering techniques.
  67461. */
  67462. export class DepthRendererSceneComponent implements ISceneComponent {
  67463. /**
  67464. * The component name helpfull to identify the component in the list of scene components.
  67465. */
  67466. readonly name: string;
  67467. /**
  67468. * The scene the component belongs to.
  67469. */
  67470. scene: Scene;
  67471. /**
  67472. * Creates a new instance of the component for the given scene
  67473. * @param scene Defines the scene to register the component in
  67474. */
  67475. constructor(scene: Scene);
  67476. /**
  67477. * Registers the component in a given scene
  67478. */
  67479. register(): void;
  67480. /**
  67481. * Rebuilds the elements related to this component in case of
  67482. * context lost for instance.
  67483. */
  67484. rebuild(): void;
  67485. /**
  67486. * Disposes the component and the associated ressources
  67487. */
  67488. dispose(): void;
  67489. private _gatherRenderTargets;
  67490. private _gatherActiveCameraRenderTargets;
  67491. }
  67492. }
  67493. declare module BABYLON {
  67494. /** @hidden */
  67495. export var outlinePixelShader: {
  67496. name: string;
  67497. shader: string;
  67498. };
  67499. }
  67500. declare module BABYLON {
  67501. /** @hidden */
  67502. export var outlineVertexShader: {
  67503. name: string;
  67504. shader: string;
  67505. };
  67506. }
  67507. declare module BABYLON {
  67508. interface Scene {
  67509. /** @hidden */
  67510. _outlineRenderer: OutlineRenderer;
  67511. /**
  67512. * Gets the outline renderer associated with the scene
  67513. * @returns a OutlineRenderer
  67514. */
  67515. getOutlineRenderer(): OutlineRenderer;
  67516. }
  67517. interface AbstractMesh {
  67518. /** @hidden (Backing field) */
  67519. _renderOutline: boolean;
  67520. /**
  67521. * Gets or sets a boolean indicating if the outline must be rendered as well
  67522. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67523. */
  67524. renderOutline: boolean;
  67525. /** @hidden (Backing field) */
  67526. _renderOverlay: boolean;
  67527. /**
  67528. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67529. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67530. */
  67531. renderOverlay: boolean;
  67532. }
  67533. /**
  67534. * This class is responsible to draw bothe outline/overlay of meshes.
  67535. * It should not be used directly but through the available method on mesh.
  67536. */
  67537. export class OutlineRenderer implements ISceneComponent {
  67538. /**
  67539. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67540. */
  67541. private static _StencilReference;
  67542. /**
  67543. * The name of the component. Each component must have a unique name.
  67544. */
  67545. name: string;
  67546. /**
  67547. * The scene the component belongs to.
  67548. */
  67549. scene: Scene;
  67550. /**
  67551. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67552. */
  67553. zOffset: number;
  67554. private _engine;
  67555. private _effect;
  67556. private _cachedDefines;
  67557. private _savedDepthWrite;
  67558. /**
  67559. * Instantiates a new outline renderer. (There could be only one per scene).
  67560. * @param scene Defines the scene it belongs to
  67561. */
  67562. constructor(scene: Scene);
  67563. /**
  67564. * Register the component to one instance of a scene.
  67565. */
  67566. register(): void;
  67567. /**
  67568. * Rebuilds the elements related to this component in case of
  67569. * context lost for instance.
  67570. */
  67571. rebuild(): void;
  67572. /**
  67573. * Disposes the component and the associated ressources.
  67574. */
  67575. dispose(): void;
  67576. /**
  67577. * Renders the outline in the canvas.
  67578. * @param subMesh Defines the sumesh to render
  67579. * @param batch Defines the batch of meshes in case of instances
  67580. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67581. */
  67582. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67583. /**
  67584. * Returns whether or not the outline renderer is ready for a given submesh.
  67585. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67586. * @param subMesh Defines the submesh to check readyness for
  67587. * @param useInstances Defines wheter wee are trying to render instances or not
  67588. * @returns true if ready otherwise false
  67589. */
  67590. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67591. private _beforeRenderingMesh;
  67592. private _afterRenderingMesh;
  67593. }
  67594. }
  67595. declare module BABYLON {
  67596. /**
  67597. * Defines the basic options interface of a Sprite Frame Source Size.
  67598. */
  67599. export interface ISpriteJSONSpriteSourceSize {
  67600. /**
  67601. * number of the original width of the Frame
  67602. */
  67603. w: number;
  67604. /**
  67605. * number of the original height of the Frame
  67606. */
  67607. h: number;
  67608. }
  67609. /**
  67610. * Defines the basic options interface of a Sprite Frame Data.
  67611. */
  67612. export interface ISpriteJSONSpriteFrameData {
  67613. /**
  67614. * number of the x offset of the Frame
  67615. */
  67616. x: number;
  67617. /**
  67618. * number of the y offset of the Frame
  67619. */
  67620. y: number;
  67621. /**
  67622. * number of the width of the Frame
  67623. */
  67624. w: number;
  67625. /**
  67626. * number of the height of the Frame
  67627. */
  67628. h: number;
  67629. }
  67630. /**
  67631. * Defines the basic options interface of a JSON Sprite.
  67632. */
  67633. export interface ISpriteJSONSprite {
  67634. /**
  67635. * string name of the Frame
  67636. */
  67637. filename: string;
  67638. /**
  67639. * ISpriteJSONSpriteFrame basic object of the frame data
  67640. */
  67641. frame: ISpriteJSONSpriteFrameData;
  67642. /**
  67643. * boolean to flag is the frame was rotated.
  67644. */
  67645. rotated: boolean;
  67646. /**
  67647. * boolean to flag is the frame was trimmed.
  67648. */
  67649. trimmed: boolean;
  67650. /**
  67651. * ISpriteJSONSpriteFrame basic object of the source data
  67652. */
  67653. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67654. /**
  67655. * ISpriteJSONSpriteFrame basic object of the source data
  67656. */
  67657. sourceSize: ISpriteJSONSpriteSourceSize;
  67658. }
  67659. /**
  67660. * Defines the basic options interface of a JSON atlas.
  67661. */
  67662. export interface ISpriteJSONAtlas {
  67663. /**
  67664. * Array of objects that contain the frame data.
  67665. */
  67666. frames: Array<ISpriteJSONSprite>;
  67667. /**
  67668. * object basic object containing the sprite meta data.
  67669. */
  67670. meta?: object;
  67671. }
  67672. }
  67673. declare module BABYLON {
  67674. /** @hidden */
  67675. export var spriteMapPixelShader: {
  67676. name: string;
  67677. shader: string;
  67678. };
  67679. }
  67680. declare module BABYLON {
  67681. /** @hidden */
  67682. export var spriteMapVertexShader: {
  67683. name: string;
  67684. shader: string;
  67685. };
  67686. }
  67687. declare module BABYLON {
  67688. /**
  67689. * Defines the basic options interface of a SpriteMap
  67690. */
  67691. export interface ISpriteMapOptions {
  67692. /**
  67693. * Vector2 of the number of cells in the grid.
  67694. */
  67695. stageSize?: Vector2;
  67696. /**
  67697. * Vector2 of the size of the output plane in World Units.
  67698. */
  67699. outputSize?: Vector2;
  67700. /**
  67701. * Vector3 of the position of the output plane in World Units.
  67702. */
  67703. outputPosition?: Vector3;
  67704. /**
  67705. * Vector3 of the rotation of the output plane.
  67706. */
  67707. outputRotation?: Vector3;
  67708. /**
  67709. * number of layers that the system will reserve in resources.
  67710. */
  67711. layerCount?: number;
  67712. /**
  67713. * number of max animation frames a single cell will reserve in resources.
  67714. */
  67715. maxAnimationFrames?: number;
  67716. /**
  67717. * number cell index of the base tile when the system compiles.
  67718. */
  67719. baseTile?: number;
  67720. /**
  67721. * boolean flip the sprite after its been repositioned by the framing data.
  67722. */
  67723. flipU?: boolean;
  67724. /**
  67725. * Vector3 scalar of the global RGB values of the SpriteMap.
  67726. */
  67727. colorMultiply?: Vector3;
  67728. }
  67729. /**
  67730. * Defines the IDisposable interface in order to be cleanable from resources.
  67731. */
  67732. export interface ISpriteMap extends IDisposable {
  67733. /**
  67734. * String name of the SpriteMap.
  67735. */
  67736. name: string;
  67737. /**
  67738. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67739. */
  67740. atlasJSON: ISpriteJSONAtlas;
  67741. /**
  67742. * Texture of the SpriteMap.
  67743. */
  67744. spriteSheet: Texture;
  67745. /**
  67746. * The parameters to initialize the SpriteMap with.
  67747. */
  67748. options: ISpriteMapOptions;
  67749. }
  67750. /**
  67751. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67752. */
  67753. export class SpriteMap implements ISpriteMap {
  67754. /** The Name of the spriteMap */
  67755. name: string;
  67756. /** The JSON file with the frame and meta data */
  67757. atlasJSON: ISpriteJSONAtlas;
  67758. /** The systems Sprite Sheet Texture */
  67759. spriteSheet: Texture;
  67760. /** Arguments passed with the Constructor */
  67761. options: ISpriteMapOptions;
  67762. /** Public Sprite Storage array, parsed from atlasJSON */
  67763. sprites: Array<ISpriteJSONSprite>;
  67764. /** Returns the Number of Sprites in the System */
  67765. get spriteCount(): number;
  67766. /** Returns the Position of Output Plane*/
  67767. get position(): Vector3;
  67768. /** Returns the Position of Output Plane*/
  67769. set position(v: Vector3);
  67770. /** Returns the Rotation of Output Plane*/
  67771. get rotation(): Vector3;
  67772. /** Returns the Rotation of Output Plane*/
  67773. set rotation(v: Vector3);
  67774. /** Sets the AnimationMap*/
  67775. get animationMap(): RawTexture;
  67776. /** Sets the AnimationMap*/
  67777. set animationMap(v: RawTexture);
  67778. /** Scene that the SpriteMap was created in */
  67779. private _scene;
  67780. /** Texture Buffer of Float32 that holds tile frame data*/
  67781. private _frameMap;
  67782. /** Texture Buffers of Float32 that holds tileMap data*/
  67783. private _tileMaps;
  67784. /** Texture Buffer of Float32 that holds Animation Data*/
  67785. private _animationMap;
  67786. /** Custom ShaderMaterial Central to the System*/
  67787. private _material;
  67788. /** Custom ShaderMaterial Central to the System*/
  67789. private _output;
  67790. /** Systems Time Ticker*/
  67791. private _time;
  67792. /**
  67793. * Creates a new SpriteMap
  67794. * @param name defines the SpriteMaps Name
  67795. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67796. * @param spriteSheet is the Texture that the Sprites are on.
  67797. * @param options a basic deployment configuration
  67798. * @param scene The Scene that the map is deployed on
  67799. */
  67800. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67801. /**
  67802. * Returns tileID location
  67803. * @returns Vector2 the cell position ID
  67804. */
  67805. getTileID(): Vector2;
  67806. /**
  67807. * Gets the UV location of the mouse over the SpriteMap.
  67808. * @returns Vector2 the UV position of the mouse interaction
  67809. */
  67810. getMousePosition(): Vector2;
  67811. /**
  67812. * Creates the "frame" texture Buffer
  67813. * -------------------------------------
  67814. * Structure of frames
  67815. * "filename": "Falling-Water-2.png",
  67816. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67817. * "rotated": true,
  67818. * "trimmed": true,
  67819. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67820. * "sourceSize": {"w":32,"h":32}
  67821. * @returns RawTexture of the frameMap
  67822. */
  67823. private _createFrameBuffer;
  67824. /**
  67825. * Creates the tileMap texture Buffer
  67826. * @param buffer normally and array of numbers, or a false to generate from scratch
  67827. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67828. * @returns RawTexture of the tileMap
  67829. */
  67830. private _createTileBuffer;
  67831. /**
  67832. * Modifies the data of the tileMaps
  67833. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67834. * @param pos is the iVector2 Coordinates of the Tile
  67835. * @param tile The SpriteIndex of the new Tile
  67836. */
  67837. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67838. /**
  67839. * Creates the animationMap texture Buffer
  67840. * @param buffer normally and array of numbers, or a false to generate from scratch
  67841. * @returns RawTexture of the animationMap
  67842. */
  67843. private _createTileAnimationBuffer;
  67844. /**
  67845. * Modifies the data of the animationMap
  67846. * @param cellID is the Index of the Sprite
  67847. * @param _frame is the target Animation frame
  67848. * @param toCell is the Target Index of the next frame of the animation
  67849. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67850. * @param speed is a global scalar of the time variable on the map.
  67851. */
  67852. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67853. /**
  67854. * Exports the .tilemaps file
  67855. */
  67856. saveTileMaps(): void;
  67857. /**
  67858. * Imports the .tilemaps file
  67859. * @param url of the .tilemaps file
  67860. */
  67861. loadTileMaps(url: string): void;
  67862. /**
  67863. * Release associated resources
  67864. */
  67865. dispose(): void;
  67866. }
  67867. }
  67868. declare module BABYLON {
  67869. /**
  67870. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67871. * @see http://doc.babylonjs.com/babylon101/sprites
  67872. */
  67873. export class SpritePackedManager extends SpriteManager {
  67874. /** defines the packed manager's name */
  67875. name: string;
  67876. /**
  67877. * Creates a new sprite manager from a packed sprite sheet
  67878. * @param name defines the manager's name
  67879. * @param imgUrl defines the sprite sheet url
  67880. * @param capacity defines the maximum allowed number of sprites
  67881. * @param scene defines the hosting scene
  67882. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67883. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67884. * @param samplingMode defines the smapling mode to use with spritesheet
  67885. * @param fromPacked set to true; do not alter
  67886. */
  67887. constructor(
  67888. /** defines the packed manager's name */
  67889. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67890. }
  67891. }
  67892. declare module BABYLON {
  67893. /**
  67894. * Defines the list of states available for a task inside a AssetsManager
  67895. */
  67896. export enum AssetTaskState {
  67897. /**
  67898. * Initialization
  67899. */
  67900. INIT = 0,
  67901. /**
  67902. * Running
  67903. */
  67904. RUNNING = 1,
  67905. /**
  67906. * Done
  67907. */
  67908. DONE = 2,
  67909. /**
  67910. * Error
  67911. */
  67912. ERROR = 3
  67913. }
  67914. /**
  67915. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67916. */
  67917. export abstract class AbstractAssetTask {
  67918. /**
  67919. * Task name
  67920. */ name: string;
  67921. /**
  67922. * Callback called when the task is successful
  67923. */
  67924. onSuccess: (task: any) => void;
  67925. /**
  67926. * Callback called when the task is not successful
  67927. */
  67928. onError: (task: any, message?: string, exception?: any) => void;
  67929. /**
  67930. * Creates a new AssetsManager
  67931. * @param name defines the name of the task
  67932. */
  67933. constructor(
  67934. /**
  67935. * Task name
  67936. */ name: string);
  67937. private _isCompleted;
  67938. private _taskState;
  67939. private _errorObject;
  67940. /**
  67941. * Get if the task is completed
  67942. */
  67943. get isCompleted(): boolean;
  67944. /**
  67945. * Gets the current state of the task
  67946. */
  67947. get taskState(): AssetTaskState;
  67948. /**
  67949. * Gets the current error object (if task is in error)
  67950. */
  67951. get errorObject(): {
  67952. message?: string;
  67953. exception?: any;
  67954. };
  67955. /**
  67956. * Internal only
  67957. * @hidden
  67958. */
  67959. _setErrorObject(message?: string, exception?: any): void;
  67960. /**
  67961. * Execute the current task
  67962. * @param scene defines the scene where you want your assets to be loaded
  67963. * @param onSuccess is a callback called when the task is successfully executed
  67964. * @param onError is a callback called if an error occurs
  67965. */
  67966. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67967. /**
  67968. * Execute the current task
  67969. * @param scene defines the scene where you want your assets to be loaded
  67970. * @param onSuccess is a callback called when the task is successfully executed
  67971. * @param onError is a callback called if an error occurs
  67972. */
  67973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67974. /**
  67975. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67976. * This can be used with failed tasks that have the reason for failure fixed.
  67977. */
  67978. reset(): void;
  67979. private onErrorCallback;
  67980. private onDoneCallback;
  67981. }
  67982. /**
  67983. * Define the interface used by progress events raised during assets loading
  67984. */
  67985. export interface IAssetsProgressEvent {
  67986. /**
  67987. * Defines the number of remaining tasks to process
  67988. */
  67989. remainingCount: number;
  67990. /**
  67991. * Defines the total number of tasks
  67992. */
  67993. totalCount: number;
  67994. /**
  67995. * Defines the task that was just processed
  67996. */
  67997. task: AbstractAssetTask;
  67998. }
  67999. /**
  68000. * Class used to share progress information about assets loading
  68001. */
  68002. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68003. /**
  68004. * Defines the number of remaining tasks to process
  68005. */
  68006. remainingCount: number;
  68007. /**
  68008. * Defines the total number of tasks
  68009. */
  68010. totalCount: number;
  68011. /**
  68012. * Defines the task that was just processed
  68013. */
  68014. task: AbstractAssetTask;
  68015. /**
  68016. * Creates a AssetsProgressEvent
  68017. * @param remainingCount defines the number of remaining tasks to process
  68018. * @param totalCount defines the total number of tasks
  68019. * @param task defines the task that was just processed
  68020. */
  68021. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68022. }
  68023. /**
  68024. * Define a task used by AssetsManager to load meshes
  68025. */
  68026. export class MeshAssetTask extends AbstractAssetTask {
  68027. /**
  68028. * Defines the name of the task
  68029. */
  68030. name: string;
  68031. /**
  68032. * Defines the list of mesh's names you want to load
  68033. */
  68034. meshesNames: any;
  68035. /**
  68036. * Defines the root url to use as a base to load your meshes and associated resources
  68037. */
  68038. rootUrl: string;
  68039. /**
  68040. * Defines the filename of the scene to load from
  68041. */
  68042. sceneFilename: string;
  68043. /**
  68044. * Gets the list of loaded meshes
  68045. */
  68046. loadedMeshes: Array<AbstractMesh>;
  68047. /**
  68048. * Gets the list of loaded particle systems
  68049. */
  68050. loadedParticleSystems: Array<IParticleSystem>;
  68051. /**
  68052. * Gets the list of loaded skeletons
  68053. */
  68054. loadedSkeletons: Array<Skeleton>;
  68055. /**
  68056. * Gets the list of loaded animation groups
  68057. */
  68058. loadedAnimationGroups: Array<AnimationGroup>;
  68059. /**
  68060. * Callback called when the task is successful
  68061. */
  68062. onSuccess: (task: MeshAssetTask) => void;
  68063. /**
  68064. * Callback called when the task is successful
  68065. */
  68066. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68067. /**
  68068. * Creates a new MeshAssetTask
  68069. * @param name defines the name of the task
  68070. * @param meshesNames defines the list of mesh's names you want to load
  68071. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68072. * @param sceneFilename defines the filename of the scene to load from
  68073. */
  68074. constructor(
  68075. /**
  68076. * Defines the name of the task
  68077. */
  68078. name: string,
  68079. /**
  68080. * Defines the list of mesh's names you want to load
  68081. */
  68082. meshesNames: any,
  68083. /**
  68084. * Defines the root url to use as a base to load your meshes and associated resources
  68085. */
  68086. rootUrl: string,
  68087. /**
  68088. * Defines the filename of the scene to load from
  68089. */
  68090. sceneFilename: string);
  68091. /**
  68092. * Execute the current task
  68093. * @param scene defines the scene where you want your assets to be loaded
  68094. * @param onSuccess is a callback called when the task is successfully executed
  68095. * @param onError is a callback called if an error occurs
  68096. */
  68097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68098. }
  68099. /**
  68100. * Define a task used by AssetsManager to load text content
  68101. */
  68102. export class TextFileAssetTask extends AbstractAssetTask {
  68103. /**
  68104. * Defines the name of the task
  68105. */
  68106. name: string;
  68107. /**
  68108. * Defines the location of the file to load
  68109. */
  68110. url: string;
  68111. /**
  68112. * Gets the loaded text string
  68113. */
  68114. text: string;
  68115. /**
  68116. * Callback called when the task is successful
  68117. */
  68118. onSuccess: (task: TextFileAssetTask) => void;
  68119. /**
  68120. * Callback called when the task is successful
  68121. */
  68122. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68123. /**
  68124. * Creates a new TextFileAssetTask object
  68125. * @param name defines the name of the task
  68126. * @param url defines the location of the file to load
  68127. */
  68128. constructor(
  68129. /**
  68130. * Defines the name of the task
  68131. */
  68132. name: string,
  68133. /**
  68134. * Defines the location of the file to load
  68135. */
  68136. url: string);
  68137. /**
  68138. * Execute the current task
  68139. * @param scene defines the scene where you want your assets to be loaded
  68140. * @param onSuccess is a callback called when the task is successfully executed
  68141. * @param onError is a callback called if an error occurs
  68142. */
  68143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68144. }
  68145. /**
  68146. * Define a task used by AssetsManager to load binary data
  68147. */
  68148. export class BinaryFileAssetTask extends AbstractAssetTask {
  68149. /**
  68150. * Defines the name of the task
  68151. */
  68152. name: string;
  68153. /**
  68154. * Defines the location of the file to load
  68155. */
  68156. url: string;
  68157. /**
  68158. * Gets the lodaded data (as an array buffer)
  68159. */
  68160. data: ArrayBuffer;
  68161. /**
  68162. * Callback called when the task is successful
  68163. */
  68164. onSuccess: (task: BinaryFileAssetTask) => void;
  68165. /**
  68166. * Callback called when the task is successful
  68167. */
  68168. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68169. /**
  68170. * Creates a new BinaryFileAssetTask object
  68171. * @param name defines the name of the new task
  68172. * @param url defines the location of the file to load
  68173. */
  68174. constructor(
  68175. /**
  68176. * Defines the name of the task
  68177. */
  68178. name: string,
  68179. /**
  68180. * Defines the location of the file to load
  68181. */
  68182. url: string);
  68183. /**
  68184. * Execute the current task
  68185. * @param scene defines the scene where you want your assets to be loaded
  68186. * @param onSuccess is a callback called when the task is successfully executed
  68187. * @param onError is a callback called if an error occurs
  68188. */
  68189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68190. }
  68191. /**
  68192. * Define a task used by AssetsManager to load images
  68193. */
  68194. export class ImageAssetTask extends AbstractAssetTask {
  68195. /**
  68196. * Defines the name of the task
  68197. */
  68198. name: string;
  68199. /**
  68200. * Defines the location of the image to load
  68201. */
  68202. url: string;
  68203. /**
  68204. * Gets the loaded images
  68205. */
  68206. image: HTMLImageElement;
  68207. /**
  68208. * Callback called when the task is successful
  68209. */
  68210. onSuccess: (task: ImageAssetTask) => void;
  68211. /**
  68212. * Callback called when the task is successful
  68213. */
  68214. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68215. /**
  68216. * Creates a new ImageAssetTask
  68217. * @param name defines the name of the task
  68218. * @param url defines the location of the image to load
  68219. */
  68220. constructor(
  68221. /**
  68222. * Defines the name of the task
  68223. */
  68224. name: string,
  68225. /**
  68226. * Defines the location of the image to load
  68227. */
  68228. url: string);
  68229. /**
  68230. * Execute the current task
  68231. * @param scene defines the scene where you want your assets to be loaded
  68232. * @param onSuccess is a callback called when the task is successfully executed
  68233. * @param onError is a callback called if an error occurs
  68234. */
  68235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68236. }
  68237. /**
  68238. * Defines the interface used by texture loading tasks
  68239. */
  68240. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68241. /**
  68242. * Gets the loaded texture
  68243. */
  68244. texture: TEX;
  68245. }
  68246. /**
  68247. * Define a task used by AssetsManager to load 2D textures
  68248. */
  68249. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68250. /**
  68251. * Defines the name of the task
  68252. */
  68253. name: string;
  68254. /**
  68255. * Defines the location of the file to load
  68256. */
  68257. url: string;
  68258. /**
  68259. * Defines if mipmap should not be generated (default is false)
  68260. */
  68261. noMipmap?: boolean | undefined;
  68262. /**
  68263. * Defines if texture must be inverted on Y axis (default is true)
  68264. */
  68265. invertY: boolean;
  68266. /**
  68267. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68268. */
  68269. samplingMode: number;
  68270. /**
  68271. * Gets the loaded texture
  68272. */
  68273. texture: Texture;
  68274. /**
  68275. * Callback called when the task is successful
  68276. */
  68277. onSuccess: (task: TextureAssetTask) => void;
  68278. /**
  68279. * Callback called when the task is successful
  68280. */
  68281. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68282. /**
  68283. * Creates a new TextureAssetTask object
  68284. * @param name defines the name of the task
  68285. * @param url defines the location of the file to load
  68286. * @param noMipmap defines if mipmap should not be generated (default is false)
  68287. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68288. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68289. */
  68290. constructor(
  68291. /**
  68292. * Defines the name of the task
  68293. */
  68294. name: string,
  68295. /**
  68296. * Defines the location of the file to load
  68297. */
  68298. url: string,
  68299. /**
  68300. * Defines if mipmap should not be generated (default is false)
  68301. */
  68302. noMipmap?: boolean | undefined,
  68303. /**
  68304. * Defines if texture must be inverted on Y axis (default is true)
  68305. */
  68306. invertY?: boolean,
  68307. /**
  68308. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68309. */
  68310. samplingMode?: number);
  68311. /**
  68312. * Execute the current task
  68313. * @param scene defines the scene where you want your assets to be loaded
  68314. * @param onSuccess is a callback called when the task is successfully executed
  68315. * @param onError is a callback called if an error occurs
  68316. */
  68317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68318. }
  68319. /**
  68320. * Define a task used by AssetsManager to load cube textures
  68321. */
  68322. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68323. /**
  68324. * Defines the name of the task
  68325. */
  68326. name: string;
  68327. /**
  68328. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68329. */
  68330. url: string;
  68331. /**
  68332. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68333. */
  68334. extensions?: string[] | undefined;
  68335. /**
  68336. * Defines if mipmaps should not be generated (default is false)
  68337. */
  68338. noMipmap?: boolean | undefined;
  68339. /**
  68340. * Defines the explicit list of files (undefined by default)
  68341. */
  68342. files?: string[] | undefined;
  68343. /**
  68344. * Gets the loaded texture
  68345. */
  68346. texture: CubeTexture;
  68347. /**
  68348. * Callback called when the task is successful
  68349. */
  68350. onSuccess: (task: CubeTextureAssetTask) => void;
  68351. /**
  68352. * Callback called when the task is successful
  68353. */
  68354. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68355. /**
  68356. * Creates a new CubeTextureAssetTask
  68357. * @param name defines the name of the task
  68358. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68359. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68360. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68361. * @param files defines the explicit list of files (undefined by default)
  68362. */
  68363. constructor(
  68364. /**
  68365. * Defines the name of the task
  68366. */
  68367. name: string,
  68368. /**
  68369. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68370. */
  68371. url: string,
  68372. /**
  68373. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68374. */
  68375. extensions?: string[] | undefined,
  68376. /**
  68377. * Defines if mipmaps should not be generated (default is false)
  68378. */
  68379. noMipmap?: boolean | undefined,
  68380. /**
  68381. * Defines the explicit list of files (undefined by default)
  68382. */
  68383. files?: string[] | undefined);
  68384. /**
  68385. * Execute the current task
  68386. * @param scene defines the scene where you want your assets to be loaded
  68387. * @param onSuccess is a callback called when the task is successfully executed
  68388. * @param onError is a callback called if an error occurs
  68389. */
  68390. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68391. }
  68392. /**
  68393. * Define a task used by AssetsManager to load HDR cube textures
  68394. */
  68395. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68396. /**
  68397. * Defines the name of the task
  68398. */
  68399. name: string;
  68400. /**
  68401. * Defines the location of the file to load
  68402. */
  68403. url: string;
  68404. /**
  68405. * Defines the desired size (the more it increases the longer the generation will be)
  68406. */
  68407. size: number;
  68408. /**
  68409. * Defines if mipmaps should not be generated (default is false)
  68410. */
  68411. noMipmap: boolean;
  68412. /**
  68413. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68414. */
  68415. generateHarmonics: boolean;
  68416. /**
  68417. * 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)
  68418. */
  68419. gammaSpace: boolean;
  68420. /**
  68421. * Internal Use Only
  68422. */
  68423. reserved: boolean;
  68424. /**
  68425. * Gets the loaded texture
  68426. */
  68427. texture: HDRCubeTexture;
  68428. /**
  68429. * Callback called when the task is successful
  68430. */
  68431. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68432. /**
  68433. * Callback called when the task is successful
  68434. */
  68435. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68436. /**
  68437. * Creates a new HDRCubeTextureAssetTask object
  68438. * @param name defines the name of the task
  68439. * @param url defines the location of the file to load
  68440. * @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.
  68441. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68442. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68443. * @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)
  68444. * @param reserved Internal use only
  68445. */
  68446. constructor(
  68447. /**
  68448. * Defines the name of the task
  68449. */
  68450. name: string,
  68451. /**
  68452. * Defines the location of the file to load
  68453. */
  68454. url: string,
  68455. /**
  68456. * Defines the desired size (the more it increases the longer the generation will be)
  68457. */
  68458. size: number,
  68459. /**
  68460. * Defines if mipmaps should not be generated (default is false)
  68461. */
  68462. noMipmap?: boolean,
  68463. /**
  68464. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68465. */
  68466. generateHarmonics?: boolean,
  68467. /**
  68468. * 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)
  68469. */
  68470. gammaSpace?: boolean,
  68471. /**
  68472. * Internal Use Only
  68473. */
  68474. reserved?: boolean);
  68475. /**
  68476. * Execute the current task
  68477. * @param scene defines the scene where you want your assets to be loaded
  68478. * @param onSuccess is a callback called when the task is successfully executed
  68479. * @param onError is a callback called if an error occurs
  68480. */
  68481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68482. }
  68483. /**
  68484. * Define a task used by AssetsManager to load Equirectangular cube textures
  68485. */
  68486. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68487. /**
  68488. * Defines the name of the task
  68489. */
  68490. name: string;
  68491. /**
  68492. * Defines the location of the file to load
  68493. */
  68494. url: string;
  68495. /**
  68496. * Defines the desired size (the more it increases the longer the generation will be)
  68497. */
  68498. size: number;
  68499. /**
  68500. * Defines if mipmaps should not be generated (default is false)
  68501. */
  68502. noMipmap: boolean;
  68503. /**
  68504. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68505. * but the standard material would require them in Gamma space) (default is true)
  68506. */
  68507. gammaSpace: boolean;
  68508. /**
  68509. * Gets the loaded texture
  68510. */
  68511. texture: EquiRectangularCubeTexture;
  68512. /**
  68513. * Callback called when the task is successful
  68514. */
  68515. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68516. /**
  68517. * Callback called when the task is successful
  68518. */
  68519. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68520. /**
  68521. * Creates a new EquiRectangularCubeTextureAssetTask object
  68522. * @param name defines the name of the task
  68523. * @param url defines the location of the file to load
  68524. * @param size defines the desired size (the more it increases the longer the generation will be)
  68525. * If the size is omitted this implies you are using a preprocessed cubemap.
  68526. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68527. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68528. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68529. * (default is true)
  68530. */
  68531. constructor(
  68532. /**
  68533. * Defines the name of the task
  68534. */
  68535. name: string,
  68536. /**
  68537. * Defines the location of the file to load
  68538. */
  68539. url: string,
  68540. /**
  68541. * Defines the desired size (the more it increases the longer the generation will be)
  68542. */
  68543. size: number,
  68544. /**
  68545. * Defines if mipmaps should not be generated (default is false)
  68546. */
  68547. noMipmap?: boolean,
  68548. /**
  68549. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68550. * but the standard material would require them in Gamma space) (default is true)
  68551. */
  68552. gammaSpace?: boolean);
  68553. /**
  68554. * Execute the current task
  68555. * @param scene defines the scene where you want your assets to be loaded
  68556. * @param onSuccess is a callback called when the task is successfully executed
  68557. * @param onError is a callback called if an error occurs
  68558. */
  68559. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68560. }
  68561. /**
  68562. * This class can be used to easily import assets into a scene
  68563. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68564. */
  68565. export class AssetsManager {
  68566. private _scene;
  68567. private _isLoading;
  68568. protected _tasks: AbstractAssetTask[];
  68569. protected _waitingTasksCount: number;
  68570. protected _totalTasksCount: number;
  68571. /**
  68572. * Callback called when all tasks are processed
  68573. */
  68574. onFinish: (tasks: AbstractAssetTask[]) => void;
  68575. /**
  68576. * Callback called when a task is successful
  68577. */
  68578. onTaskSuccess: (task: AbstractAssetTask) => void;
  68579. /**
  68580. * Callback called when a task had an error
  68581. */
  68582. onTaskError: (task: AbstractAssetTask) => void;
  68583. /**
  68584. * Callback called when a task is done (whatever the result is)
  68585. */
  68586. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68587. /**
  68588. * Observable called when all tasks are processed
  68589. */
  68590. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68591. /**
  68592. * Observable called when a task had an error
  68593. */
  68594. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68595. /**
  68596. * Observable called when all tasks were executed
  68597. */
  68598. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68599. /**
  68600. * Observable called when a task is done (whatever the result is)
  68601. */
  68602. onProgressObservable: Observable<IAssetsProgressEvent>;
  68603. /**
  68604. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68605. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68606. */
  68607. useDefaultLoadingScreen: boolean;
  68608. /**
  68609. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68610. * when all assets have been downloaded.
  68611. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68612. */
  68613. autoHideLoadingUI: boolean;
  68614. /**
  68615. * Creates a new AssetsManager
  68616. * @param scene defines the scene to work on
  68617. */
  68618. constructor(scene: Scene);
  68619. /**
  68620. * Add a MeshAssetTask to the list of active tasks
  68621. * @param taskName defines the name of the new task
  68622. * @param meshesNames defines the name of meshes to load
  68623. * @param rootUrl defines the root url to use to locate files
  68624. * @param sceneFilename defines the filename of the scene file
  68625. * @returns a new MeshAssetTask object
  68626. */
  68627. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68628. /**
  68629. * Add a TextFileAssetTask to the list of active tasks
  68630. * @param taskName defines the name of the new task
  68631. * @param url defines the url of the file to load
  68632. * @returns a new TextFileAssetTask object
  68633. */
  68634. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68635. /**
  68636. * Add a BinaryFileAssetTask to the list of active tasks
  68637. * @param taskName defines the name of the new task
  68638. * @param url defines the url of the file to load
  68639. * @returns a new BinaryFileAssetTask object
  68640. */
  68641. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68642. /**
  68643. * Add a ImageAssetTask to the list of active tasks
  68644. * @param taskName defines the name of the new task
  68645. * @param url defines the url of the file to load
  68646. * @returns a new ImageAssetTask object
  68647. */
  68648. addImageTask(taskName: string, url: string): ImageAssetTask;
  68649. /**
  68650. * Add a TextureAssetTask to the list of active tasks
  68651. * @param taskName defines the name of the new task
  68652. * @param url defines the url of the file to load
  68653. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68654. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68655. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68656. * @returns a new TextureAssetTask object
  68657. */
  68658. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68659. /**
  68660. * Add a CubeTextureAssetTask to the list of active tasks
  68661. * @param taskName defines the name of the new task
  68662. * @param url defines the url of the file to load
  68663. * @param extensions defines the extension to use to load the cube map (can be null)
  68664. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68665. * @param files defines the list of files to load (can be null)
  68666. * @returns a new CubeTextureAssetTask object
  68667. */
  68668. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68669. /**
  68670. *
  68671. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68672. * @param taskName defines the name of the new task
  68673. * @param url defines the url of the file to load
  68674. * @param size defines the size you want for the cubemap (can be null)
  68675. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68676. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68677. * @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)
  68678. * @param reserved Internal use only
  68679. * @returns a new HDRCubeTextureAssetTask object
  68680. */
  68681. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68682. /**
  68683. *
  68684. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68685. * @param taskName defines the name of the new task
  68686. * @param url defines the url of the file to load
  68687. * @param size defines the size you want for the cubemap (can be null)
  68688. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68689. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68690. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68691. * @returns a new EquiRectangularCubeTextureAssetTask object
  68692. */
  68693. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68694. /**
  68695. * Remove a task from the assets manager.
  68696. * @param task the task to remove
  68697. */
  68698. removeTask(task: AbstractAssetTask): void;
  68699. private _decreaseWaitingTasksCount;
  68700. private _runTask;
  68701. /**
  68702. * Reset the AssetsManager and remove all tasks
  68703. * @return the current instance of the AssetsManager
  68704. */
  68705. reset(): AssetsManager;
  68706. /**
  68707. * Start the loading process
  68708. * @return the current instance of the AssetsManager
  68709. */
  68710. load(): AssetsManager;
  68711. /**
  68712. * Start the loading process as an async operation
  68713. * @return a promise returning the list of failed tasks
  68714. */
  68715. loadAsync(): Promise<void>;
  68716. }
  68717. }
  68718. declare module BABYLON {
  68719. /**
  68720. * Wrapper class for promise with external resolve and reject.
  68721. */
  68722. export class Deferred<T> {
  68723. /**
  68724. * The promise associated with this deferred object.
  68725. */
  68726. readonly promise: Promise<T>;
  68727. private _resolve;
  68728. private _reject;
  68729. /**
  68730. * The resolve method of the promise associated with this deferred object.
  68731. */
  68732. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68733. /**
  68734. * The reject method of the promise associated with this deferred object.
  68735. */
  68736. get reject(): (reason?: any) => void;
  68737. /**
  68738. * Constructor for this deferred object.
  68739. */
  68740. constructor();
  68741. }
  68742. }
  68743. declare module BABYLON {
  68744. /**
  68745. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68746. */
  68747. export class MeshExploder {
  68748. private _centerMesh;
  68749. private _meshes;
  68750. private _meshesOrigins;
  68751. private _toCenterVectors;
  68752. private _scaledDirection;
  68753. private _newPosition;
  68754. private _centerPosition;
  68755. /**
  68756. * Explodes meshes from a center mesh.
  68757. * @param meshes The meshes to explode.
  68758. * @param centerMesh The mesh to be center of explosion.
  68759. */
  68760. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68761. private _setCenterMesh;
  68762. /**
  68763. * Get class name
  68764. * @returns "MeshExploder"
  68765. */
  68766. getClassName(): string;
  68767. /**
  68768. * "Exploded meshes"
  68769. * @returns Array of meshes with the centerMesh at index 0.
  68770. */
  68771. getMeshes(): Array<Mesh>;
  68772. /**
  68773. * Explodes meshes giving a specific direction
  68774. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68775. */
  68776. explode(direction?: number): void;
  68777. }
  68778. }
  68779. declare module BABYLON {
  68780. /**
  68781. * Class used to help managing file picking and drag'n'drop
  68782. */
  68783. export class FilesInput {
  68784. /**
  68785. * List of files ready to be loaded
  68786. */
  68787. static get FilesToLoad(): {
  68788. [key: string]: File;
  68789. };
  68790. /**
  68791. * Callback called when a file is processed
  68792. */
  68793. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68794. private _engine;
  68795. private _currentScene;
  68796. private _sceneLoadedCallback;
  68797. private _progressCallback;
  68798. private _additionalRenderLoopLogicCallback;
  68799. private _textureLoadingCallback;
  68800. private _startingProcessingFilesCallback;
  68801. private _onReloadCallback;
  68802. private _errorCallback;
  68803. private _elementToMonitor;
  68804. private _sceneFileToLoad;
  68805. private _filesToLoad;
  68806. /**
  68807. * Creates a new FilesInput
  68808. * @param engine defines the rendering engine
  68809. * @param scene defines the hosting scene
  68810. * @param sceneLoadedCallback callback called when scene is loaded
  68811. * @param progressCallback callback called to track progress
  68812. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68813. * @param textureLoadingCallback callback called when a texture is loading
  68814. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68815. * @param onReloadCallback callback called when a reload is requested
  68816. * @param errorCallback callback call if an error occurs
  68817. */
  68818. 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);
  68819. private _dragEnterHandler;
  68820. private _dragOverHandler;
  68821. private _dropHandler;
  68822. /**
  68823. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68824. * @param elementToMonitor defines the DOM element to track
  68825. */
  68826. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68827. /**
  68828. * Release all associated resources
  68829. */
  68830. dispose(): void;
  68831. private renderFunction;
  68832. private drag;
  68833. private drop;
  68834. private _traverseFolder;
  68835. private _processFiles;
  68836. /**
  68837. * Load files from a drop event
  68838. * @param event defines the drop event to use as source
  68839. */
  68840. loadFiles(event: any): void;
  68841. private _processReload;
  68842. /**
  68843. * Reload the current scene from the loaded files
  68844. */
  68845. reload(): void;
  68846. }
  68847. }
  68848. declare module BABYLON {
  68849. /**
  68850. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68851. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68852. */
  68853. export class SceneOptimization {
  68854. /**
  68855. * Defines the priority of this optimization (0 by default which means first in the list)
  68856. */
  68857. priority: number;
  68858. /**
  68859. * Gets a string describing the action executed by the current optimization
  68860. * @returns description string
  68861. */
  68862. getDescription(): string;
  68863. /**
  68864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68865. * @param scene defines the current scene where to apply this optimization
  68866. * @param optimizer defines the current optimizer
  68867. * @returns true if everything that can be done was applied
  68868. */
  68869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68870. /**
  68871. * Creates the SceneOptimization object
  68872. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68873. * @param desc defines the description associated with the optimization
  68874. */
  68875. constructor(
  68876. /**
  68877. * Defines the priority of this optimization (0 by default which means first in the list)
  68878. */
  68879. priority?: number);
  68880. }
  68881. /**
  68882. * Defines an optimization used to reduce the size of render target textures
  68883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68884. */
  68885. export class TextureOptimization extends SceneOptimization {
  68886. /**
  68887. * Defines the priority of this optimization (0 by default which means first in the list)
  68888. */
  68889. priority: number;
  68890. /**
  68891. * 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
  68892. */
  68893. maximumSize: number;
  68894. /**
  68895. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68896. */
  68897. step: number;
  68898. /**
  68899. * Gets a string describing the action executed by the current optimization
  68900. * @returns description string
  68901. */
  68902. getDescription(): string;
  68903. /**
  68904. * Creates the TextureOptimization object
  68905. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68906. * @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
  68907. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68908. */
  68909. constructor(
  68910. /**
  68911. * Defines the priority of this optimization (0 by default which means first in the list)
  68912. */
  68913. priority?: number,
  68914. /**
  68915. * 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
  68916. */
  68917. maximumSize?: number,
  68918. /**
  68919. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68920. */
  68921. step?: number);
  68922. /**
  68923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68924. * @param scene defines the current scene where to apply this optimization
  68925. * @param optimizer defines the current optimizer
  68926. * @returns true if everything that can be done was applied
  68927. */
  68928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68929. }
  68930. /**
  68931. * Defines an optimization used to increase or decrease the rendering resolution
  68932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68933. */
  68934. export class HardwareScalingOptimization extends SceneOptimization {
  68935. /**
  68936. * Defines the priority of this optimization (0 by default which means first in the list)
  68937. */
  68938. priority: number;
  68939. /**
  68940. * Defines the maximum scale to use (2 by default)
  68941. */
  68942. maximumScale: number;
  68943. /**
  68944. * Defines the step to use between two passes (0.5 by default)
  68945. */
  68946. step: number;
  68947. private _currentScale;
  68948. private _directionOffset;
  68949. /**
  68950. * Gets a string describing the action executed by the current optimization
  68951. * @return description string
  68952. */
  68953. getDescription(): string;
  68954. /**
  68955. * Creates the HardwareScalingOptimization object
  68956. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68957. * @param maximumScale defines the maximum scale to use (2 by default)
  68958. * @param step defines the step to use between two passes (0.5 by default)
  68959. */
  68960. constructor(
  68961. /**
  68962. * Defines the priority of this optimization (0 by default which means first in the list)
  68963. */
  68964. priority?: number,
  68965. /**
  68966. * Defines the maximum scale to use (2 by default)
  68967. */
  68968. maximumScale?: number,
  68969. /**
  68970. * Defines the step to use between two passes (0.5 by default)
  68971. */
  68972. step?: number);
  68973. /**
  68974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68975. * @param scene defines the current scene where to apply this optimization
  68976. * @param optimizer defines the current optimizer
  68977. * @returns true if everything that can be done was applied
  68978. */
  68979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68980. }
  68981. /**
  68982. * Defines an optimization used to remove shadows
  68983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68984. */
  68985. export class ShadowsOptimization extends SceneOptimization {
  68986. /**
  68987. * Gets a string describing the action executed by the current optimization
  68988. * @return description string
  68989. */
  68990. getDescription(): string;
  68991. /**
  68992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68993. * @param scene defines the current scene where to apply this optimization
  68994. * @param optimizer defines the current optimizer
  68995. * @returns true if everything that can be done was applied
  68996. */
  68997. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68998. }
  68999. /**
  69000. * Defines an optimization used to turn post-processes off
  69001. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69002. */
  69003. export class PostProcessesOptimization extends SceneOptimization {
  69004. /**
  69005. * Gets a string describing the action executed by the current optimization
  69006. * @return description string
  69007. */
  69008. getDescription(): string;
  69009. /**
  69010. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69011. * @param scene defines the current scene where to apply this optimization
  69012. * @param optimizer defines the current optimizer
  69013. * @returns true if everything that can be done was applied
  69014. */
  69015. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69016. }
  69017. /**
  69018. * Defines an optimization used to turn lens flares off
  69019. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69020. */
  69021. export class LensFlaresOptimization extends SceneOptimization {
  69022. /**
  69023. * Gets a string describing the action executed by the current optimization
  69024. * @return description string
  69025. */
  69026. getDescription(): string;
  69027. /**
  69028. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69029. * @param scene defines the current scene where to apply this optimization
  69030. * @param optimizer defines the current optimizer
  69031. * @returns true if everything that can be done was applied
  69032. */
  69033. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69034. }
  69035. /**
  69036. * Defines an optimization based on user defined callback.
  69037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69038. */
  69039. export class CustomOptimization extends SceneOptimization {
  69040. /**
  69041. * Callback called to apply the custom optimization.
  69042. */
  69043. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69044. /**
  69045. * Callback called to get custom description
  69046. */
  69047. onGetDescription: () => string;
  69048. /**
  69049. * Gets a string describing the action executed by the current optimization
  69050. * @returns description string
  69051. */
  69052. getDescription(): string;
  69053. /**
  69054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69055. * @param scene defines the current scene where to apply this optimization
  69056. * @param optimizer defines the current optimizer
  69057. * @returns true if everything that can be done was applied
  69058. */
  69059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69060. }
  69061. /**
  69062. * Defines an optimization used to turn particles off
  69063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69064. */
  69065. export class ParticlesOptimization extends SceneOptimization {
  69066. /**
  69067. * Gets a string describing the action executed by the current optimization
  69068. * @return description string
  69069. */
  69070. getDescription(): string;
  69071. /**
  69072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69073. * @param scene defines the current scene where to apply this optimization
  69074. * @param optimizer defines the current optimizer
  69075. * @returns true if everything that can be done was applied
  69076. */
  69077. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69078. }
  69079. /**
  69080. * Defines an optimization used to turn render targets off
  69081. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69082. */
  69083. export class RenderTargetsOptimization extends SceneOptimization {
  69084. /**
  69085. * Gets a string describing the action executed by the current optimization
  69086. * @return description string
  69087. */
  69088. getDescription(): string;
  69089. /**
  69090. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69091. * @param scene defines the current scene where to apply this optimization
  69092. * @param optimizer defines the current optimizer
  69093. * @returns true if everything that can be done was applied
  69094. */
  69095. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69096. }
  69097. /**
  69098. * Defines an optimization used to merge meshes with compatible materials
  69099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69100. */
  69101. export class MergeMeshesOptimization extends SceneOptimization {
  69102. private static _UpdateSelectionTree;
  69103. /**
  69104. * Gets or sets a boolean which defines if optimization octree has to be updated
  69105. */
  69106. static get UpdateSelectionTree(): boolean;
  69107. /**
  69108. * Gets or sets a boolean which defines if optimization octree has to be updated
  69109. */
  69110. static set UpdateSelectionTree(value: boolean);
  69111. /**
  69112. * Gets a string describing the action executed by the current optimization
  69113. * @return description string
  69114. */
  69115. getDescription(): string;
  69116. private _canBeMerged;
  69117. /**
  69118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69119. * @param scene defines the current scene where to apply this optimization
  69120. * @param optimizer defines the current optimizer
  69121. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69122. * @returns true if everything that can be done was applied
  69123. */
  69124. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69125. }
  69126. /**
  69127. * Defines a list of options used by SceneOptimizer
  69128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69129. */
  69130. export class SceneOptimizerOptions {
  69131. /**
  69132. * Defines the target frame rate to reach (60 by default)
  69133. */
  69134. targetFrameRate: number;
  69135. /**
  69136. * Defines the interval between two checkes (2000ms by default)
  69137. */
  69138. trackerDuration: number;
  69139. /**
  69140. * Gets the list of optimizations to apply
  69141. */
  69142. optimizations: SceneOptimization[];
  69143. /**
  69144. * Creates a new list of options used by SceneOptimizer
  69145. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69146. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69147. */
  69148. constructor(
  69149. /**
  69150. * Defines the target frame rate to reach (60 by default)
  69151. */
  69152. targetFrameRate?: number,
  69153. /**
  69154. * Defines the interval between two checkes (2000ms by default)
  69155. */
  69156. trackerDuration?: number);
  69157. /**
  69158. * Add a new optimization
  69159. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69160. * @returns the current SceneOptimizerOptions
  69161. */
  69162. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69163. /**
  69164. * Add a new custom optimization
  69165. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69166. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69167. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69168. * @returns the current SceneOptimizerOptions
  69169. */
  69170. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69171. /**
  69172. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69173. * @param targetFrameRate defines the target frame rate (60 by default)
  69174. * @returns a SceneOptimizerOptions object
  69175. */
  69176. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69177. /**
  69178. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69179. * @param targetFrameRate defines the target frame rate (60 by default)
  69180. * @returns a SceneOptimizerOptions object
  69181. */
  69182. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69183. /**
  69184. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69185. * @param targetFrameRate defines the target frame rate (60 by default)
  69186. * @returns a SceneOptimizerOptions object
  69187. */
  69188. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69189. }
  69190. /**
  69191. * Class used to run optimizations in order to reach a target frame rate
  69192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69193. */
  69194. export class SceneOptimizer implements IDisposable {
  69195. private _isRunning;
  69196. private _options;
  69197. private _scene;
  69198. private _currentPriorityLevel;
  69199. private _targetFrameRate;
  69200. private _trackerDuration;
  69201. private _currentFrameRate;
  69202. private _sceneDisposeObserver;
  69203. private _improvementMode;
  69204. /**
  69205. * Defines an observable called when the optimizer reaches the target frame rate
  69206. */
  69207. onSuccessObservable: Observable<SceneOptimizer>;
  69208. /**
  69209. * Defines an observable called when the optimizer enables an optimization
  69210. */
  69211. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69212. /**
  69213. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69214. */
  69215. onFailureObservable: Observable<SceneOptimizer>;
  69216. /**
  69217. * Gets a boolean indicating if the optimizer is in improvement mode
  69218. */
  69219. get isInImprovementMode(): boolean;
  69220. /**
  69221. * Gets the current priority level (0 at start)
  69222. */
  69223. get currentPriorityLevel(): number;
  69224. /**
  69225. * Gets the current frame rate checked by the SceneOptimizer
  69226. */
  69227. get currentFrameRate(): number;
  69228. /**
  69229. * Gets or sets the current target frame rate (60 by default)
  69230. */
  69231. get targetFrameRate(): number;
  69232. /**
  69233. * Gets or sets the current target frame rate (60 by default)
  69234. */
  69235. set targetFrameRate(value: number);
  69236. /**
  69237. * Gets or sets the current interval between two checks (every 2000ms by default)
  69238. */
  69239. get trackerDuration(): number;
  69240. /**
  69241. * Gets or sets the current interval between two checks (every 2000ms by default)
  69242. */
  69243. set trackerDuration(value: number);
  69244. /**
  69245. * Gets the list of active optimizations
  69246. */
  69247. get optimizations(): SceneOptimization[];
  69248. /**
  69249. * Creates a new SceneOptimizer
  69250. * @param scene defines the scene to work on
  69251. * @param options defines the options to use with the SceneOptimizer
  69252. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69253. * @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)
  69254. */
  69255. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69256. /**
  69257. * Stops the current optimizer
  69258. */
  69259. stop(): void;
  69260. /**
  69261. * Reset the optimizer to initial step (current priority level = 0)
  69262. */
  69263. reset(): void;
  69264. /**
  69265. * Start the optimizer. By default it will try to reach a specific framerate
  69266. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69267. */
  69268. start(): void;
  69269. private _checkCurrentState;
  69270. /**
  69271. * Release all resources
  69272. */
  69273. dispose(): void;
  69274. /**
  69275. * Helper function to create a SceneOptimizer with one single line of code
  69276. * @param scene defines the scene to work on
  69277. * @param options defines the options to use with the SceneOptimizer
  69278. * @param onSuccess defines a callback to call on success
  69279. * @param onFailure defines a callback to call on failure
  69280. * @returns the new SceneOptimizer object
  69281. */
  69282. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69283. }
  69284. }
  69285. declare module BABYLON {
  69286. /**
  69287. * Class used to serialize a scene into a string
  69288. */
  69289. export class SceneSerializer {
  69290. /**
  69291. * Clear cache used by a previous serialization
  69292. */
  69293. static ClearCache(): void;
  69294. /**
  69295. * Serialize a scene into a JSON compatible object
  69296. * @param scene defines the scene to serialize
  69297. * @returns a JSON compatible object
  69298. */
  69299. static Serialize(scene: Scene): any;
  69300. /**
  69301. * Serialize a mesh into a JSON compatible object
  69302. * @param toSerialize defines the mesh to serialize
  69303. * @param withParents defines if parents must be serialized as well
  69304. * @param withChildren defines if children must be serialized as well
  69305. * @returns a JSON compatible object
  69306. */
  69307. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69308. }
  69309. }
  69310. declare module BABYLON {
  69311. /**
  69312. * Class used to host texture specific utilities
  69313. */
  69314. export class TextureTools {
  69315. /**
  69316. * Uses the GPU to create a copy texture rescaled at a given size
  69317. * @param texture Texture to copy from
  69318. * @param width defines the desired width
  69319. * @param height defines the desired height
  69320. * @param useBilinearMode defines if bilinear mode has to be used
  69321. * @return the generated texture
  69322. */
  69323. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69324. }
  69325. }
  69326. declare module BABYLON {
  69327. /**
  69328. * This represents the different options available for the video capture.
  69329. */
  69330. export interface VideoRecorderOptions {
  69331. /** Defines the mime type of the video. */
  69332. mimeType: string;
  69333. /** Defines the FPS the video should be recorded at. */
  69334. fps: number;
  69335. /** Defines the chunk size for the recording data. */
  69336. recordChunckSize: number;
  69337. /** The audio tracks to attach to the recording. */
  69338. audioTracks?: MediaStreamTrack[];
  69339. }
  69340. /**
  69341. * This can help with recording videos from BabylonJS.
  69342. * This is based on the available WebRTC functionalities of the browser.
  69343. *
  69344. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69345. */
  69346. export class VideoRecorder {
  69347. private static readonly _defaultOptions;
  69348. /**
  69349. * Returns whether or not the VideoRecorder is available in your browser.
  69350. * @param engine Defines the Babylon Engine.
  69351. * @returns true if supported otherwise false.
  69352. */
  69353. static IsSupported(engine: Engine): boolean;
  69354. private readonly _options;
  69355. private _canvas;
  69356. private _mediaRecorder;
  69357. private _recordedChunks;
  69358. private _fileName;
  69359. private _resolve;
  69360. private _reject;
  69361. /**
  69362. * True when a recording is already in progress.
  69363. */
  69364. get isRecording(): boolean;
  69365. /**
  69366. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69367. * @param engine Defines the BabylonJS Engine you wish to record.
  69368. * @param options Defines options that can be used to customize the capture.
  69369. */
  69370. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69371. /**
  69372. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69373. */
  69374. stopRecording(): void;
  69375. /**
  69376. * Starts recording the canvas for a max duration specified in parameters.
  69377. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69378. * If null no automatic download will start and you can rely on the promise to get the data back.
  69379. * @param maxDuration Defines the maximum recording time in seconds.
  69380. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69381. * @return A promise callback at the end of the recording with the video data in Blob.
  69382. */
  69383. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69384. /**
  69385. * Releases internal resources used during the recording.
  69386. */
  69387. dispose(): void;
  69388. private _handleDataAvailable;
  69389. private _handleError;
  69390. private _handleStop;
  69391. }
  69392. }
  69393. declare module BABYLON {
  69394. /**
  69395. * Class containing a set of static utilities functions for screenshots
  69396. */
  69397. export class ScreenshotTools {
  69398. /**
  69399. * Captures a screenshot of the current rendering
  69400. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69401. * @param engine defines the rendering engine
  69402. * @param camera defines the source camera
  69403. * @param size This parameter can be set to a single number or to an object with the
  69404. * following (optional) properties: precision, width, height. If a single number is passed,
  69405. * it will be used for both width and height. If an object is passed, the screenshot size
  69406. * will be derived from the parameters. The precision property is a multiplier allowing
  69407. * rendering at a higher or lower resolution
  69408. * @param successCallback defines the callback receives a single parameter which contains the
  69409. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69410. * src parameter of an <img> to display it
  69411. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69412. * Check your browser for supported MIME types
  69413. */
  69414. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69415. /**
  69416. * Captures a screenshot of the current rendering
  69417. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69418. * @param engine defines the rendering engine
  69419. * @param camera defines the source camera
  69420. * @param size This parameter can be set to a single number or to an object with the
  69421. * following (optional) properties: precision, width, height. If a single number is passed,
  69422. * it will be used for both width and height. If an object is passed, the screenshot size
  69423. * will be derived from the parameters. The precision property is a multiplier allowing
  69424. * rendering at a higher or lower resolution
  69425. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69426. * Check your browser for supported MIME types
  69427. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69428. * to the src parameter of an <img> to display it
  69429. */
  69430. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69431. /**
  69432. * Generates an image screenshot from the specified camera.
  69433. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69434. * @param engine The engine to use for rendering
  69435. * @param camera The camera to use for rendering
  69436. * @param size This parameter can be set to a single number or to an object with the
  69437. * following (optional) properties: precision, width, height. If a single number is passed,
  69438. * it will be used for both width and height. If an object is passed, the screenshot size
  69439. * will be derived from the parameters. The precision property is a multiplier allowing
  69440. * rendering at a higher or lower resolution
  69441. * @param successCallback The callback receives a single parameter which contains the
  69442. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69443. * src parameter of an <img> to display it
  69444. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69445. * Check your browser for supported MIME types
  69446. * @param samples Texture samples (default: 1)
  69447. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69448. * @param fileName A name for for the downloaded file.
  69449. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69450. */
  69451. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69452. /**
  69453. * Generates an image screenshot from the specified camera.
  69454. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69455. * @param engine The engine to use for rendering
  69456. * @param camera The camera to use for rendering
  69457. * @param size This parameter can be set to a single number or to an object with the
  69458. * following (optional) properties: precision, width, height. If a single number is passed,
  69459. * it will be used for both width and height. If an object is passed, the screenshot size
  69460. * will be derived from the parameters. The precision property is a multiplier allowing
  69461. * rendering at a higher or lower resolution
  69462. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69463. * Check your browser for supported MIME types
  69464. * @param samples Texture samples (default: 1)
  69465. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69466. * @param fileName A name for for the downloaded file.
  69467. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69468. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69469. * to the src parameter of an <img> to display it
  69470. */
  69471. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69472. /**
  69473. * Gets height and width for screenshot size
  69474. * @private
  69475. */
  69476. private static _getScreenshotSize;
  69477. }
  69478. }
  69479. declare module BABYLON {
  69480. /**
  69481. * Interface for a data buffer
  69482. */
  69483. export interface IDataBuffer {
  69484. /**
  69485. * Reads bytes from the data buffer.
  69486. * @param byteOffset The byte offset to read
  69487. * @param byteLength The byte length to read
  69488. * @returns A promise that resolves when the bytes are read
  69489. */
  69490. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69491. /**
  69492. * The byte length of the buffer.
  69493. */
  69494. readonly byteLength: number;
  69495. }
  69496. /**
  69497. * Utility class for reading from a data buffer
  69498. */
  69499. export class DataReader {
  69500. /**
  69501. * The data buffer associated with this data reader.
  69502. */
  69503. readonly buffer: IDataBuffer;
  69504. /**
  69505. * The current byte offset from the beginning of the data buffer.
  69506. */
  69507. byteOffset: number;
  69508. private _dataView;
  69509. private _dataByteOffset;
  69510. /**
  69511. * Constructor
  69512. * @param buffer The buffer to read
  69513. */
  69514. constructor(buffer: IDataBuffer);
  69515. /**
  69516. * Loads the given byte length.
  69517. * @param byteLength The byte length to load
  69518. * @returns A promise that resolves when the load is complete
  69519. */
  69520. loadAsync(byteLength: number): Promise<void>;
  69521. /**
  69522. * Read a unsigned 32-bit integer from the currently loaded data range.
  69523. * @returns The 32-bit integer read
  69524. */
  69525. readUint32(): number;
  69526. /**
  69527. * Read a byte array from the currently loaded data range.
  69528. * @param byteLength The byte length to read
  69529. * @returns The byte array read
  69530. */
  69531. readUint8Array(byteLength: number): Uint8Array;
  69532. /**
  69533. * Read a string from the currently loaded data range.
  69534. * @param byteLength The byte length to read
  69535. * @returns The string read
  69536. */
  69537. readString(byteLength: number): string;
  69538. /**
  69539. * Skips the given byte length the currently loaded data range.
  69540. * @param byteLength The byte length to skip
  69541. */
  69542. skipBytes(byteLength: number): void;
  69543. }
  69544. }
  69545. declare module BABYLON {
  69546. /**
  69547. * Class for storing data to local storage if available or in-memory storage otherwise
  69548. */
  69549. export class DataStorage {
  69550. private static _Storage;
  69551. private static _GetStorage;
  69552. /**
  69553. * Reads a string from the data storage
  69554. * @param key The key to read
  69555. * @param defaultValue The value if the key doesn't exist
  69556. * @returns The string value
  69557. */
  69558. static ReadString(key: string, defaultValue: string): string;
  69559. /**
  69560. * Writes a string to the data storage
  69561. * @param key The key to write
  69562. * @param value The value to write
  69563. */
  69564. static WriteString(key: string, value: string): void;
  69565. /**
  69566. * Reads a boolean from the data storage
  69567. * @param key The key to read
  69568. * @param defaultValue The value if the key doesn't exist
  69569. * @returns The boolean value
  69570. */
  69571. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69572. /**
  69573. * Writes a boolean to the data storage
  69574. * @param key The key to write
  69575. * @param value The value to write
  69576. */
  69577. static WriteBoolean(key: string, value: boolean): void;
  69578. /**
  69579. * Reads a number from the data storage
  69580. * @param key The key to read
  69581. * @param defaultValue The value if the key doesn't exist
  69582. * @returns The number value
  69583. */
  69584. static ReadNumber(key: string, defaultValue: number): number;
  69585. /**
  69586. * Writes a number to the data storage
  69587. * @param key The key to write
  69588. * @param value The value to write
  69589. */
  69590. static WriteNumber(key: string, value: number): void;
  69591. }
  69592. }
  69593. declare module BABYLON {
  69594. /**
  69595. * Options used for hit testing
  69596. */
  69597. export interface IWebXRLegacyHitTestOptions {
  69598. /**
  69599. * Only test when user interacted with the scene. Default - hit test every frame
  69600. */
  69601. testOnPointerDownOnly?: boolean;
  69602. /**
  69603. * The node to use to transform the local results to world coordinates
  69604. */
  69605. worldParentNode?: TransformNode;
  69606. }
  69607. /**
  69608. * Interface defining the babylon result of raycasting/hit-test
  69609. */
  69610. export interface IWebXRLegacyHitResult {
  69611. /**
  69612. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69613. */
  69614. transformationMatrix: Matrix;
  69615. /**
  69616. * The native hit test result
  69617. */
  69618. xrHitResult: XRHitResult | XRHitTestResult;
  69619. }
  69620. /**
  69621. * The currently-working hit-test module.
  69622. * Hit test (or Ray-casting) is used to interact with the real world.
  69623. * For further information read here - https://github.com/immersive-web/hit-test
  69624. */
  69625. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69626. /**
  69627. * options to use when constructing this feature
  69628. */
  69629. readonly options: IWebXRLegacyHitTestOptions;
  69630. private _direction;
  69631. private _mat;
  69632. private _onSelectEnabled;
  69633. private _origin;
  69634. /**
  69635. * The module's name
  69636. */
  69637. static readonly Name: string;
  69638. /**
  69639. * The (Babylon) version of this module.
  69640. * This is an integer representing the implementation version.
  69641. * This number does not correspond to the WebXR specs version
  69642. */
  69643. static readonly Version: number;
  69644. /**
  69645. * Populated with the last native XR Hit Results
  69646. */
  69647. lastNativeXRHitResults: XRHitResult[];
  69648. /**
  69649. * Triggered when new babylon (transformed) hit test results are available
  69650. */
  69651. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69652. /**
  69653. * Creates a new instance of the (legacy version) hit test feature
  69654. * @param _xrSessionManager an instance of WebXRSessionManager
  69655. * @param options options to use when constructing this feature
  69656. */
  69657. constructor(_xrSessionManager: WebXRSessionManager,
  69658. /**
  69659. * options to use when constructing this feature
  69660. */
  69661. options?: IWebXRLegacyHitTestOptions);
  69662. /**
  69663. * execute a hit test with an XR Ray
  69664. *
  69665. * @param xrSession a native xrSession that will execute this hit test
  69666. * @param xrRay the ray (position and direction) to use for ray-casting
  69667. * @param referenceSpace native XR reference space to use for the hit-test
  69668. * @param filter filter function that will filter the results
  69669. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69670. */
  69671. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69672. /**
  69673. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69674. * @param event the (select) event to use to select with
  69675. * @param referenceSpace the reference space to use for this hit test
  69676. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69677. */
  69678. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69679. /**
  69680. * attach this feature
  69681. * Will usually be called by the features manager
  69682. *
  69683. * @returns true if successful.
  69684. */
  69685. attach(): boolean;
  69686. /**
  69687. * detach this feature.
  69688. * Will usually be called by the features manager
  69689. *
  69690. * @returns true if successful.
  69691. */
  69692. detach(): boolean;
  69693. /**
  69694. * Dispose this feature and all of the resources attached
  69695. */
  69696. dispose(): void;
  69697. protected _onXRFrame(frame: XRFrame): void;
  69698. private _onHitTestResults;
  69699. private _onSelect;
  69700. }
  69701. }
  69702. declare module BABYLON {
  69703. /**
  69704. * Options used in the plane detector module
  69705. */
  69706. export interface IWebXRPlaneDetectorOptions {
  69707. /**
  69708. * The node to use to transform the local results to world coordinates
  69709. */
  69710. worldParentNode?: TransformNode;
  69711. }
  69712. /**
  69713. * A babylon interface for a WebXR plane.
  69714. * A Plane is actually a polygon, built from N points in space
  69715. *
  69716. * Supported in chrome 79, not supported in canary 81 ATM
  69717. */
  69718. export interface IWebXRPlane {
  69719. /**
  69720. * a babylon-assigned ID for this polygon
  69721. */
  69722. id: number;
  69723. /**
  69724. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69725. */
  69726. polygonDefinition: Array<Vector3>;
  69727. /**
  69728. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69729. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69730. */
  69731. transformationMatrix: Matrix;
  69732. /**
  69733. * the native xr-plane object
  69734. */
  69735. xrPlane: XRPlane;
  69736. }
  69737. /**
  69738. * The plane detector is used to detect planes in the real world when in AR
  69739. * For more information see https://github.com/immersive-web/real-world-geometry/
  69740. */
  69741. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69742. private _options;
  69743. private _detectedPlanes;
  69744. private _enabled;
  69745. private _lastFrameDetected;
  69746. /**
  69747. * The module's name
  69748. */
  69749. static readonly Name: string;
  69750. /**
  69751. * The (Babylon) version of this module.
  69752. * This is an integer representing the implementation version.
  69753. * This number does not correspond to the WebXR specs version
  69754. */
  69755. static readonly Version: number;
  69756. /**
  69757. * Observers registered here will be executed when a new plane was added to the session
  69758. */
  69759. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69760. /**
  69761. * Observers registered here will be executed when a plane is no longer detected in the session
  69762. */
  69763. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69764. /**
  69765. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69766. * This can execute N times every frame
  69767. */
  69768. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69769. /**
  69770. * construct a new Plane Detector
  69771. * @param _xrSessionManager an instance of xr Session manager
  69772. * @param _options configuration to use when constructing this feature
  69773. */
  69774. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69775. /**
  69776. * Dispose this feature and all of the resources attached
  69777. */
  69778. dispose(): void;
  69779. protected _onXRFrame(frame: XRFrame): void;
  69780. private _init;
  69781. private _updatePlaneWithXRPlane;
  69782. /**
  69783. * avoiding using Array.find for global support.
  69784. * @param xrPlane the plane to find in the array
  69785. */
  69786. private findIndexInPlaneArray;
  69787. }
  69788. }
  69789. declare module BABYLON {
  69790. /**
  69791. * Configuration options of the anchor system
  69792. */
  69793. export interface IWebXRAnchorSystemOptions {
  69794. /**
  69795. * Should a new anchor be added every time a select event is triggered
  69796. */
  69797. addAnchorOnSelect?: boolean;
  69798. /**
  69799. * should the anchor system use plane detection.
  69800. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69801. */
  69802. usePlaneDetection?: boolean;
  69803. /**
  69804. * a node that will be used to convert local to world coordinates
  69805. */
  69806. worldParentNode?: TransformNode;
  69807. }
  69808. /**
  69809. * A babylon container for an XR Anchor
  69810. */
  69811. export interface IWebXRAnchor {
  69812. /**
  69813. * A babylon-assigned ID for this anchor
  69814. */
  69815. id: number;
  69816. /**
  69817. * Transformation matrix to apply to an object attached to this anchor
  69818. */
  69819. transformationMatrix: Matrix;
  69820. /**
  69821. * The native anchor object
  69822. */
  69823. xrAnchor: XRAnchor;
  69824. }
  69825. /**
  69826. * An implementation of the anchor system of WebXR.
  69827. * Note that the current documented implementation is not available in any browser. Future implementations
  69828. * will use the frame to create an anchor and not the session or a detected plane
  69829. * For further information see https://github.com/immersive-web/anchors/
  69830. */
  69831. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69832. private _options;
  69833. private _enabled;
  69834. private _hitTestModule;
  69835. private _lastFrameDetected;
  69836. private _onSelect;
  69837. private _planeDetector;
  69838. private _trackedAnchors;
  69839. /**
  69840. * The module's name
  69841. */
  69842. static readonly Name: string;
  69843. /**
  69844. * The (Babylon) version of this module.
  69845. * This is an integer representing the implementation version.
  69846. * This number does not correspond to the WebXR specs version
  69847. */
  69848. static readonly Version: number;
  69849. /**
  69850. * Observers registered here will be executed when a new anchor was added to the session
  69851. */
  69852. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69853. /**
  69854. * Observers registered here will be executed when an anchor was removed from the session
  69855. */
  69856. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69857. /**
  69858. * Observers registered here will be executed when an existing anchor updates
  69859. * This can execute N times every frame
  69860. */
  69861. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69862. /**
  69863. * constructs a new anchor system
  69864. * @param _xrSessionManager an instance of WebXRSessionManager
  69865. * @param _options configuration object for this feature
  69866. */
  69867. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69868. /**
  69869. * Add anchor at a specific XR point.
  69870. *
  69871. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69872. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69873. * @returns a promise the fulfills when the anchor was created
  69874. */
  69875. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69876. /**
  69877. * attach this feature
  69878. * Will usually be called by the features manager
  69879. *
  69880. * @returns true if successful.
  69881. */
  69882. attach(): boolean;
  69883. /**
  69884. * detach this feature.
  69885. * Will usually be called by the features manager
  69886. *
  69887. * @returns true if successful.
  69888. */
  69889. detach(): boolean;
  69890. /**
  69891. * Dispose this feature and all of the resources attached
  69892. */
  69893. dispose(): void;
  69894. /**
  69895. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69896. * @param hitTestModule the hit-test module to use.
  69897. */
  69898. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69899. /**
  69900. * set the plane detector to use in order to create anchors from frames
  69901. * @param planeDetector the plane-detector module to use
  69902. * @param enable enable plane-anchors. default is true
  69903. */
  69904. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69905. protected _onXRFrame(frame: XRFrame): void;
  69906. /**
  69907. * avoiding using Array.find for global support.
  69908. * @param xrAnchor the plane to find in the array
  69909. */
  69910. private _findIndexInAnchorArray;
  69911. private _updateAnchorWithXRFrame;
  69912. }
  69913. }
  69914. declare module BABYLON {
  69915. /**
  69916. * Options interface for the background remover plugin
  69917. */
  69918. export interface IWebXRBackgroundRemoverOptions {
  69919. /**
  69920. * Further background meshes to disable when entering AR
  69921. */
  69922. backgroundMeshes?: AbstractMesh[];
  69923. /**
  69924. * flags to configure the removal of the environment helper.
  69925. * If not set, the entire background will be removed. If set, flags should be set as well.
  69926. */
  69927. environmentHelperRemovalFlags?: {
  69928. /**
  69929. * Should the skybox be removed (default false)
  69930. */
  69931. skyBox?: boolean;
  69932. /**
  69933. * Should the ground be removed (default false)
  69934. */
  69935. ground?: boolean;
  69936. };
  69937. /**
  69938. * don't disable the environment helper
  69939. */
  69940. ignoreEnvironmentHelper?: boolean;
  69941. }
  69942. /**
  69943. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69944. */
  69945. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69946. /**
  69947. * read-only options to be used in this module
  69948. */
  69949. readonly options: IWebXRBackgroundRemoverOptions;
  69950. /**
  69951. * The module's name
  69952. */
  69953. static readonly Name: string;
  69954. /**
  69955. * The (Babylon) version of this module.
  69956. * This is an integer representing the implementation version.
  69957. * This number does not correspond to the WebXR specs version
  69958. */
  69959. static readonly Version: number;
  69960. /**
  69961. * registered observers will be triggered when the background state changes
  69962. */
  69963. onBackgroundStateChangedObservable: Observable<boolean>;
  69964. /**
  69965. * constructs a new background remover module
  69966. * @param _xrSessionManager the session manager for this module
  69967. * @param options read-only options to be used in this module
  69968. */
  69969. constructor(_xrSessionManager: WebXRSessionManager,
  69970. /**
  69971. * read-only options to be used in this module
  69972. */
  69973. options?: IWebXRBackgroundRemoverOptions);
  69974. /**
  69975. * attach this feature
  69976. * Will usually be called by the features manager
  69977. *
  69978. * @returns true if successful.
  69979. */
  69980. attach(): boolean;
  69981. /**
  69982. * detach this feature.
  69983. * Will usually be called by the features manager
  69984. *
  69985. * @returns true if successful.
  69986. */
  69987. detach(): boolean;
  69988. /**
  69989. * Dispose this feature and all of the resources attached
  69990. */
  69991. dispose(): void;
  69992. protected _onXRFrame(_xrFrame: XRFrame): void;
  69993. private _setBackgroundState;
  69994. }
  69995. }
  69996. declare module BABYLON {
  69997. /**
  69998. * Options for the controller physics feature
  69999. */
  70000. export class IWebXRControllerPhysicsOptions {
  70001. /**
  70002. * Should the headset get its own impostor
  70003. */
  70004. enableHeadsetImpostor?: boolean;
  70005. /**
  70006. * Optional parameters for the headset impostor
  70007. */
  70008. headsetImpostorParams?: {
  70009. /**
  70010. * The type of impostor to create. Default is sphere
  70011. */
  70012. impostorType: number;
  70013. /**
  70014. * the size of the impostor. Defaults to 10cm
  70015. */
  70016. impostorSize?: number | {
  70017. width: number;
  70018. height: number;
  70019. depth: number;
  70020. };
  70021. /**
  70022. * Friction definitions
  70023. */
  70024. friction?: number;
  70025. /**
  70026. * Restitution
  70027. */
  70028. restitution?: number;
  70029. };
  70030. /**
  70031. * The physics properties of the future impostors
  70032. */
  70033. physicsProperties?: {
  70034. /**
  70035. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  70036. * Note that this requires a physics engine that supports mesh impostors!
  70037. */
  70038. useControllerMesh?: boolean;
  70039. /**
  70040. * The type of impostor to create. Default is sphere
  70041. */
  70042. impostorType?: number;
  70043. /**
  70044. * the size of the impostor. Defaults to 10cm
  70045. */
  70046. impostorSize?: number | {
  70047. width: number;
  70048. height: number;
  70049. depth: number;
  70050. };
  70051. /**
  70052. * Friction definitions
  70053. */
  70054. friction?: number;
  70055. /**
  70056. * Restitution
  70057. */
  70058. restitution?: number;
  70059. };
  70060. /**
  70061. * the xr input to use with this pointer selection
  70062. */
  70063. xrInput: WebXRInput;
  70064. }
  70065. /**
  70066. * Add physics impostor to your webxr controllers,
  70067. * including naive calculation of their linear and angular velocity
  70068. */
  70069. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  70070. private readonly _options;
  70071. private _attachController;
  70072. private _controllers;
  70073. private _debugMode;
  70074. private _delta;
  70075. private _headsetImpostor?;
  70076. private _headsetMesh?;
  70077. private _lastTimestamp;
  70078. private _tmpQuaternion;
  70079. private _tmpVector;
  70080. /**
  70081. * The module's name
  70082. */
  70083. static readonly Name: string;
  70084. /**
  70085. * The (Babylon) version of this module.
  70086. * This is an integer representing the implementation version.
  70087. * This number does not correspond to the webxr specs version
  70088. */
  70089. static readonly Version: number;
  70090. /**
  70091. * Construct a new Controller Physics Feature
  70092. * @param _xrSessionManager the corresponding xr session manager
  70093. * @param _options options to create this feature with
  70094. */
  70095. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  70096. /**
  70097. * @hidden
  70098. * enable debugging - will show console outputs and the impostor mesh
  70099. */
  70100. _enablePhysicsDebug(): void;
  70101. /**
  70102. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  70103. * @param xrController the controller to add
  70104. */
  70105. addController(xrController: WebXRInputSource): void;
  70106. /**
  70107. * attach this feature
  70108. * Will usually be called by the features manager
  70109. *
  70110. * @returns true if successful.
  70111. */
  70112. attach(): boolean;
  70113. /**
  70114. * detach this feature.
  70115. * Will usually be called by the features manager
  70116. *
  70117. * @returns true if successful.
  70118. */
  70119. detach(): boolean;
  70120. /**
  70121. * Get the headset impostor, if enabled
  70122. * @returns the impostor
  70123. */
  70124. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70125. /**
  70126. * Get the physics impostor of a specific controller.
  70127. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70128. * @param controller the controller or the controller id of which to get the impostor
  70129. * @returns the impostor or null
  70130. */
  70131. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70132. /**
  70133. * Update the physics properties provided in the constructor
  70134. * @param newProperties the new properties object
  70135. */
  70136. setPhysicsProperties(newProperties: {
  70137. impostorType?: number;
  70138. impostorSize?: number | {
  70139. width: number;
  70140. height: number;
  70141. depth: number;
  70142. };
  70143. friction?: number;
  70144. restitution?: number;
  70145. }): void;
  70146. protected _onXRFrame(_xrFrame: any): void;
  70147. private _detachController;
  70148. }
  70149. }
  70150. declare module BABYLON {
  70151. /**
  70152. * Options used for hit testing (version 2)
  70153. */
  70154. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70155. /**
  70156. * Do not create a permanent hit test. Will usually be used when only
  70157. * transient inputs are needed.
  70158. */
  70159. disablePermanentHitTest?: boolean;
  70160. /**
  70161. * Enable transient (for example touch-based) hit test inspections
  70162. */
  70163. enableTransientHitTest?: boolean;
  70164. /**
  70165. * Offset ray for the permanent hit test
  70166. */
  70167. offsetRay?: Vector3;
  70168. /**
  70169. * Offset ray for the transient hit test
  70170. */
  70171. transientOffsetRay?: Vector3;
  70172. /**
  70173. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70174. */
  70175. useReferenceSpace?: boolean;
  70176. }
  70177. /**
  70178. * Interface defining the babylon result of hit-test
  70179. */
  70180. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70181. /**
  70182. * The input source that generated this hit test (if transient)
  70183. */
  70184. inputSource?: XRInputSource;
  70185. /**
  70186. * Is this a transient hit test
  70187. */
  70188. isTransient?: boolean;
  70189. /**
  70190. * Position of the hit test result
  70191. */
  70192. position: Vector3;
  70193. /**
  70194. * Rotation of the hit test result
  70195. */
  70196. rotationQuaternion: Quaternion;
  70197. }
  70198. /**
  70199. * The currently-working hit-test module.
  70200. * Hit test (or Ray-casting) is used to interact with the real world.
  70201. * For further information read here - https://github.com/immersive-web/hit-test
  70202. *
  70203. * Tested on chrome (mobile) 80.
  70204. */
  70205. export class WebXRHitTest extends WebXRAbstractFeature {
  70206. /**
  70207. * options to use when constructing this feature
  70208. */
  70209. readonly options: IWebXRHitTestOptions;
  70210. private _tmpMat;
  70211. private _tmpPos;
  70212. private _tmpQuat;
  70213. private _transientXrHitTestSource;
  70214. private _xrHitTestSource;
  70215. private initHitTestSource;
  70216. /**
  70217. * The module's name
  70218. */
  70219. static readonly Name: string;
  70220. /**
  70221. * The (Babylon) version of this module.
  70222. * This is an integer representing the implementation version.
  70223. * This number does not correspond to the WebXR specs version
  70224. */
  70225. static readonly Version: number;
  70226. /**
  70227. * When set to true, each hit test will have its own position/rotation objects
  70228. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70229. * the developers will clone them or copy them as they see fit.
  70230. */
  70231. autoCloneTransformation: boolean;
  70232. /**
  70233. * Populated with the last native XR Hit Results
  70234. */
  70235. lastNativeXRHitResults: XRHitResult[];
  70236. /**
  70237. * Triggered when new babylon (transformed) hit test results are available
  70238. */
  70239. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70240. /**
  70241. * Use this to temporarily pause hit test checks.
  70242. */
  70243. paused: boolean;
  70244. /**
  70245. * Creates a new instance of the hit test feature
  70246. * @param _xrSessionManager an instance of WebXRSessionManager
  70247. * @param options options to use when constructing this feature
  70248. */
  70249. constructor(_xrSessionManager: WebXRSessionManager,
  70250. /**
  70251. * options to use when constructing this feature
  70252. */
  70253. options?: IWebXRHitTestOptions);
  70254. /**
  70255. * attach this feature
  70256. * Will usually be called by the features manager
  70257. *
  70258. * @returns true if successful.
  70259. */
  70260. attach(): boolean;
  70261. /**
  70262. * detach this feature.
  70263. * Will usually be called by the features manager
  70264. *
  70265. * @returns true if successful.
  70266. */
  70267. detach(): boolean;
  70268. /**
  70269. * Dispose this feature and all of the resources attached
  70270. */
  70271. dispose(): void;
  70272. protected _onXRFrame(frame: XRFrame): void;
  70273. private _processWebXRHitTestResult;
  70274. }
  70275. }
  70276. declare module BABYLON {
  70277. /**
  70278. * The motion controller class for all microsoft mixed reality controllers
  70279. */
  70280. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70281. protected readonly _mapping: {
  70282. defaultButton: {
  70283. valueNodeName: string;
  70284. unpressedNodeName: string;
  70285. pressedNodeName: string;
  70286. };
  70287. defaultAxis: {
  70288. valueNodeName: string;
  70289. minNodeName: string;
  70290. maxNodeName: string;
  70291. };
  70292. buttons: {
  70293. "xr-standard-trigger": {
  70294. rootNodeName: string;
  70295. componentProperty: string;
  70296. states: string[];
  70297. };
  70298. "xr-standard-squeeze": {
  70299. rootNodeName: string;
  70300. componentProperty: string;
  70301. states: string[];
  70302. };
  70303. "xr-standard-touchpad": {
  70304. rootNodeName: string;
  70305. labelAnchorNodeName: string;
  70306. touchPointNodeName: string;
  70307. };
  70308. "xr-standard-thumbstick": {
  70309. rootNodeName: string;
  70310. componentProperty: string;
  70311. states: string[];
  70312. };
  70313. };
  70314. axes: {
  70315. "xr-standard-touchpad": {
  70316. "x-axis": {
  70317. rootNodeName: string;
  70318. };
  70319. "y-axis": {
  70320. rootNodeName: string;
  70321. };
  70322. };
  70323. "xr-standard-thumbstick": {
  70324. "x-axis": {
  70325. rootNodeName: string;
  70326. };
  70327. "y-axis": {
  70328. rootNodeName: string;
  70329. };
  70330. };
  70331. };
  70332. };
  70333. /**
  70334. * The base url used to load the left and right controller models
  70335. */
  70336. static MODEL_BASE_URL: string;
  70337. /**
  70338. * The name of the left controller model file
  70339. */
  70340. static MODEL_LEFT_FILENAME: string;
  70341. /**
  70342. * The name of the right controller model file
  70343. */
  70344. static MODEL_RIGHT_FILENAME: string;
  70345. profileId: string;
  70346. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70347. protected _getFilenameAndPath(): {
  70348. filename: string;
  70349. path: string;
  70350. };
  70351. protected _getModelLoadingConstraints(): boolean;
  70352. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70353. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70354. protected _updateModel(): void;
  70355. }
  70356. }
  70357. declare module BABYLON {
  70358. /**
  70359. * The motion controller class for oculus touch (quest, rift).
  70360. * This class supports legacy mapping as well the standard xr mapping
  70361. */
  70362. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70363. private _forceLegacyControllers;
  70364. private _modelRootNode;
  70365. /**
  70366. * The base url used to load the left and right controller models
  70367. */
  70368. static MODEL_BASE_URL: string;
  70369. /**
  70370. * The name of the left controller model file
  70371. */
  70372. static MODEL_LEFT_FILENAME: string;
  70373. /**
  70374. * The name of the right controller model file
  70375. */
  70376. static MODEL_RIGHT_FILENAME: string;
  70377. /**
  70378. * Base Url for the Quest controller model.
  70379. */
  70380. static QUEST_MODEL_BASE_URL: string;
  70381. profileId: string;
  70382. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70383. protected _getFilenameAndPath(): {
  70384. filename: string;
  70385. path: string;
  70386. };
  70387. protected _getModelLoadingConstraints(): boolean;
  70388. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70389. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70390. protected _updateModel(): void;
  70391. /**
  70392. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70393. * between the touch and touch 2.
  70394. */
  70395. private _isQuest;
  70396. }
  70397. }
  70398. declare module BABYLON {
  70399. /**
  70400. * The motion controller class for the standard HTC-Vive controllers
  70401. */
  70402. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70403. private _modelRootNode;
  70404. /**
  70405. * The base url used to load the left and right controller models
  70406. */
  70407. static MODEL_BASE_URL: string;
  70408. /**
  70409. * File name for the controller model.
  70410. */
  70411. static MODEL_FILENAME: string;
  70412. profileId: string;
  70413. /**
  70414. * Create a new Vive motion controller object
  70415. * @param scene the scene to use to create this controller
  70416. * @param gamepadObject the corresponding gamepad object
  70417. * @param handness the handness of the controller
  70418. */
  70419. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70420. protected _getFilenameAndPath(): {
  70421. filename: string;
  70422. path: string;
  70423. };
  70424. protected _getModelLoadingConstraints(): boolean;
  70425. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70426. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70427. protected _updateModel(): void;
  70428. }
  70429. }
  70430. declare module BABYLON {
  70431. /**
  70432. * A cursor which tracks a point on a path
  70433. */
  70434. export class PathCursor {
  70435. private path;
  70436. /**
  70437. * Stores path cursor callbacks for when an onchange event is triggered
  70438. */
  70439. private _onchange;
  70440. /**
  70441. * The value of the path cursor
  70442. */
  70443. value: number;
  70444. /**
  70445. * The animation array of the path cursor
  70446. */
  70447. animations: Animation[];
  70448. /**
  70449. * Initializes the path cursor
  70450. * @param path The path to track
  70451. */
  70452. constructor(path: Path2);
  70453. /**
  70454. * Gets the cursor point on the path
  70455. * @returns A point on the path cursor at the cursor location
  70456. */
  70457. getPoint(): Vector3;
  70458. /**
  70459. * Moves the cursor ahead by the step amount
  70460. * @param step The amount to move the cursor forward
  70461. * @returns This path cursor
  70462. */
  70463. moveAhead(step?: number): PathCursor;
  70464. /**
  70465. * Moves the cursor behind by the step amount
  70466. * @param step The amount to move the cursor back
  70467. * @returns This path cursor
  70468. */
  70469. moveBack(step?: number): PathCursor;
  70470. /**
  70471. * Moves the cursor by the step amount
  70472. * If the step amount is greater than one, an exception is thrown
  70473. * @param step The amount to move the cursor
  70474. * @returns This path cursor
  70475. */
  70476. move(step: number): PathCursor;
  70477. /**
  70478. * Ensures that the value is limited between zero and one
  70479. * @returns This path cursor
  70480. */
  70481. private ensureLimits;
  70482. /**
  70483. * Runs onchange callbacks on change (used by the animation engine)
  70484. * @returns This path cursor
  70485. */
  70486. private raiseOnChange;
  70487. /**
  70488. * Executes a function on change
  70489. * @param f A path cursor onchange callback
  70490. * @returns This path cursor
  70491. */
  70492. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70493. }
  70494. }
  70495. declare module BABYLON {
  70496. /** @hidden */
  70497. export var blurPixelShader: {
  70498. name: string;
  70499. shader: string;
  70500. };
  70501. }
  70502. declare module BABYLON {
  70503. /** @hidden */
  70504. export var pointCloudVertexDeclaration: {
  70505. name: string;
  70506. shader: string;
  70507. };
  70508. }
  70509. // Mixins
  70510. interface Window {
  70511. mozIndexedDB: IDBFactory;
  70512. webkitIndexedDB: IDBFactory;
  70513. msIndexedDB: IDBFactory;
  70514. webkitURL: typeof URL;
  70515. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70516. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70517. WebGLRenderingContext: WebGLRenderingContext;
  70518. MSGesture: MSGesture;
  70519. CANNON: any;
  70520. AudioContext: AudioContext;
  70521. webkitAudioContext: AudioContext;
  70522. PointerEvent: any;
  70523. Math: Math;
  70524. Uint8Array: Uint8ArrayConstructor;
  70525. Float32Array: Float32ArrayConstructor;
  70526. mozURL: typeof URL;
  70527. msURL: typeof URL;
  70528. VRFrameData: any; // WebVR, from specs 1.1
  70529. DracoDecoderModule: any;
  70530. setImmediate(handler: (...args: any[]) => void): number;
  70531. }
  70532. interface HTMLCanvasElement {
  70533. requestPointerLock(): void;
  70534. msRequestPointerLock?(): void;
  70535. mozRequestPointerLock?(): void;
  70536. webkitRequestPointerLock?(): void;
  70537. /** Track wether a record is in progress */
  70538. isRecording: boolean;
  70539. /** Capture Stream method defined by some browsers */
  70540. captureStream(fps?: number): MediaStream;
  70541. }
  70542. interface CanvasRenderingContext2D {
  70543. msImageSmoothingEnabled: boolean;
  70544. }
  70545. interface MouseEvent {
  70546. mozMovementX: number;
  70547. mozMovementY: number;
  70548. webkitMovementX: number;
  70549. webkitMovementY: number;
  70550. msMovementX: number;
  70551. msMovementY: number;
  70552. }
  70553. interface Navigator {
  70554. mozGetVRDevices: (any: any) => any;
  70555. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70556. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70557. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70558. webkitGetGamepads(): Gamepad[];
  70559. msGetGamepads(): Gamepad[];
  70560. webkitGamepads(): Gamepad[];
  70561. }
  70562. interface HTMLVideoElement {
  70563. mozSrcObject: any;
  70564. }
  70565. interface Math {
  70566. fround(x: number): number;
  70567. imul(a: number, b: number): number;
  70568. }
  70569. interface WebGLRenderingContext {
  70570. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70571. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70572. vertexAttribDivisor(index: number, divisor: number): void;
  70573. createVertexArray(): any;
  70574. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70575. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70576. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70577. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70578. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70579. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70580. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70581. // Queries
  70582. createQuery(): WebGLQuery;
  70583. deleteQuery(query: WebGLQuery): void;
  70584. beginQuery(target: number, query: WebGLQuery): void;
  70585. endQuery(target: number): void;
  70586. getQueryParameter(query: WebGLQuery, pname: number): any;
  70587. getQuery(target: number, pname: number): any;
  70588. MAX_SAMPLES: number;
  70589. RGBA8: number;
  70590. READ_FRAMEBUFFER: number;
  70591. DRAW_FRAMEBUFFER: number;
  70592. UNIFORM_BUFFER: number;
  70593. HALF_FLOAT_OES: number;
  70594. RGBA16F: number;
  70595. RGBA32F: number;
  70596. R32F: number;
  70597. RG32F: number;
  70598. RGB32F: number;
  70599. R16F: number;
  70600. RG16F: number;
  70601. RGB16F: number;
  70602. RED: number;
  70603. RG: number;
  70604. R8: number;
  70605. RG8: number;
  70606. UNSIGNED_INT_24_8: number;
  70607. DEPTH24_STENCIL8: number;
  70608. MIN: number;
  70609. MAX: number;
  70610. /* Multiple Render Targets */
  70611. drawBuffers(buffers: number[]): void;
  70612. readBuffer(src: number): void;
  70613. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70614. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70615. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70616. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70617. // Occlusion Query
  70618. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70619. ANY_SAMPLES_PASSED: number;
  70620. QUERY_RESULT_AVAILABLE: number;
  70621. QUERY_RESULT: number;
  70622. }
  70623. interface WebGLProgram {
  70624. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70625. }
  70626. interface EXT_disjoint_timer_query {
  70627. QUERY_COUNTER_BITS_EXT: number;
  70628. TIME_ELAPSED_EXT: number;
  70629. TIMESTAMP_EXT: number;
  70630. GPU_DISJOINT_EXT: number;
  70631. QUERY_RESULT_EXT: number;
  70632. QUERY_RESULT_AVAILABLE_EXT: number;
  70633. queryCounterEXT(query: WebGLQuery, target: number): void;
  70634. createQueryEXT(): WebGLQuery;
  70635. beginQueryEXT(target: number, query: WebGLQuery): void;
  70636. endQueryEXT(target: number): void;
  70637. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70638. deleteQueryEXT(query: WebGLQuery): void;
  70639. }
  70640. interface WebGLUniformLocation {
  70641. _currentState: any;
  70642. }
  70643. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70644. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70645. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70646. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70647. interface WebGLRenderingContext {
  70648. readonly RASTERIZER_DISCARD: number;
  70649. readonly DEPTH_COMPONENT24: number;
  70650. readonly TEXTURE_3D: number;
  70651. readonly TEXTURE_2D_ARRAY: number;
  70652. readonly TEXTURE_COMPARE_FUNC: number;
  70653. readonly TEXTURE_COMPARE_MODE: number;
  70654. readonly COMPARE_REF_TO_TEXTURE: number;
  70655. readonly TEXTURE_WRAP_R: number;
  70656. readonly HALF_FLOAT: number;
  70657. readonly RGB8: number;
  70658. readonly RED_INTEGER: number;
  70659. readonly RG_INTEGER: number;
  70660. readonly RGB_INTEGER: number;
  70661. readonly RGBA_INTEGER: number;
  70662. readonly R8_SNORM: number;
  70663. readonly RG8_SNORM: number;
  70664. readonly RGB8_SNORM: number;
  70665. readonly RGBA8_SNORM: number;
  70666. readonly R8I: number;
  70667. readonly RG8I: number;
  70668. readonly RGB8I: number;
  70669. readonly RGBA8I: number;
  70670. readonly R8UI: number;
  70671. readonly RG8UI: number;
  70672. readonly RGB8UI: number;
  70673. readonly RGBA8UI: number;
  70674. readonly R16I: number;
  70675. readonly RG16I: number;
  70676. readonly RGB16I: number;
  70677. readonly RGBA16I: number;
  70678. readonly R16UI: number;
  70679. readonly RG16UI: number;
  70680. readonly RGB16UI: number;
  70681. readonly RGBA16UI: number;
  70682. readonly R32I: number;
  70683. readonly RG32I: number;
  70684. readonly RGB32I: number;
  70685. readonly RGBA32I: number;
  70686. readonly R32UI: number;
  70687. readonly RG32UI: number;
  70688. readonly RGB32UI: number;
  70689. readonly RGBA32UI: number;
  70690. readonly RGB10_A2UI: number;
  70691. readonly R11F_G11F_B10F: number;
  70692. readonly RGB9_E5: number;
  70693. readonly RGB10_A2: number;
  70694. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70695. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70696. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70697. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70698. readonly DEPTH_COMPONENT32F: number;
  70699. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70700. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70701. 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;
  70702. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70703. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70704. readonly TRANSFORM_FEEDBACK: number;
  70705. readonly INTERLEAVED_ATTRIBS: number;
  70706. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70707. createTransformFeedback(): WebGLTransformFeedback;
  70708. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70709. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70710. beginTransformFeedback(primitiveMode: number): void;
  70711. endTransformFeedback(): void;
  70712. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70713. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70714. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70715. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70716. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70717. }
  70718. interface ImageBitmap {
  70719. readonly width: number;
  70720. readonly height: number;
  70721. close(): void;
  70722. }
  70723. interface WebGLQuery extends WebGLObject {
  70724. }
  70725. declare var WebGLQuery: {
  70726. prototype: WebGLQuery;
  70727. new(): WebGLQuery;
  70728. };
  70729. interface WebGLSampler extends WebGLObject {
  70730. }
  70731. declare var WebGLSampler: {
  70732. prototype: WebGLSampler;
  70733. new(): WebGLSampler;
  70734. };
  70735. interface WebGLSync extends WebGLObject {
  70736. }
  70737. declare var WebGLSync: {
  70738. prototype: WebGLSync;
  70739. new(): WebGLSync;
  70740. };
  70741. interface WebGLTransformFeedback extends WebGLObject {
  70742. }
  70743. declare var WebGLTransformFeedback: {
  70744. prototype: WebGLTransformFeedback;
  70745. new(): WebGLTransformFeedback;
  70746. };
  70747. interface WebGLVertexArrayObject extends WebGLObject {
  70748. }
  70749. declare var WebGLVertexArrayObject: {
  70750. prototype: WebGLVertexArrayObject;
  70751. new(): WebGLVertexArrayObject;
  70752. };
  70753. // Type definitions for WebVR API
  70754. // Project: https://w3c.github.io/webvr/
  70755. // Definitions by: six a <https://github.com/lostfictions>
  70756. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70757. interface VRDisplay extends EventTarget {
  70758. /**
  70759. * Dictionary of capabilities describing the VRDisplay.
  70760. */
  70761. readonly capabilities: VRDisplayCapabilities;
  70762. /**
  70763. * z-depth defining the far plane of the eye view frustum
  70764. * enables mapping of values in the render target depth
  70765. * attachment to scene coordinates. Initially set to 10000.0.
  70766. */
  70767. depthFar: number;
  70768. /**
  70769. * z-depth defining the near plane of the eye view frustum
  70770. * enables mapping of values in the render target depth
  70771. * attachment to scene coordinates. Initially set to 0.01.
  70772. */
  70773. depthNear: number;
  70774. /**
  70775. * An identifier for this distinct VRDisplay. Used as an
  70776. * association point in the Gamepad API.
  70777. */
  70778. readonly displayId: number;
  70779. /**
  70780. * A display name, a user-readable name identifying it.
  70781. */
  70782. readonly displayName: string;
  70783. readonly isConnected: boolean;
  70784. readonly isPresenting: boolean;
  70785. /**
  70786. * If this VRDisplay supports room-scale experiences, the optional
  70787. * stage attribute contains details on the room-scale parameters.
  70788. */
  70789. readonly stageParameters: VRStageParameters | null;
  70790. /**
  70791. * Passing the value returned by `requestAnimationFrame` to
  70792. * `cancelAnimationFrame` will unregister the callback.
  70793. * @param handle Define the hanle of the request to cancel
  70794. */
  70795. cancelAnimationFrame(handle: number): void;
  70796. /**
  70797. * Stops presenting to the VRDisplay.
  70798. * @returns a promise to know when it stopped
  70799. */
  70800. exitPresent(): Promise<void>;
  70801. /**
  70802. * Return the current VREyeParameters for the given eye.
  70803. * @param whichEye Define the eye we want the parameter for
  70804. * @returns the eye parameters
  70805. */
  70806. getEyeParameters(whichEye: string): VREyeParameters;
  70807. /**
  70808. * Populates the passed VRFrameData with the information required to render
  70809. * the current frame.
  70810. * @param frameData Define the data structure to populate
  70811. * @returns true if ok otherwise false
  70812. */
  70813. getFrameData(frameData: VRFrameData): boolean;
  70814. /**
  70815. * Get the layers currently being presented.
  70816. * @returns the list of VR layers
  70817. */
  70818. getLayers(): VRLayer[];
  70819. /**
  70820. * Return a VRPose containing the future predicted pose of the VRDisplay
  70821. * when the current frame will be presented. The value returned will not
  70822. * change until JavaScript has returned control to the browser.
  70823. *
  70824. * The VRPose will contain the position, orientation, velocity,
  70825. * and acceleration of each of these properties.
  70826. * @returns the pose object
  70827. */
  70828. getPose(): VRPose;
  70829. /**
  70830. * Return the current instantaneous pose of the VRDisplay, with no
  70831. * prediction applied.
  70832. * @returns the current instantaneous pose
  70833. */
  70834. getImmediatePose(): VRPose;
  70835. /**
  70836. * The callback passed to `requestAnimationFrame` will be called
  70837. * any time a new frame should be rendered. When the VRDisplay is
  70838. * presenting the callback will be called at the native refresh
  70839. * rate of the HMD. When not presenting this function acts
  70840. * identically to how window.requestAnimationFrame acts. Content should
  70841. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70842. * asynchronously from other displays and at differing refresh rates.
  70843. * @param callback Define the eaction to run next frame
  70844. * @returns the request handle it
  70845. */
  70846. requestAnimationFrame(callback: FrameRequestCallback): number;
  70847. /**
  70848. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70849. * Repeat calls while already presenting will update the VRLayers being displayed.
  70850. * @param layers Define the list of layer to present
  70851. * @returns a promise to know when the request has been fulfilled
  70852. */
  70853. requestPresent(layers: VRLayer[]): Promise<void>;
  70854. /**
  70855. * Reset the pose for this display, treating its current position and
  70856. * orientation as the "origin/zero" values. VRPose.position,
  70857. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70858. * updated when calling resetPose(). This should be called in only
  70859. * sitting-space experiences.
  70860. */
  70861. resetPose(): void;
  70862. /**
  70863. * The VRLayer provided to the VRDisplay will be captured and presented
  70864. * in the HMD. Calling this function has the same effect on the source
  70865. * canvas as any other operation that uses its source image, and canvases
  70866. * created without preserveDrawingBuffer set to true will be cleared.
  70867. * @param pose Define the pose to submit
  70868. */
  70869. submitFrame(pose?: VRPose): void;
  70870. }
  70871. declare var VRDisplay: {
  70872. prototype: VRDisplay;
  70873. new(): VRDisplay;
  70874. };
  70875. interface VRLayer {
  70876. leftBounds?: number[] | Float32Array | null;
  70877. rightBounds?: number[] | Float32Array | null;
  70878. source?: HTMLCanvasElement | null;
  70879. }
  70880. interface VRDisplayCapabilities {
  70881. readonly canPresent: boolean;
  70882. readonly hasExternalDisplay: boolean;
  70883. readonly hasOrientation: boolean;
  70884. readonly hasPosition: boolean;
  70885. readonly maxLayers: number;
  70886. }
  70887. interface VREyeParameters {
  70888. /** @deprecated */
  70889. readonly fieldOfView: VRFieldOfView;
  70890. readonly offset: Float32Array;
  70891. readonly renderHeight: number;
  70892. readonly renderWidth: number;
  70893. }
  70894. interface VRFieldOfView {
  70895. readonly downDegrees: number;
  70896. readonly leftDegrees: number;
  70897. readonly rightDegrees: number;
  70898. readonly upDegrees: number;
  70899. }
  70900. interface VRFrameData {
  70901. readonly leftProjectionMatrix: Float32Array;
  70902. readonly leftViewMatrix: Float32Array;
  70903. readonly pose: VRPose;
  70904. readonly rightProjectionMatrix: Float32Array;
  70905. readonly rightViewMatrix: Float32Array;
  70906. readonly timestamp: number;
  70907. }
  70908. interface VRPose {
  70909. readonly angularAcceleration: Float32Array | null;
  70910. readonly angularVelocity: Float32Array | null;
  70911. readonly linearAcceleration: Float32Array | null;
  70912. readonly linearVelocity: Float32Array | null;
  70913. readonly orientation: Float32Array | null;
  70914. readonly position: Float32Array | null;
  70915. readonly timestamp: number;
  70916. }
  70917. interface VRStageParameters {
  70918. sittingToStandingTransform?: Float32Array;
  70919. sizeX?: number;
  70920. sizeY?: number;
  70921. }
  70922. interface Navigator {
  70923. getVRDisplays(): Promise<VRDisplay[]>;
  70924. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70925. }
  70926. interface Window {
  70927. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70928. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70929. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70930. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70931. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70932. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70933. }
  70934. interface Gamepad {
  70935. readonly displayId: number;
  70936. }
  70937. type XRSessionMode =
  70938. | "inline"
  70939. | "immersive-vr"
  70940. | "immersive-ar";
  70941. type XRReferenceSpaceType =
  70942. | "viewer"
  70943. | "local"
  70944. | "local-floor"
  70945. | "bounded-floor"
  70946. | "unbounded";
  70947. type XREnvironmentBlendMode =
  70948. | "opaque"
  70949. | "additive"
  70950. | "alpha-blend";
  70951. type XRVisibilityState =
  70952. | "visible"
  70953. | "visible-blurred"
  70954. | "hidden";
  70955. type XRHandedness =
  70956. | "none"
  70957. | "left"
  70958. | "right";
  70959. type XRTargetRayMode =
  70960. | "gaze"
  70961. | "tracked-pointer"
  70962. | "screen";
  70963. type XREye =
  70964. | "none"
  70965. | "left"
  70966. | "right";
  70967. type XREventType =
  70968. | "devicechange"
  70969. | "visibilitychange"
  70970. | "end"
  70971. | "inputsourceschange"
  70972. | "select"
  70973. | "selectstart"
  70974. | "selectend"
  70975. | "squeeze"
  70976. | "squeezestart"
  70977. | "squeezeend"
  70978. | "reset";
  70979. interface XRSpace extends EventTarget {
  70980. }
  70981. interface XRRenderState {
  70982. depthNear?: number;
  70983. depthFar?: number;
  70984. inlineVerticalFieldOfView?: number;
  70985. baseLayer?: XRWebGLLayer;
  70986. }
  70987. interface XRInputSource {
  70988. handedness: XRHandedness;
  70989. targetRayMode: XRTargetRayMode;
  70990. targetRaySpace: XRSpace;
  70991. gripSpace: XRSpace | undefined;
  70992. gamepad: Gamepad | undefined;
  70993. profiles: Array<string>;
  70994. }
  70995. interface XRSessionInit {
  70996. optionalFeatures?: XRReferenceSpaceType[];
  70997. requiredFeatures?: XRReferenceSpaceType[];
  70998. }
  70999. interface XRSession extends XRAnchorCreator {
  71000. addEventListener: Function;
  71001. removeEventListener: Function;
  71002. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  71003. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  71004. requestAnimationFrame: Function;
  71005. end(): Promise<void>;
  71006. renderState: XRRenderState;
  71007. inputSources: Array<XRInputSource>;
  71008. // hit test
  71009. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  71010. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  71011. // legacy AR hit test
  71012. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71013. // legacy plane detection
  71014. updateWorldTrackingState(options: {
  71015. planeDetectionState?: { enabled: boolean; }
  71016. }): void;
  71017. }
  71018. interface XRReferenceSpace extends XRSpace {
  71019. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  71020. onreset: any;
  71021. }
  71022. type XRPlaneSet = Set<XRPlane>;
  71023. type XRAnchorSet = Set<XRAnchor>;
  71024. interface XRFrame {
  71025. session: XRSession;
  71026. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  71027. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  71028. // AR
  71029. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  71030. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  71031. // Anchors
  71032. trackedAnchors?: XRAnchorSet;
  71033. // Planes
  71034. worldInformation: {
  71035. detectedPlanes?: XRPlaneSet;
  71036. };
  71037. }
  71038. interface XRViewerPose extends XRPose {
  71039. views: Array<XRView>;
  71040. }
  71041. interface XRPose {
  71042. transform: XRRigidTransform;
  71043. emulatedPosition: boolean;
  71044. }
  71045. interface XRWebGLLayerOptions {
  71046. antialias?: boolean;
  71047. depth?: boolean;
  71048. stencil?: boolean;
  71049. alpha?: boolean;
  71050. multiview?: boolean;
  71051. framebufferScaleFactor?: number;
  71052. }
  71053. declare var XRWebGLLayer: {
  71054. prototype: XRWebGLLayer;
  71055. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  71056. };
  71057. interface XRWebGLLayer {
  71058. framebuffer: WebGLFramebuffer;
  71059. framebufferWidth: number;
  71060. framebufferHeight: number;
  71061. getViewport: Function;
  71062. }
  71063. declare class XRRigidTransform {
  71064. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  71065. position: DOMPointReadOnly;
  71066. orientation: DOMPointReadOnly;
  71067. matrix: Float32Array;
  71068. inverse: XRRigidTransform;
  71069. }
  71070. interface XRView {
  71071. eye: XREye;
  71072. projectionMatrix: Float32Array;
  71073. transform: XRRigidTransform;
  71074. }
  71075. interface XRInputSourceChangeEvent {
  71076. session: XRSession;
  71077. removed: Array<XRInputSource>;
  71078. added: Array<XRInputSource>;
  71079. }
  71080. interface XRInputSourceEvent extends Event {
  71081. readonly frame: XRFrame;
  71082. readonly inputSource: XRInputSource;
  71083. }
  71084. // Experimental(er) features
  71085. declare class XRRay {
  71086. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  71087. origin: DOMPointReadOnly;
  71088. direction: DOMPointReadOnly;
  71089. matrix: Float32Array;
  71090. }
  71091. declare enum XRHitTestTrackableType {
  71092. "point",
  71093. "plane"
  71094. }
  71095. interface XRHitResult {
  71096. hitMatrix: Float32Array;
  71097. }
  71098. interface XRTransientInputHitTestResult {
  71099. readonly inputSource: XRInputSource;
  71100. readonly results: Array<XRHitTestResult>;
  71101. }
  71102. interface XRHitTestResult {
  71103. getPose(baseSpace: XRSpace): XRPose | undefined;
  71104. }
  71105. interface XRHitTestSource {
  71106. cancel(): void;
  71107. }
  71108. interface XRTransientInputHitTestSource {
  71109. cancel(): void;
  71110. }
  71111. interface XRHitTestOptionsInit {
  71112. space: XRSpace;
  71113. entityTypes?: Array<XRHitTestTrackableType>;
  71114. offsetRay?: XRRay;
  71115. }
  71116. interface XRTransientInputHitTestOptionsInit {
  71117. profile: string;
  71118. entityTypes?: Array<XRHitTestTrackableType>;
  71119. offsetRay?: XRRay;
  71120. }
  71121. interface XRAnchor {
  71122. // remove?
  71123. id?: string;
  71124. anchorSpace: XRSpace;
  71125. lastChangedTime: number;
  71126. detach(): void;
  71127. }
  71128. interface XRPlane extends XRAnchorCreator {
  71129. orientation: "Horizontal" | "Vertical";
  71130. planeSpace: XRSpace;
  71131. polygon: Array<DOMPointReadOnly>;
  71132. lastChangedTime: number;
  71133. }
  71134. interface XRAnchorCreator {
  71135. // AR Anchors
  71136. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71137. }
  71138. /**
  71139. * @ignore
  71140. */
  71141. declare module BABYLON.GLTF2.Exporter {
  71142. }
  71143. /**
  71144. * @ignore
  71145. */
  71146. declare module BABYLON.GLTF1 {
  71147. }
  71148. declare module BABYLON.GUI {
  71149. /**
  71150. * Class used to specific a value and its associated unit
  71151. */
  71152. export class ValueAndUnit {
  71153. /** defines the unit to store */
  71154. unit: number;
  71155. /** defines a boolean indicating if the value can be negative */
  71156. negativeValueAllowed: boolean;
  71157. private _value;
  71158. private _originalUnit;
  71159. /**
  71160. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71161. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71162. */
  71163. ignoreAdaptiveScaling: boolean;
  71164. /**
  71165. * Creates a new ValueAndUnit
  71166. * @param value defines the value to store
  71167. * @param unit defines the unit to store
  71168. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71169. */
  71170. constructor(value: number,
  71171. /** defines the unit to store */
  71172. unit?: number,
  71173. /** defines a boolean indicating if the value can be negative */
  71174. negativeValueAllowed?: boolean);
  71175. /** Gets a boolean indicating if the value is a percentage */
  71176. get isPercentage(): boolean;
  71177. /** Gets a boolean indicating if the value is store as pixel */
  71178. get isPixel(): boolean;
  71179. /** Gets direct internal value */
  71180. get internalValue(): number;
  71181. /**
  71182. * Gets value as pixel
  71183. * @param host defines the root host
  71184. * @param refValue defines the reference value for percentages
  71185. * @returns the value as pixel
  71186. */
  71187. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71188. /**
  71189. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71190. * @param value defines the value to store
  71191. * @param unit defines the unit to store
  71192. * @returns the current ValueAndUnit
  71193. */
  71194. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71195. /**
  71196. * Gets the value accordingly to its unit
  71197. * @param host defines the root host
  71198. * @returns the value
  71199. */
  71200. getValue(host: AdvancedDynamicTexture): number;
  71201. /**
  71202. * Gets a string representation of the value
  71203. * @param host defines the root host
  71204. * @param decimals defines an optional number of decimals to display
  71205. * @returns a string
  71206. */
  71207. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71208. /**
  71209. * Store a value parsed from a string
  71210. * @param source defines the source string
  71211. * @returns true if the value was successfully parsed
  71212. */
  71213. fromString(source: string | number): boolean;
  71214. private static _Regex;
  71215. private static _UNITMODE_PERCENTAGE;
  71216. private static _UNITMODE_PIXEL;
  71217. /** UNITMODE_PERCENTAGE */
  71218. static get UNITMODE_PERCENTAGE(): number;
  71219. /** UNITMODE_PIXEL */
  71220. static get UNITMODE_PIXEL(): number;
  71221. }
  71222. }
  71223. declare module BABYLON.GUI {
  71224. /**
  71225. * Define a style used by control to automatically setup properties based on a template.
  71226. * Only support font related properties so far
  71227. */
  71228. export class Style implements BABYLON.IDisposable {
  71229. private _fontFamily;
  71230. private _fontStyle;
  71231. private _fontWeight;
  71232. /** @hidden */
  71233. _host: AdvancedDynamicTexture;
  71234. /** @hidden */
  71235. _fontSize: ValueAndUnit;
  71236. /**
  71237. * BABYLON.Observable raised when the style values are changed
  71238. */
  71239. onChangedObservable: BABYLON.Observable<Style>;
  71240. /**
  71241. * Creates a new style object
  71242. * @param host defines the AdvancedDynamicTexture which hosts this style
  71243. */
  71244. constructor(host: AdvancedDynamicTexture);
  71245. /**
  71246. * Gets or sets the font size
  71247. */
  71248. get fontSize(): string | number;
  71249. set fontSize(value: string | number);
  71250. /**
  71251. * Gets or sets the font family
  71252. */
  71253. get fontFamily(): string;
  71254. set fontFamily(value: string);
  71255. /**
  71256. * Gets or sets the font style
  71257. */
  71258. get fontStyle(): string;
  71259. set fontStyle(value: string);
  71260. /** Gets or sets font weight */
  71261. get fontWeight(): string;
  71262. set fontWeight(value: string);
  71263. /** Dispose all associated resources */
  71264. dispose(): void;
  71265. }
  71266. }
  71267. declare module BABYLON.GUI {
  71268. /**
  71269. * Class used to transport BABYLON.Vector2 information for pointer events
  71270. */
  71271. export class Vector2WithInfo extends BABYLON.Vector2 {
  71272. /** defines the current mouse button index */
  71273. buttonIndex: number;
  71274. /**
  71275. * Creates a new Vector2WithInfo
  71276. * @param source defines the vector2 data to transport
  71277. * @param buttonIndex defines the current mouse button index
  71278. */
  71279. constructor(source: BABYLON.Vector2,
  71280. /** defines the current mouse button index */
  71281. buttonIndex?: number);
  71282. }
  71283. /** Class used to provide 2D matrix features */
  71284. export class Matrix2D {
  71285. /** Gets the internal array of 6 floats used to store matrix data */
  71286. m: Float32Array;
  71287. /**
  71288. * Creates a new matrix
  71289. * @param m00 defines value for (0, 0)
  71290. * @param m01 defines value for (0, 1)
  71291. * @param m10 defines value for (1, 0)
  71292. * @param m11 defines value for (1, 1)
  71293. * @param m20 defines value for (2, 0)
  71294. * @param m21 defines value for (2, 1)
  71295. */
  71296. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71297. /**
  71298. * Fills the matrix from direct values
  71299. * @param m00 defines value for (0, 0)
  71300. * @param m01 defines value for (0, 1)
  71301. * @param m10 defines value for (1, 0)
  71302. * @param m11 defines value for (1, 1)
  71303. * @param m20 defines value for (2, 0)
  71304. * @param m21 defines value for (2, 1)
  71305. * @returns the current modified matrix
  71306. */
  71307. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71308. /**
  71309. * Gets matrix determinant
  71310. * @returns the determinant
  71311. */
  71312. determinant(): number;
  71313. /**
  71314. * Inverses the matrix and stores it in a target matrix
  71315. * @param result defines the target matrix
  71316. * @returns the current matrix
  71317. */
  71318. invertToRef(result: Matrix2D): Matrix2D;
  71319. /**
  71320. * Multiplies the current matrix with another one
  71321. * @param other defines the second operand
  71322. * @param result defines the target matrix
  71323. * @returns the current matrix
  71324. */
  71325. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71326. /**
  71327. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71328. * @param x defines the x coordinate to transform
  71329. * @param y defines the x coordinate to transform
  71330. * @param result defines the target vector2
  71331. * @returns the current matrix
  71332. */
  71333. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71334. /**
  71335. * Creates an identity matrix
  71336. * @returns a new matrix
  71337. */
  71338. static Identity(): Matrix2D;
  71339. /**
  71340. * Creates a translation matrix and stores it in a target matrix
  71341. * @param x defines the x coordinate of the translation
  71342. * @param y defines the y coordinate of the translation
  71343. * @param result defines the target matrix
  71344. */
  71345. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71346. /**
  71347. * Creates a scaling matrix and stores it in a target matrix
  71348. * @param x defines the x coordinate of the scaling
  71349. * @param y defines the y coordinate of the scaling
  71350. * @param result defines the target matrix
  71351. */
  71352. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71353. /**
  71354. * Creates a rotation matrix and stores it in a target matrix
  71355. * @param angle defines the rotation angle
  71356. * @param result defines the target matrix
  71357. */
  71358. static RotationToRef(angle: number, result: Matrix2D): void;
  71359. private static _TempPreTranslationMatrix;
  71360. private static _TempPostTranslationMatrix;
  71361. private static _TempRotationMatrix;
  71362. private static _TempScalingMatrix;
  71363. private static _TempCompose0;
  71364. private static _TempCompose1;
  71365. private static _TempCompose2;
  71366. /**
  71367. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71368. * @param tx defines the x coordinate of the translation
  71369. * @param ty defines the y coordinate of the translation
  71370. * @param angle defines the rotation angle
  71371. * @param scaleX defines the x coordinate of the scaling
  71372. * @param scaleY defines the y coordinate of the scaling
  71373. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71374. * @param result defines the target matrix
  71375. */
  71376. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71377. }
  71378. }
  71379. declare module BABYLON.GUI {
  71380. /**
  71381. * Class used to store 2D control sizes
  71382. */
  71383. export class Measure {
  71384. /** defines left coordinate */
  71385. left: number;
  71386. /** defines top coordinate */
  71387. top: number;
  71388. /** defines width dimension */
  71389. width: number;
  71390. /** defines height dimension */
  71391. height: number;
  71392. /**
  71393. * Creates a new measure
  71394. * @param left defines left coordinate
  71395. * @param top defines top coordinate
  71396. * @param width defines width dimension
  71397. * @param height defines height dimension
  71398. */
  71399. constructor(
  71400. /** defines left coordinate */
  71401. left: number,
  71402. /** defines top coordinate */
  71403. top: number,
  71404. /** defines width dimension */
  71405. width: number,
  71406. /** defines height dimension */
  71407. height: number);
  71408. /**
  71409. * Copy from another measure
  71410. * @param other defines the other measure to copy from
  71411. */
  71412. copyFrom(other: Measure): void;
  71413. /**
  71414. * Copy from a group of 4 floats
  71415. * @param left defines left coordinate
  71416. * @param top defines top coordinate
  71417. * @param width defines width dimension
  71418. * @param height defines height dimension
  71419. */
  71420. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71421. /**
  71422. * Computes the axis aligned bounding box measure for two given measures
  71423. * @param a Input measure
  71424. * @param b Input measure
  71425. * @param result the resulting bounding measure
  71426. */
  71427. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71428. /**
  71429. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71430. * @param transform the matrix to transform the measure before computing the AABB
  71431. * @param result the resulting AABB
  71432. */
  71433. transformToRef(transform: Matrix2D, result: Measure): void;
  71434. /**
  71435. * Check equality between this measure and another one
  71436. * @param other defines the other measures
  71437. * @returns true if both measures are equals
  71438. */
  71439. isEqualsTo(other: Measure): boolean;
  71440. /**
  71441. * Creates an empty measure
  71442. * @returns a new measure
  71443. */
  71444. static Empty(): Measure;
  71445. }
  71446. }
  71447. declare module BABYLON.GUI {
  71448. /**
  71449. * Interface used to define a control that can receive focus
  71450. */
  71451. export interface IFocusableControl {
  71452. /**
  71453. * Function called when the control receives the focus
  71454. */
  71455. onFocus(): void;
  71456. /**
  71457. * Function called when the control loses the focus
  71458. */
  71459. onBlur(): void;
  71460. /**
  71461. * Function called to let the control handle keyboard events
  71462. * @param evt defines the current keyboard event
  71463. */
  71464. processKeyboard(evt: KeyboardEvent): void;
  71465. /**
  71466. * Function called to get the list of controls that should not steal the focus from this control
  71467. * @returns an array of controls
  71468. */
  71469. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71470. }
  71471. /**
  71472. * Class used to create texture to support 2D GUI elements
  71473. * @see http://doc.babylonjs.com/how_to/gui
  71474. */
  71475. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71476. private _isDirty;
  71477. private _renderObserver;
  71478. private _resizeObserver;
  71479. private _preKeyboardObserver;
  71480. private _pointerMoveObserver;
  71481. private _pointerObserver;
  71482. private _canvasPointerOutObserver;
  71483. private _background;
  71484. /** @hidden */
  71485. _rootContainer: Container;
  71486. /** @hidden */
  71487. _lastPickedControl: Control;
  71488. /** @hidden */
  71489. _lastControlOver: {
  71490. [pointerId: number]: Control;
  71491. };
  71492. /** @hidden */
  71493. _lastControlDown: {
  71494. [pointerId: number]: Control;
  71495. };
  71496. /** @hidden */
  71497. _capturingControl: {
  71498. [pointerId: number]: Control;
  71499. };
  71500. /** @hidden */
  71501. _shouldBlockPointer: boolean;
  71502. /** @hidden */
  71503. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71504. /** @hidden */
  71505. _linkedControls: Control[];
  71506. private _isFullscreen;
  71507. private _fullscreenViewport;
  71508. private _idealWidth;
  71509. private _idealHeight;
  71510. private _useSmallestIdeal;
  71511. private _renderAtIdealSize;
  71512. private _focusedControl;
  71513. private _blockNextFocusCheck;
  71514. private _renderScale;
  71515. private _rootElement;
  71516. private _cursorChanged;
  71517. private _defaultMousePointerId;
  71518. /** @hidden */
  71519. _numLayoutCalls: number;
  71520. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71521. get numLayoutCalls(): number;
  71522. /** @hidden */
  71523. _numRenderCalls: number;
  71524. /** Gets the number of render calls made the last time the ADT has been rendered */
  71525. get numRenderCalls(): number;
  71526. /**
  71527. * Define type to string to ensure compatibility across browsers
  71528. * Safari doesn't support DataTransfer constructor
  71529. */
  71530. private _clipboardData;
  71531. /**
  71532. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71533. */
  71534. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71535. /**
  71536. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71537. */
  71538. onControlPickedObservable: BABYLON.Observable<Control>;
  71539. /**
  71540. * BABYLON.Observable event triggered before layout is evaluated
  71541. */
  71542. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71543. /**
  71544. * BABYLON.Observable event triggered after the layout was evaluated
  71545. */
  71546. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71547. /**
  71548. * BABYLON.Observable event triggered before the texture is rendered
  71549. */
  71550. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71551. /**
  71552. * BABYLON.Observable event triggered after the texture was rendered
  71553. */
  71554. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71555. /**
  71556. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71557. */
  71558. premulAlpha: boolean;
  71559. /**
  71560. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71561. * Useful when you want more antialiasing
  71562. */
  71563. get renderScale(): number;
  71564. set renderScale(value: number);
  71565. /** Gets or sets the background color */
  71566. get background(): string;
  71567. set background(value: string);
  71568. /**
  71569. * Gets or sets the ideal width used to design controls.
  71570. * The GUI will then rescale everything accordingly
  71571. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71572. */
  71573. get idealWidth(): number;
  71574. set idealWidth(value: number);
  71575. /**
  71576. * Gets or sets the ideal height used to design controls.
  71577. * The GUI will then rescale everything accordingly
  71578. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71579. */
  71580. get idealHeight(): number;
  71581. set idealHeight(value: number);
  71582. /**
  71583. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71584. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71585. */
  71586. get useSmallestIdeal(): boolean;
  71587. set useSmallestIdeal(value: boolean);
  71588. /**
  71589. * Gets or sets a boolean indicating if adaptive scaling must be used
  71590. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71591. */
  71592. get renderAtIdealSize(): boolean;
  71593. set renderAtIdealSize(value: boolean);
  71594. /**
  71595. * Gets the ratio used when in "ideal mode"
  71596. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71597. * */
  71598. get idealRatio(): number;
  71599. /**
  71600. * Gets the underlying layer used to render the texture when in fullscreen mode
  71601. */
  71602. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71603. /**
  71604. * Gets the root container control
  71605. */
  71606. get rootContainer(): Container;
  71607. /**
  71608. * Returns an array containing the root container.
  71609. * This is mostly used to let the Inspector introspects the ADT
  71610. * @returns an array containing the rootContainer
  71611. */
  71612. getChildren(): Array<Container>;
  71613. /**
  71614. * Will return all controls that are inside this texture
  71615. * @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
  71616. * @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
  71617. * @return all child controls
  71618. */
  71619. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71620. /**
  71621. * Gets or sets the current focused control
  71622. */
  71623. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71624. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71625. /**
  71626. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71627. */
  71628. get isForeground(): boolean;
  71629. set isForeground(value: boolean);
  71630. /**
  71631. * Gets or set information about clipboardData
  71632. */
  71633. get clipboardData(): string;
  71634. set clipboardData(value: string);
  71635. /**
  71636. * Creates a new AdvancedDynamicTexture
  71637. * @param name defines the name of the texture
  71638. * @param width defines the width of the texture
  71639. * @param height defines the height of the texture
  71640. * @param scene defines the hosting scene
  71641. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71642. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71643. */
  71644. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71645. /**
  71646. * Get the current class name of the texture useful for serialization or dynamic coding.
  71647. * @returns "AdvancedDynamicTexture"
  71648. */
  71649. getClassName(): string;
  71650. /**
  71651. * Function used to execute a function on all controls
  71652. * @param func defines the function to execute
  71653. * @param container defines the container where controls belong. If null the root container will be used
  71654. */
  71655. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71656. private _useInvalidateRectOptimization;
  71657. /**
  71658. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71659. */
  71660. get useInvalidateRectOptimization(): boolean;
  71661. set useInvalidateRectOptimization(value: boolean);
  71662. private _invalidatedRectangle;
  71663. /**
  71664. * Invalidates a rectangle area on the gui texture
  71665. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71666. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71667. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71668. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71669. */
  71670. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71671. /**
  71672. * Marks the texture as dirty forcing a complete update
  71673. */
  71674. markAsDirty(): void;
  71675. /**
  71676. * Helper function used to create a new style
  71677. * @returns a new style
  71678. * @see http://doc.babylonjs.com/how_to/gui#styles
  71679. */
  71680. createStyle(): Style;
  71681. /**
  71682. * Adds a new control to the root container
  71683. * @param control defines the control to add
  71684. * @returns the current texture
  71685. */
  71686. addControl(control: Control): AdvancedDynamicTexture;
  71687. /**
  71688. * Removes a control from the root container
  71689. * @param control defines the control to remove
  71690. * @returns the current texture
  71691. */
  71692. removeControl(control: Control): AdvancedDynamicTexture;
  71693. /**
  71694. * Release all resources
  71695. */
  71696. dispose(): void;
  71697. private _onResize;
  71698. /** @hidden */
  71699. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71700. /**
  71701. * Get screen coordinates for a vector3
  71702. * @param position defines the position to project
  71703. * @param worldMatrix defines the world matrix to use
  71704. * @returns the projected position
  71705. */
  71706. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71707. private _checkUpdate;
  71708. private _clearMeasure;
  71709. private _render;
  71710. /** @hidden */
  71711. _changeCursor(cursor: string): void;
  71712. /** @hidden */
  71713. _registerLastControlDown(control: Control, pointerId: number): void;
  71714. private _doPicking;
  71715. /** @hidden */
  71716. _cleanControlAfterRemovalFromList(list: {
  71717. [pointerId: number]: Control;
  71718. }, control: Control): void;
  71719. /** @hidden */
  71720. _cleanControlAfterRemoval(control: Control): void;
  71721. /** Attach to all scene events required to support pointer events */
  71722. attach(): void;
  71723. /** @hidden */
  71724. private onClipboardCopy;
  71725. /** @hidden */
  71726. private onClipboardCut;
  71727. /** @hidden */
  71728. private onClipboardPaste;
  71729. /**
  71730. * Register the clipboard Events onto the canvas
  71731. */
  71732. registerClipboardEvents(): void;
  71733. /**
  71734. * Unregister the clipboard Events from the canvas
  71735. */
  71736. unRegisterClipboardEvents(): void;
  71737. /**
  71738. * Connect the texture to a hosting mesh to enable interactions
  71739. * @param mesh defines the mesh to attach to
  71740. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71741. */
  71742. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71743. /**
  71744. * Move the focus to a specific control
  71745. * @param control defines the control which will receive the focus
  71746. */
  71747. moveFocusToControl(control: IFocusableControl): void;
  71748. private _manageFocus;
  71749. private _attachToOnPointerOut;
  71750. /**
  71751. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71752. * @param mesh defines the mesh which will receive the texture
  71753. * @param width defines the texture width (1024 by default)
  71754. * @param height defines the texture height (1024 by default)
  71755. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71756. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71757. * @returns a new AdvancedDynamicTexture
  71758. */
  71759. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71760. /**
  71761. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71762. * In this mode the texture will rely on a layer for its rendering.
  71763. * This allows it to be treated like any other layer.
  71764. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71765. * LayerMask is set through advancedTexture.layer.layerMask
  71766. * @param name defines name for the texture
  71767. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71768. * @param scene defines the hsoting scene
  71769. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71770. * @returns a new AdvancedDynamicTexture
  71771. */
  71772. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71773. }
  71774. }
  71775. declare module BABYLON.GUI {
  71776. /**
  71777. * Root class used for all 2D controls
  71778. * @see http://doc.babylonjs.com/how_to/gui#controls
  71779. */
  71780. export class Control {
  71781. /** defines the name of the control */
  71782. name?: string | undefined;
  71783. /**
  71784. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71785. */
  71786. static AllowAlphaInheritance: boolean;
  71787. private _alpha;
  71788. private _alphaSet;
  71789. private _zIndex;
  71790. /** @hidden */
  71791. _host: AdvancedDynamicTexture;
  71792. /** Gets or sets the control parent */
  71793. parent: BABYLON.Nullable<Container>;
  71794. /** @hidden */
  71795. _currentMeasure: Measure;
  71796. private _fontFamily;
  71797. private _fontStyle;
  71798. private _fontWeight;
  71799. private _fontSize;
  71800. private _font;
  71801. /** @hidden */
  71802. _width: ValueAndUnit;
  71803. /** @hidden */
  71804. _height: ValueAndUnit;
  71805. /** @hidden */
  71806. protected _fontOffset: {
  71807. ascent: number;
  71808. height: number;
  71809. descent: number;
  71810. };
  71811. private _color;
  71812. private _style;
  71813. private _styleObserver;
  71814. /** @hidden */
  71815. protected _horizontalAlignment: number;
  71816. /** @hidden */
  71817. protected _verticalAlignment: number;
  71818. /** @hidden */
  71819. protected _isDirty: boolean;
  71820. /** @hidden */
  71821. protected _wasDirty: boolean;
  71822. /** @hidden */
  71823. _tempParentMeasure: Measure;
  71824. /** @hidden */
  71825. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71826. /** @hidden */
  71827. protected _cachedParentMeasure: Measure;
  71828. private _paddingLeft;
  71829. private _paddingRight;
  71830. private _paddingTop;
  71831. private _paddingBottom;
  71832. /** @hidden */
  71833. _left: ValueAndUnit;
  71834. /** @hidden */
  71835. _top: ValueAndUnit;
  71836. private _scaleX;
  71837. private _scaleY;
  71838. private _rotation;
  71839. private _transformCenterX;
  71840. private _transformCenterY;
  71841. /** @hidden */
  71842. _transformMatrix: Matrix2D;
  71843. /** @hidden */
  71844. protected _invertTransformMatrix: Matrix2D;
  71845. /** @hidden */
  71846. protected _transformedPosition: BABYLON.Vector2;
  71847. private _isMatrixDirty;
  71848. private _cachedOffsetX;
  71849. private _cachedOffsetY;
  71850. private _isVisible;
  71851. private _isHighlighted;
  71852. /** @hidden */
  71853. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71854. private _fontSet;
  71855. private _dummyVector2;
  71856. private _downCount;
  71857. private _enterCount;
  71858. private _doNotRender;
  71859. private _downPointerIds;
  71860. protected _isEnabled: boolean;
  71861. protected _disabledColor: string;
  71862. protected _disabledColorItem: string;
  71863. /** @hidden */
  71864. protected _rebuildLayout: boolean;
  71865. /** @hidden */
  71866. _customData: any;
  71867. /** @hidden */
  71868. _isClipped: boolean;
  71869. /** @hidden */
  71870. _automaticSize: boolean;
  71871. /** @hidden */
  71872. _tag: any;
  71873. /**
  71874. * 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
  71875. */
  71876. uniqueId: number;
  71877. /**
  71878. * Gets or sets an object used to store user defined information for the node
  71879. */
  71880. metadata: any;
  71881. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71882. isHitTestVisible: boolean;
  71883. /** Gets or sets a boolean indicating if the control can block pointer events */
  71884. isPointerBlocker: boolean;
  71885. /** Gets or sets a boolean indicating if the control can be focusable */
  71886. isFocusInvisible: boolean;
  71887. /**
  71888. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71889. * 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
  71890. */
  71891. clipChildren: boolean;
  71892. /**
  71893. * Gets or sets a boolean indicating that control content must be clipped
  71894. * 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
  71895. */
  71896. clipContent: boolean;
  71897. /**
  71898. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71899. */
  71900. useBitmapCache: boolean;
  71901. private _cacheData;
  71902. private _shadowOffsetX;
  71903. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71904. get shadowOffsetX(): number;
  71905. set shadowOffsetX(value: number);
  71906. private _shadowOffsetY;
  71907. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71908. get shadowOffsetY(): number;
  71909. set shadowOffsetY(value: number);
  71910. private _shadowBlur;
  71911. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71912. get shadowBlur(): number;
  71913. set shadowBlur(value: number);
  71914. private _shadowColor;
  71915. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71916. get shadowColor(): string;
  71917. set shadowColor(value: string);
  71918. /** Gets or sets the cursor to use when the control is hovered */
  71919. hoverCursor: string;
  71920. /** @hidden */
  71921. protected _linkOffsetX: ValueAndUnit;
  71922. /** @hidden */
  71923. protected _linkOffsetY: ValueAndUnit;
  71924. /** Gets the control type name */
  71925. get typeName(): string;
  71926. /**
  71927. * Get the current class name of the control.
  71928. * @returns current class name
  71929. */
  71930. getClassName(): string;
  71931. /**
  71932. * An event triggered when pointer wheel is scrolled
  71933. */
  71934. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71935. /**
  71936. * An event triggered when the pointer move over the control.
  71937. */
  71938. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71939. /**
  71940. * An event triggered when the pointer move out of the control.
  71941. */
  71942. onPointerOutObservable: BABYLON.Observable<Control>;
  71943. /**
  71944. * An event triggered when the pointer taps the control
  71945. */
  71946. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71947. /**
  71948. * An event triggered when pointer up
  71949. */
  71950. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71951. /**
  71952. * An event triggered when a control is clicked on
  71953. */
  71954. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71955. /**
  71956. * An event triggered when pointer enters the control
  71957. */
  71958. onPointerEnterObservable: BABYLON.Observable<Control>;
  71959. /**
  71960. * An event triggered when the control is marked as dirty
  71961. */
  71962. onDirtyObservable: BABYLON.Observable<Control>;
  71963. /**
  71964. * An event triggered before drawing the control
  71965. */
  71966. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71967. /**
  71968. * An event triggered after the control was drawn
  71969. */
  71970. onAfterDrawObservable: BABYLON.Observable<Control>;
  71971. /**
  71972. * Get the hosting AdvancedDynamicTexture
  71973. */
  71974. get host(): AdvancedDynamicTexture;
  71975. /** Gets or set information about font offsets (used to render and align text) */
  71976. get fontOffset(): {
  71977. ascent: number;
  71978. height: number;
  71979. descent: number;
  71980. };
  71981. set fontOffset(offset: {
  71982. ascent: number;
  71983. height: number;
  71984. descent: number;
  71985. });
  71986. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71987. get alpha(): number;
  71988. set alpha(value: number);
  71989. /**
  71990. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71991. */
  71992. get isHighlighted(): boolean;
  71993. set isHighlighted(value: boolean);
  71994. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71995. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71996. */
  71997. get scaleX(): number;
  71998. set scaleX(value: number);
  71999. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  72000. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72001. */
  72002. get scaleY(): number;
  72003. set scaleY(value: number);
  72004. /** Gets or sets the rotation angle (0 by default)
  72005. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72006. */
  72007. get rotation(): number;
  72008. set rotation(value: number);
  72009. /** Gets or sets the transformation center on Y axis (0 by default)
  72010. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72011. */
  72012. get transformCenterY(): number;
  72013. set transformCenterY(value: number);
  72014. /** Gets or sets the transformation center on X axis (0 by default)
  72015. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72016. */
  72017. get transformCenterX(): number;
  72018. set transformCenterX(value: number);
  72019. /**
  72020. * Gets or sets the horizontal alignment
  72021. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72022. */
  72023. get horizontalAlignment(): number;
  72024. set horizontalAlignment(value: number);
  72025. /**
  72026. * Gets or sets the vertical alignment
  72027. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72028. */
  72029. get verticalAlignment(): number;
  72030. set verticalAlignment(value: number);
  72031. /**
  72032. * Gets or sets control width
  72033. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72034. */
  72035. get width(): string | number;
  72036. set width(value: string | number);
  72037. /**
  72038. * Gets or sets the control width in pixel
  72039. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72040. */
  72041. get widthInPixels(): number;
  72042. set widthInPixels(value: number);
  72043. /**
  72044. * Gets or sets control height
  72045. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72046. */
  72047. get height(): string | number;
  72048. set height(value: string | number);
  72049. /**
  72050. * Gets or sets control height in pixel
  72051. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72052. */
  72053. get heightInPixels(): number;
  72054. set heightInPixels(value: number);
  72055. /** Gets or set font family */
  72056. get fontFamily(): string;
  72057. set fontFamily(value: string);
  72058. /** Gets or sets font style */
  72059. get fontStyle(): string;
  72060. set fontStyle(value: string);
  72061. /** Gets or sets font weight */
  72062. get fontWeight(): string;
  72063. set fontWeight(value: string);
  72064. /**
  72065. * Gets or sets style
  72066. * @see http://doc.babylonjs.com/how_to/gui#styles
  72067. */
  72068. get style(): BABYLON.Nullable<Style>;
  72069. set style(value: BABYLON.Nullable<Style>);
  72070. /** @hidden */
  72071. get _isFontSizeInPercentage(): boolean;
  72072. /** Gets or sets font size in pixels */
  72073. get fontSizeInPixels(): number;
  72074. set fontSizeInPixels(value: number);
  72075. /** Gets or sets font size */
  72076. get fontSize(): string | number;
  72077. set fontSize(value: string | number);
  72078. /** Gets or sets foreground color */
  72079. get color(): string;
  72080. set color(value: string);
  72081. /** Gets or sets z index which is used to reorder controls on the z axis */
  72082. get zIndex(): number;
  72083. set zIndex(value: number);
  72084. /** Gets or sets a boolean indicating if the control can be rendered */
  72085. get notRenderable(): boolean;
  72086. set notRenderable(value: boolean);
  72087. /** Gets or sets a boolean indicating if the control is visible */
  72088. get isVisible(): boolean;
  72089. set isVisible(value: boolean);
  72090. /** Gets a boolean indicating that the control needs to update its rendering */
  72091. get isDirty(): boolean;
  72092. /**
  72093. * Gets the current linked mesh (or null if none)
  72094. */
  72095. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72096. /**
  72097. * Gets or sets a value indicating the padding to use on the left of the control
  72098. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72099. */
  72100. get paddingLeft(): string | number;
  72101. set paddingLeft(value: string | number);
  72102. /**
  72103. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  72104. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72105. */
  72106. get paddingLeftInPixels(): number;
  72107. set paddingLeftInPixels(value: number);
  72108. /**
  72109. * Gets or sets a value indicating the padding to use on the right of the control
  72110. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72111. */
  72112. get paddingRight(): string | number;
  72113. set paddingRight(value: string | number);
  72114. /**
  72115. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72116. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72117. */
  72118. get paddingRightInPixels(): number;
  72119. set paddingRightInPixels(value: number);
  72120. /**
  72121. * Gets or sets a value indicating the padding to use on the top of the control
  72122. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72123. */
  72124. get paddingTop(): string | number;
  72125. set paddingTop(value: string | number);
  72126. /**
  72127. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72128. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72129. */
  72130. get paddingTopInPixels(): number;
  72131. set paddingTopInPixels(value: number);
  72132. /**
  72133. * Gets or sets a value indicating the padding to use on the bottom of the control
  72134. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72135. */
  72136. get paddingBottom(): string | number;
  72137. set paddingBottom(value: string | number);
  72138. /**
  72139. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72140. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72141. */
  72142. get paddingBottomInPixels(): number;
  72143. set paddingBottomInPixels(value: number);
  72144. /**
  72145. * Gets or sets a value indicating the left coordinate of the control
  72146. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72147. */
  72148. get left(): string | number;
  72149. set left(value: string | number);
  72150. /**
  72151. * Gets or sets a value indicating the left coordinate in pixels of the control
  72152. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72153. */
  72154. get leftInPixels(): number;
  72155. set leftInPixels(value: number);
  72156. /**
  72157. * Gets or sets a value indicating the top coordinate of the control
  72158. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72159. */
  72160. get top(): string | number;
  72161. set top(value: string | number);
  72162. /**
  72163. * Gets or sets a value indicating the top coordinate in pixels of the control
  72164. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72165. */
  72166. get topInPixels(): number;
  72167. set topInPixels(value: number);
  72168. /**
  72169. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72170. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72171. */
  72172. get linkOffsetX(): string | number;
  72173. set linkOffsetX(value: string | number);
  72174. /**
  72175. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72176. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72177. */
  72178. get linkOffsetXInPixels(): number;
  72179. set linkOffsetXInPixels(value: number);
  72180. /**
  72181. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72182. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72183. */
  72184. get linkOffsetY(): string | number;
  72185. set linkOffsetY(value: string | number);
  72186. /**
  72187. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72188. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72189. */
  72190. get linkOffsetYInPixels(): number;
  72191. set linkOffsetYInPixels(value: number);
  72192. /** Gets the center coordinate on X axis */
  72193. get centerX(): number;
  72194. /** Gets the center coordinate on Y axis */
  72195. get centerY(): number;
  72196. /** Gets or sets if control is Enabled*/
  72197. get isEnabled(): boolean;
  72198. set isEnabled(value: boolean);
  72199. /** Gets or sets background color of control if it's disabled*/
  72200. get disabledColor(): string;
  72201. set disabledColor(value: string);
  72202. /** Gets or sets front color of control if it's disabled*/
  72203. get disabledColorItem(): string;
  72204. set disabledColorItem(value: string);
  72205. /**
  72206. * Creates a new control
  72207. * @param name defines the name of the control
  72208. */
  72209. constructor(
  72210. /** defines the name of the control */
  72211. name?: string | undefined);
  72212. /** @hidden */
  72213. protected _getTypeName(): string;
  72214. /**
  72215. * Gets the first ascendant in the hierarchy of the given type
  72216. * @param className defines the required type
  72217. * @returns the ascendant or null if not found
  72218. */
  72219. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72220. /** @hidden */
  72221. _resetFontCache(): void;
  72222. /**
  72223. * Determines if a container is an ascendant of the current control
  72224. * @param container defines the container to look for
  72225. * @returns true if the container is one of the ascendant of the control
  72226. */
  72227. isAscendant(container: Control): boolean;
  72228. /**
  72229. * Gets coordinates in local control space
  72230. * @param globalCoordinates defines the coordinates to transform
  72231. * @returns the new coordinates in local space
  72232. */
  72233. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72234. /**
  72235. * Gets coordinates in local control space
  72236. * @param globalCoordinates defines the coordinates to transform
  72237. * @param result defines the target vector2 where to store the result
  72238. * @returns the current control
  72239. */
  72240. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72241. /**
  72242. * Gets coordinates in parent local control space
  72243. * @param globalCoordinates defines the coordinates to transform
  72244. * @returns the new coordinates in parent local space
  72245. */
  72246. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72247. /**
  72248. * Move the current control to a vector3 position projected onto the screen.
  72249. * @param position defines the target position
  72250. * @param scene defines the hosting scene
  72251. */
  72252. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72253. /**
  72254. * Will store all controls that have this control as ascendant in a given array
  72255. * @param results defines the array where to store the descendants
  72256. * @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
  72257. * @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
  72258. */
  72259. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72260. /**
  72261. * Will return all controls that have this control as ascendant
  72262. * @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
  72263. * @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
  72264. * @return all child controls
  72265. */
  72266. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72267. /**
  72268. * Link current control with a target mesh
  72269. * @param mesh defines the mesh to link with
  72270. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72271. */
  72272. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72273. /** @hidden */
  72274. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72275. /** @hidden */
  72276. _offsetLeft(offset: number): void;
  72277. /** @hidden */
  72278. _offsetTop(offset: number): void;
  72279. /** @hidden */
  72280. _markMatrixAsDirty(): void;
  72281. /** @hidden */
  72282. _flagDescendantsAsMatrixDirty(): void;
  72283. /** @hidden */
  72284. _intersectsRect(rect: Measure): boolean;
  72285. /** @hidden */
  72286. protected invalidateRect(): void;
  72287. /** @hidden */
  72288. _markAsDirty(force?: boolean): void;
  72289. /** @hidden */
  72290. _markAllAsDirty(): void;
  72291. /** @hidden */
  72292. _link(host: AdvancedDynamicTexture): void;
  72293. /** @hidden */
  72294. protected _transform(context?: CanvasRenderingContext2D): void;
  72295. /** @hidden */
  72296. _renderHighlight(context: CanvasRenderingContext2D): void;
  72297. /** @hidden */
  72298. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72299. /** @hidden */
  72300. protected _applyStates(context: CanvasRenderingContext2D): void;
  72301. /** @hidden */
  72302. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72303. /** @hidden */
  72304. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72305. protected _evaluateClippingState(parentMeasure: Measure): void;
  72306. /** @hidden */
  72307. _measure(): void;
  72308. /** @hidden */
  72309. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72310. /** @hidden */
  72311. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72312. /** @hidden */
  72313. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72314. /** @hidden */
  72315. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72316. private static _ClipMeasure;
  72317. private _tmpMeasureA;
  72318. private _clip;
  72319. /** @hidden */
  72320. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72321. /** @hidden */
  72322. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72323. /**
  72324. * Tests if a given coordinates belong to the current control
  72325. * @param x defines x coordinate to test
  72326. * @param y defines y coordinate to test
  72327. * @returns true if the coordinates are inside the control
  72328. */
  72329. contains(x: number, y: number): boolean;
  72330. /** @hidden */
  72331. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72332. /** @hidden */
  72333. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72334. /** @hidden */
  72335. _onPointerEnter(target: Control): boolean;
  72336. /** @hidden */
  72337. _onPointerOut(target: Control, force?: boolean): void;
  72338. /** @hidden */
  72339. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72340. /** @hidden */
  72341. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72342. /** @hidden */
  72343. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72344. /** @hidden */
  72345. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72346. /** @hidden */
  72347. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72348. private _prepareFont;
  72349. /** Releases associated resources */
  72350. dispose(): void;
  72351. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72352. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72353. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72354. private static _VERTICAL_ALIGNMENT_TOP;
  72355. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72356. private static _VERTICAL_ALIGNMENT_CENTER;
  72357. /** HORIZONTAL_ALIGNMENT_LEFT */
  72358. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72359. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72360. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72361. /** HORIZONTAL_ALIGNMENT_CENTER */
  72362. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72363. /** VERTICAL_ALIGNMENT_TOP */
  72364. static get VERTICAL_ALIGNMENT_TOP(): number;
  72365. /** VERTICAL_ALIGNMENT_BOTTOM */
  72366. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72367. /** VERTICAL_ALIGNMENT_CENTER */
  72368. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72369. private static _FontHeightSizes;
  72370. /** @hidden */
  72371. static _GetFontOffset(font: string): {
  72372. ascent: number;
  72373. height: number;
  72374. descent: number;
  72375. };
  72376. /**
  72377. * Creates a stack panel that can be used to render headers
  72378. * @param control defines the control to associate with the header
  72379. * @param text defines the text of the header
  72380. * @param size defines the size of the header
  72381. * @param options defines options used to configure the header
  72382. * @returns a new StackPanel
  72383. * @ignore
  72384. * @hidden
  72385. */
  72386. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72387. isHorizontal: boolean;
  72388. controlFirst: boolean;
  72389. }) => any;
  72390. /** @hidden */
  72391. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72392. }
  72393. }
  72394. declare module BABYLON.GUI {
  72395. /**
  72396. * Root class for 2D containers
  72397. * @see http://doc.babylonjs.com/how_to/gui#containers
  72398. */
  72399. export class Container extends Control {
  72400. name?: string | undefined;
  72401. /** @hidden */
  72402. _children: Control[];
  72403. /** @hidden */
  72404. protected _measureForChildren: Measure;
  72405. /** @hidden */
  72406. protected _background: string;
  72407. /** @hidden */
  72408. protected _adaptWidthToChildren: boolean;
  72409. /** @hidden */
  72410. protected _adaptHeightToChildren: boolean;
  72411. /**
  72412. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72413. */
  72414. logLayoutCycleErrors: boolean;
  72415. /**
  72416. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72417. */
  72418. maxLayoutCycle: number;
  72419. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72420. get adaptHeightToChildren(): boolean;
  72421. set adaptHeightToChildren(value: boolean);
  72422. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72423. get adaptWidthToChildren(): boolean;
  72424. set adaptWidthToChildren(value: boolean);
  72425. /** Gets or sets background color */
  72426. get background(): string;
  72427. set background(value: string);
  72428. /** Gets the list of children */
  72429. get children(): Control[];
  72430. /**
  72431. * Creates a new Container
  72432. * @param name defines the name of the container
  72433. */
  72434. constructor(name?: string | undefined);
  72435. protected _getTypeName(): string;
  72436. _flagDescendantsAsMatrixDirty(): void;
  72437. /**
  72438. * Gets a child using its name
  72439. * @param name defines the child name to look for
  72440. * @returns the child control if found
  72441. */
  72442. getChildByName(name: string): BABYLON.Nullable<Control>;
  72443. /**
  72444. * Gets a child using its type and its name
  72445. * @param name defines the child name to look for
  72446. * @param type defines the child type to look for
  72447. * @returns the child control if found
  72448. */
  72449. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72450. /**
  72451. * Search for a specific control in children
  72452. * @param control defines the control to look for
  72453. * @returns true if the control is in child list
  72454. */
  72455. containsControl(control: Control): boolean;
  72456. /**
  72457. * Adds a new control to the current container
  72458. * @param control defines the control to add
  72459. * @returns the current container
  72460. */
  72461. addControl(control: BABYLON.Nullable<Control>): Container;
  72462. /**
  72463. * Removes all controls from the current container
  72464. * @returns the current container
  72465. */
  72466. clearControls(): Container;
  72467. /**
  72468. * Removes a control from the current container
  72469. * @param control defines the control to remove
  72470. * @returns the current container
  72471. */
  72472. removeControl(control: Control): Container;
  72473. /** @hidden */
  72474. _reOrderControl(control: Control): void;
  72475. /** @hidden */
  72476. _offsetLeft(offset: number): void;
  72477. /** @hidden */
  72478. _offsetTop(offset: number): void;
  72479. /** @hidden */
  72480. _markAllAsDirty(): void;
  72481. /** @hidden */
  72482. protected _localDraw(context: CanvasRenderingContext2D): void;
  72483. /** @hidden */
  72484. _link(host: AdvancedDynamicTexture): void;
  72485. /** @hidden */
  72486. protected _beforeLayout(): void;
  72487. /** @hidden */
  72488. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72489. /** @hidden */
  72490. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72491. protected _postMeasure(): void;
  72492. /** @hidden */
  72493. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72494. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72495. /** @hidden */
  72496. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72497. /** @hidden */
  72498. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72499. /** Releases associated resources */
  72500. dispose(): void;
  72501. }
  72502. }
  72503. declare module BABYLON.GUI {
  72504. /** Class used to create rectangle container */
  72505. export class Rectangle extends Container {
  72506. name?: string | undefined;
  72507. private _thickness;
  72508. private _cornerRadius;
  72509. /** Gets or sets border thickness */
  72510. get thickness(): number;
  72511. set thickness(value: number);
  72512. /** Gets or sets the corner radius angle */
  72513. get cornerRadius(): number;
  72514. set cornerRadius(value: number);
  72515. /**
  72516. * Creates a new Rectangle
  72517. * @param name defines the control name
  72518. */
  72519. constructor(name?: string | undefined);
  72520. protected _getTypeName(): string;
  72521. protected _localDraw(context: CanvasRenderingContext2D): void;
  72522. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72523. private _drawRoundedRect;
  72524. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72525. }
  72526. }
  72527. declare module BABYLON.GUI {
  72528. /**
  72529. * Enum that determines the text-wrapping mode to use.
  72530. */
  72531. export enum TextWrapping {
  72532. /**
  72533. * Clip the text when it's larger than Control.width; this is the default mode.
  72534. */
  72535. Clip = 0,
  72536. /**
  72537. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72538. */
  72539. WordWrap = 1,
  72540. /**
  72541. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72542. */
  72543. Ellipsis = 2
  72544. }
  72545. /**
  72546. * Class used to create text block control
  72547. */
  72548. export class TextBlock extends Control {
  72549. /**
  72550. * Defines the name of the control
  72551. */
  72552. name?: string | undefined;
  72553. private _text;
  72554. private _textWrapping;
  72555. private _textHorizontalAlignment;
  72556. private _textVerticalAlignment;
  72557. private _lines;
  72558. private _resizeToFit;
  72559. private _lineSpacing;
  72560. private _outlineWidth;
  72561. private _outlineColor;
  72562. /**
  72563. * An event triggered after the text is changed
  72564. */
  72565. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72566. /**
  72567. * An event triggered after the text was broken up into lines
  72568. */
  72569. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72570. /**
  72571. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72572. */
  72573. get lines(): any[];
  72574. /**
  72575. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72576. */
  72577. get resizeToFit(): boolean;
  72578. /**
  72579. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72580. */
  72581. set resizeToFit(value: boolean);
  72582. /**
  72583. * Gets or sets a boolean indicating if text must be wrapped
  72584. */
  72585. get textWrapping(): TextWrapping | boolean;
  72586. /**
  72587. * Gets or sets a boolean indicating if text must be wrapped
  72588. */
  72589. set textWrapping(value: TextWrapping | boolean);
  72590. /**
  72591. * Gets or sets text to display
  72592. */
  72593. get text(): string;
  72594. /**
  72595. * Gets or sets text to display
  72596. */
  72597. set text(value: string);
  72598. /**
  72599. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72600. */
  72601. get textHorizontalAlignment(): number;
  72602. /**
  72603. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72604. */
  72605. set textHorizontalAlignment(value: number);
  72606. /**
  72607. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72608. */
  72609. get textVerticalAlignment(): number;
  72610. /**
  72611. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72612. */
  72613. set textVerticalAlignment(value: number);
  72614. /**
  72615. * Gets or sets line spacing value
  72616. */
  72617. set lineSpacing(value: string | number);
  72618. /**
  72619. * Gets or sets line spacing value
  72620. */
  72621. get lineSpacing(): string | number;
  72622. /**
  72623. * Gets or sets outlineWidth of the text to display
  72624. */
  72625. get outlineWidth(): number;
  72626. /**
  72627. * Gets or sets outlineWidth of the text to display
  72628. */
  72629. set outlineWidth(value: number);
  72630. /**
  72631. * Gets or sets outlineColor of the text to display
  72632. */
  72633. get outlineColor(): string;
  72634. /**
  72635. * Gets or sets outlineColor of the text to display
  72636. */
  72637. set outlineColor(value: string);
  72638. /**
  72639. * Creates a new TextBlock object
  72640. * @param name defines the name of the control
  72641. * @param text defines the text to display (emptry string by default)
  72642. */
  72643. constructor(
  72644. /**
  72645. * Defines the name of the control
  72646. */
  72647. name?: string | undefined, text?: string);
  72648. protected _getTypeName(): string;
  72649. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72650. private _drawText;
  72651. /** @hidden */
  72652. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72653. protected _applyStates(context: CanvasRenderingContext2D): void;
  72654. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72655. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72656. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72657. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72658. protected _renderLines(context: CanvasRenderingContext2D): void;
  72659. /**
  72660. * Given a width constraint applied on the text block, find the expected height
  72661. * @returns expected height
  72662. */
  72663. computeExpectedHeight(): number;
  72664. dispose(): void;
  72665. }
  72666. }
  72667. declare module BABYLON.GUI {
  72668. /**
  72669. * Class used to create 2D images
  72670. */
  72671. export class Image extends Control {
  72672. name?: string | undefined;
  72673. private _workingCanvas;
  72674. private _domImage;
  72675. private _imageWidth;
  72676. private _imageHeight;
  72677. private _loaded;
  72678. private _stretch;
  72679. private _source;
  72680. private _autoScale;
  72681. private _sourceLeft;
  72682. private _sourceTop;
  72683. private _sourceWidth;
  72684. private _sourceHeight;
  72685. private _svgAttributesComputationCompleted;
  72686. private _isSVG;
  72687. private _cellWidth;
  72688. private _cellHeight;
  72689. private _cellId;
  72690. private _populateNinePatchSlicesFromImage;
  72691. private _sliceLeft;
  72692. private _sliceRight;
  72693. private _sliceTop;
  72694. private _sliceBottom;
  72695. private _detectPointerOnOpaqueOnly;
  72696. /**
  72697. * BABYLON.Observable notified when the content is loaded
  72698. */
  72699. onImageLoadedObservable: BABYLON.Observable<Image>;
  72700. /**
  72701. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72702. */
  72703. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72704. /**
  72705. * Gets a boolean indicating that the content is loaded
  72706. */
  72707. get isLoaded(): boolean;
  72708. /**
  72709. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72710. */
  72711. get populateNinePatchSlicesFromImage(): boolean;
  72712. set populateNinePatchSlicesFromImage(value: boolean);
  72713. /**
  72714. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72715. * Beware using this as this will comsume more memory as the image has to be stored twice
  72716. */
  72717. get detectPointerOnOpaqueOnly(): boolean;
  72718. set detectPointerOnOpaqueOnly(value: boolean);
  72719. /**
  72720. * Gets or sets the left value for slicing (9-patch)
  72721. */
  72722. get sliceLeft(): number;
  72723. set sliceLeft(value: number);
  72724. /**
  72725. * Gets or sets the right value for slicing (9-patch)
  72726. */
  72727. get sliceRight(): number;
  72728. set sliceRight(value: number);
  72729. /**
  72730. * Gets or sets the top value for slicing (9-patch)
  72731. */
  72732. get sliceTop(): number;
  72733. set sliceTop(value: number);
  72734. /**
  72735. * Gets or sets the bottom value for slicing (9-patch)
  72736. */
  72737. get sliceBottom(): number;
  72738. set sliceBottom(value: number);
  72739. /**
  72740. * Gets or sets the left coordinate in the source image
  72741. */
  72742. get sourceLeft(): number;
  72743. set sourceLeft(value: number);
  72744. /**
  72745. * Gets or sets the top coordinate in the source image
  72746. */
  72747. get sourceTop(): number;
  72748. set sourceTop(value: number);
  72749. /**
  72750. * Gets or sets the width to capture in the source image
  72751. */
  72752. get sourceWidth(): number;
  72753. set sourceWidth(value: number);
  72754. /**
  72755. * Gets or sets the height to capture in the source image
  72756. */
  72757. get sourceHeight(): number;
  72758. set sourceHeight(value: number);
  72759. /** Indicates if the format of the image is SVG */
  72760. get isSVG(): boolean;
  72761. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72762. get svgAttributesComputationCompleted(): boolean;
  72763. /**
  72764. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72765. * @see http://doc.babylonjs.com/how_to/gui#image
  72766. */
  72767. get autoScale(): boolean;
  72768. set autoScale(value: boolean);
  72769. /** Gets or sets the streching mode used by the image */
  72770. get stretch(): number;
  72771. set stretch(value: number);
  72772. /** @hidden */
  72773. _rotate90(n: number, preserveProperties?: boolean): Image;
  72774. private _handleRotationForSVGImage;
  72775. private _rotate90SourceProperties;
  72776. /**
  72777. * Gets or sets the internal DOM image used to render the control
  72778. */
  72779. set domImage(value: HTMLImageElement);
  72780. get domImage(): HTMLImageElement;
  72781. private _onImageLoaded;
  72782. private _extractNinePatchSliceDataFromImage;
  72783. /**
  72784. * Gets or sets image source url
  72785. */
  72786. set source(value: BABYLON.Nullable<string>);
  72787. /**
  72788. * Checks for svg document with icon id present
  72789. */
  72790. private _svgCheck;
  72791. /**
  72792. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72793. * given external svg file and icon id
  72794. */
  72795. private _getSVGAttribs;
  72796. /**
  72797. * Gets or sets the cell width to use when animation sheet is enabled
  72798. * @see http://doc.babylonjs.com/how_to/gui#image
  72799. */
  72800. get cellWidth(): number;
  72801. set cellWidth(value: number);
  72802. /**
  72803. * Gets or sets the cell height to use when animation sheet is enabled
  72804. * @see http://doc.babylonjs.com/how_to/gui#image
  72805. */
  72806. get cellHeight(): number;
  72807. set cellHeight(value: number);
  72808. /**
  72809. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72810. * @see http://doc.babylonjs.com/how_to/gui#image
  72811. */
  72812. get cellId(): number;
  72813. set cellId(value: number);
  72814. /**
  72815. * Creates a new Image
  72816. * @param name defines the control name
  72817. * @param url defines the image url
  72818. */
  72819. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72820. /**
  72821. * Tests if a given coordinates belong to the current control
  72822. * @param x defines x coordinate to test
  72823. * @param y defines y coordinate to test
  72824. * @returns true if the coordinates are inside the control
  72825. */
  72826. contains(x: number, y: number): boolean;
  72827. protected _getTypeName(): string;
  72828. /** Force the control to synchronize with its content */
  72829. synchronizeSizeWithContent(): void;
  72830. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72831. private _prepareWorkingCanvasForOpaqueDetection;
  72832. private _drawImage;
  72833. _draw(context: CanvasRenderingContext2D): void;
  72834. private _renderCornerPatch;
  72835. private _renderNinePatch;
  72836. dispose(): void;
  72837. /** STRETCH_NONE */
  72838. static readonly STRETCH_NONE: number;
  72839. /** STRETCH_FILL */
  72840. static readonly STRETCH_FILL: number;
  72841. /** STRETCH_UNIFORM */
  72842. static readonly STRETCH_UNIFORM: number;
  72843. /** STRETCH_EXTEND */
  72844. static readonly STRETCH_EXTEND: number;
  72845. /** NINE_PATCH */
  72846. static readonly STRETCH_NINE_PATCH: number;
  72847. }
  72848. }
  72849. declare module BABYLON.GUI {
  72850. /**
  72851. * Class used to create 2D buttons
  72852. */
  72853. export class Button extends Rectangle {
  72854. name?: string | undefined;
  72855. /**
  72856. * Function called to generate a pointer enter animation
  72857. */
  72858. pointerEnterAnimation: () => void;
  72859. /**
  72860. * Function called to generate a pointer out animation
  72861. */
  72862. pointerOutAnimation: () => void;
  72863. /**
  72864. * Function called to generate a pointer down animation
  72865. */
  72866. pointerDownAnimation: () => void;
  72867. /**
  72868. * Function called to generate a pointer up animation
  72869. */
  72870. pointerUpAnimation: () => void;
  72871. /**
  72872. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72873. */
  72874. delegatePickingToChildren: boolean;
  72875. private _image;
  72876. /**
  72877. * Returns the image part of the button (if any)
  72878. */
  72879. get image(): BABYLON.Nullable<Image>;
  72880. private _textBlock;
  72881. /**
  72882. * Returns the image part of the button (if any)
  72883. */
  72884. get textBlock(): BABYLON.Nullable<TextBlock>;
  72885. /**
  72886. * Creates a new Button
  72887. * @param name defines the name of the button
  72888. */
  72889. constructor(name?: string | undefined);
  72890. protected _getTypeName(): string;
  72891. /** @hidden */
  72892. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72893. /** @hidden */
  72894. _onPointerEnter(target: Control): boolean;
  72895. /** @hidden */
  72896. _onPointerOut(target: Control, force?: boolean): void;
  72897. /** @hidden */
  72898. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72899. /** @hidden */
  72900. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72901. /**
  72902. * Creates a new button made with an image and a text
  72903. * @param name defines the name of the button
  72904. * @param text defines the text of the button
  72905. * @param imageUrl defines the url of the image
  72906. * @returns a new Button
  72907. */
  72908. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72909. /**
  72910. * Creates a new button made with an image
  72911. * @param name defines the name of the button
  72912. * @param imageUrl defines the url of the image
  72913. * @returns a new Button
  72914. */
  72915. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72916. /**
  72917. * Creates a new button made with a text
  72918. * @param name defines the name of the button
  72919. * @param text defines the text of the button
  72920. * @returns a new Button
  72921. */
  72922. static CreateSimpleButton(name: string, text: string): Button;
  72923. /**
  72924. * Creates a new button made with an image and a centered text
  72925. * @param name defines the name of the button
  72926. * @param text defines the text of the button
  72927. * @param imageUrl defines the url of the image
  72928. * @returns a new Button
  72929. */
  72930. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72931. }
  72932. }
  72933. declare module BABYLON.GUI {
  72934. /**
  72935. * Class used to create a 2D stack panel container
  72936. */
  72937. export class StackPanel extends Container {
  72938. name?: string | undefined;
  72939. private _isVertical;
  72940. private _manualWidth;
  72941. private _manualHeight;
  72942. private _doNotTrackManualChanges;
  72943. /**
  72944. * Gets or sets a boolean indicating that layou warnings should be ignored
  72945. */
  72946. ignoreLayoutWarnings: boolean;
  72947. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72948. get isVertical(): boolean;
  72949. set isVertical(value: boolean);
  72950. /**
  72951. * Gets or sets panel width.
  72952. * This value should not be set when in horizontal mode as it will be computed automatically
  72953. */
  72954. set width(value: string | number);
  72955. get width(): string | number;
  72956. /**
  72957. * Gets or sets panel height.
  72958. * This value should not be set when in vertical mode as it will be computed automatically
  72959. */
  72960. set height(value: string | number);
  72961. get height(): string | number;
  72962. /**
  72963. * Creates a new StackPanel
  72964. * @param name defines control name
  72965. */
  72966. constructor(name?: string | undefined);
  72967. protected _getTypeName(): string;
  72968. /** @hidden */
  72969. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72970. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72971. protected _postMeasure(): void;
  72972. }
  72973. }
  72974. declare module BABYLON.GUI {
  72975. /**
  72976. * Class used to represent a 2D checkbox
  72977. */
  72978. export class Checkbox extends Control {
  72979. name?: string | undefined;
  72980. private _isChecked;
  72981. private _background;
  72982. private _checkSizeRatio;
  72983. private _thickness;
  72984. /** Gets or sets border thickness */
  72985. get thickness(): number;
  72986. set thickness(value: number);
  72987. /**
  72988. * BABYLON.Observable raised when isChecked property changes
  72989. */
  72990. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72991. /** Gets or sets a value indicating the ratio between overall size and check size */
  72992. get checkSizeRatio(): number;
  72993. set checkSizeRatio(value: number);
  72994. /** Gets or sets background color */
  72995. get background(): string;
  72996. set background(value: string);
  72997. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72998. get isChecked(): boolean;
  72999. set isChecked(value: boolean);
  73000. /**
  73001. * Creates a new CheckBox
  73002. * @param name defines the control name
  73003. */
  73004. constructor(name?: string | undefined);
  73005. protected _getTypeName(): string;
  73006. /** @hidden */
  73007. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73008. /** @hidden */
  73009. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73010. /**
  73011. * Utility function to easily create a checkbox with a header
  73012. * @param title defines the label to use for the header
  73013. * @param onValueChanged defines the callback to call when value changes
  73014. * @returns a StackPanel containing the checkbox and a textBlock
  73015. */
  73016. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  73017. }
  73018. }
  73019. declare module BABYLON.GUI {
  73020. /**
  73021. * Class used to store key control properties
  73022. */
  73023. export class KeyPropertySet {
  73024. /** Width */
  73025. width?: string;
  73026. /** Height */
  73027. height?: string;
  73028. /** Left padding */
  73029. paddingLeft?: string;
  73030. /** Right padding */
  73031. paddingRight?: string;
  73032. /** Top padding */
  73033. paddingTop?: string;
  73034. /** Bottom padding */
  73035. paddingBottom?: string;
  73036. /** Foreground color */
  73037. color?: string;
  73038. /** Background color */
  73039. background?: string;
  73040. }
  73041. /**
  73042. * Class used to create virtual keyboard
  73043. */
  73044. export class VirtualKeyboard extends StackPanel {
  73045. /** BABYLON.Observable raised when a key is pressed */
  73046. onKeyPressObservable: BABYLON.Observable<string>;
  73047. /** Gets or sets default key button width */
  73048. defaultButtonWidth: string;
  73049. /** Gets or sets default key button height */
  73050. defaultButtonHeight: string;
  73051. /** Gets or sets default key button left padding */
  73052. defaultButtonPaddingLeft: string;
  73053. /** Gets or sets default key button right padding */
  73054. defaultButtonPaddingRight: string;
  73055. /** Gets or sets default key button top padding */
  73056. defaultButtonPaddingTop: string;
  73057. /** Gets or sets default key button bottom padding */
  73058. defaultButtonPaddingBottom: string;
  73059. /** Gets or sets default key button foreground color */
  73060. defaultButtonColor: string;
  73061. /** Gets or sets default key button background color */
  73062. defaultButtonBackground: string;
  73063. /** Gets or sets shift button foreground color */
  73064. shiftButtonColor: string;
  73065. /** Gets or sets shift button thickness*/
  73066. selectedShiftThickness: number;
  73067. /** Gets shift key state */
  73068. shiftState: number;
  73069. protected _getTypeName(): string;
  73070. private _createKey;
  73071. /**
  73072. * Adds a new row of keys
  73073. * @param keys defines the list of keys to add
  73074. * @param propertySets defines the associated property sets
  73075. */
  73076. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  73077. /**
  73078. * Set the shift key to a specific state
  73079. * @param shiftState defines the new shift state
  73080. */
  73081. applyShiftState(shiftState: number): void;
  73082. private _currentlyConnectedInputText;
  73083. private _connectedInputTexts;
  73084. private _onKeyPressObserver;
  73085. /** Gets the input text control currently attached to the keyboard */
  73086. get connectedInputText(): BABYLON.Nullable<InputText>;
  73087. /**
  73088. * Connects the keyboard with an input text control
  73089. *
  73090. * @param input defines the target control
  73091. */
  73092. connect(input: InputText): void;
  73093. /**
  73094. * Disconnects the keyboard from connected InputText controls
  73095. *
  73096. * @param input optionally defines a target control, otherwise all are disconnected
  73097. */
  73098. disconnect(input?: InputText): void;
  73099. private _removeConnectedInputObservables;
  73100. /**
  73101. * Release all resources
  73102. */
  73103. dispose(): void;
  73104. /**
  73105. * Creates a new keyboard using a default layout
  73106. *
  73107. * @param name defines control name
  73108. * @returns a new VirtualKeyboard
  73109. */
  73110. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  73111. }
  73112. }
  73113. declare module BABYLON.GUI {
  73114. /**
  73115. * Class used to create input text control
  73116. */
  73117. export class InputText extends Control implements IFocusableControl {
  73118. name?: string | undefined;
  73119. private _text;
  73120. private _placeholderText;
  73121. private _background;
  73122. private _focusedBackground;
  73123. private _focusedColor;
  73124. private _placeholderColor;
  73125. private _thickness;
  73126. private _margin;
  73127. private _autoStretchWidth;
  73128. private _maxWidth;
  73129. private _isFocused;
  73130. private _blinkTimeout;
  73131. private _blinkIsEven;
  73132. private _cursorOffset;
  73133. private _scrollLeft;
  73134. private _textWidth;
  73135. private _clickedCoordinate;
  73136. private _deadKey;
  73137. private _addKey;
  73138. private _currentKey;
  73139. private _isTextHighlightOn;
  73140. private _textHighlightColor;
  73141. private _highligherOpacity;
  73142. private _highlightedText;
  73143. private _startHighlightIndex;
  73144. private _endHighlightIndex;
  73145. private _cursorIndex;
  73146. private _onFocusSelectAll;
  73147. private _isPointerDown;
  73148. private _onClipboardObserver;
  73149. private _onPointerDblTapObserver;
  73150. /** @hidden */
  73151. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73152. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73153. promptMessage: string;
  73154. /** Force disable prompt on mobile device */
  73155. disableMobilePrompt: boolean;
  73156. /** BABYLON.Observable raised when the text changes */
  73157. onTextChangedObservable: BABYLON.Observable<InputText>;
  73158. /** BABYLON.Observable raised just before an entered character is to be added */
  73159. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73160. /** BABYLON.Observable raised when the control gets the focus */
  73161. onFocusObservable: BABYLON.Observable<InputText>;
  73162. /** BABYLON.Observable raised when the control loses the focus */
  73163. onBlurObservable: BABYLON.Observable<InputText>;
  73164. /**Observable raised when the text is highlighted */
  73165. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73166. /**Observable raised when copy event is triggered */
  73167. onTextCopyObservable: BABYLON.Observable<InputText>;
  73168. /** BABYLON.Observable raised when cut event is triggered */
  73169. onTextCutObservable: BABYLON.Observable<InputText>;
  73170. /** BABYLON.Observable raised when paste event is triggered */
  73171. onTextPasteObservable: BABYLON.Observable<InputText>;
  73172. /** BABYLON.Observable raised when a key event was processed */
  73173. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73174. /** Gets or sets the maximum width allowed by the control */
  73175. get maxWidth(): string | number;
  73176. /** Gets the maximum width allowed by the control in pixels */
  73177. get maxWidthInPixels(): number;
  73178. set maxWidth(value: string | number);
  73179. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73180. get highligherOpacity(): number;
  73181. set highligherOpacity(value: number);
  73182. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73183. get onFocusSelectAll(): boolean;
  73184. set onFocusSelectAll(value: boolean);
  73185. /** Gets or sets the text hightlight color */
  73186. get textHighlightColor(): string;
  73187. set textHighlightColor(value: string);
  73188. /** Gets or sets control margin */
  73189. get margin(): string;
  73190. /** Gets control margin in pixels */
  73191. get marginInPixels(): number;
  73192. set margin(value: string);
  73193. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73194. get autoStretchWidth(): boolean;
  73195. set autoStretchWidth(value: boolean);
  73196. /** Gets or sets border thickness */
  73197. get thickness(): number;
  73198. set thickness(value: number);
  73199. /** Gets or sets the background color when focused */
  73200. get focusedBackground(): string;
  73201. set focusedBackground(value: string);
  73202. /** Gets or sets the background color when focused */
  73203. get focusedColor(): string;
  73204. set focusedColor(value: string);
  73205. /** Gets or sets the background color */
  73206. get background(): string;
  73207. set background(value: string);
  73208. /** Gets or sets the placeholder color */
  73209. get placeholderColor(): string;
  73210. set placeholderColor(value: string);
  73211. /** Gets or sets the text displayed when the control is empty */
  73212. get placeholderText(): string;
  73213. set placeholderText(value: string);
  73214. /** Gets or sets the dead key flag */
  73215. get deadKey(): boolean;
  73216. set deadKey(flag: boolean);
  73217. /** Gets or sets the highlight text */
  73218. get highlightedText(): string;
  73219. set highlightedText(text: string);
  73220. /** Gets or sets if the current key should be added */
  73221. get addKey(): boolean;
  73222. set addKey(flag: boolean);
  73223. /** Gets or sets the value of the current key being entered */
  73224. get currentKey(): string;
  73225. set currentKey(key: string);
  73226. /** Gets or sets the text displayed in the control */
  73227. get text(): string;
  73228. set text(value: string);
  73229. /** Gets or sets control width */
  73230. get width(): string | number;
  73231. set width(value: string | number);
  73232. /**
  73233. * Creates a new InputText
  73234. * @param name defines the control name
  73235. * @param text defines the text of the control
  73236. */
  73237. constructor(name?: string | undefined, text?: string);
  73238. /** @hidden */
  73239. onBlur(): void;
  73240. /** @hidden */
  73241. onFocus(): void;
  73242. protected _getTypeName(): string;
  73243. /**
  73244. * Function called to get the list of controls that should not steal the focus from this control
  73245. * @returns an array of controls
  73246. */
  73247. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73248. /** @hidden */
  73249. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73250. /** @hidden */
  73251. private _updateValueFromCursorIndex;
  73252. /** @hidden */
  73253. private _processDblClick;
  73254. /** @hidden */
  73255. private _selectAllText;
  73256. /**
  73257. * Handles the keyboard event
  73258. * @param evt Defines the KeyboardEvent
  73259. */
  73260. processKeyboard(evt: KeyboardEvent): void;
  73261. /** @hidden */
  73262. private _onCopyText;
  73263. /** @hidden */
  73264. private _onCutText;
  73265. /** @hidden */
  73266. private _onPasteText;
  73267. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73268. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73269. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73270. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73271. protected _beforeRenderText(text: string): string;
  73272. dispose(): void;
  73273. }
  73274. }
  73275. declare module BABYLON.GUI {
  73276. /**
  73277. * Class used to create a 2D grid container
  73278. */
  73279. export class Grid extends Container {
  73280. name?: string | undefined;
  73281. private _rowDefinitions;
  73282. private _columnDefinitions;
  73283. private _cells;
  73284. private _childControls;
  73285. /**
  73286. * Gets the number of columns
  73287. */
  73288. get columnCount(): number;
  73289. /**
  73290. * Gets the number of rows
  73291. */
  73292. get rowCount(): number;
  73293. /** Gets the list of children */
  73294. get children(): Control[];
  73295. /** Gets the list of cells (e.g. the containers) */
  73296. get cells(): {
  73297. [key: string]: Container;
  73298. };
  73299. /**
  73300. * Gets the definition of a specific row
  73301. * @param index defines the index of the row
  73302. * @returns the row definition
  73303. */
  73304. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73305. /**
  73306. * Gets the definition of a specific column
  73307. * @param index defines the index of the column
  73308. * @returns the column definition
  73309. */
  73310. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73311. /**
  73312. * Adds a new row to the grid
  73313. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73314. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73315. * @returns the current grid
  73316. */
  73317. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73318. /**
  73319. * Adds a new column to the grid
  73320. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73321. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73322. * @returns the current grid
  73323. */
  73324. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73325. /**
  73326. * Update a row definition
  73327. * @param index defines the index of the row to update
  73328. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73329. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73330. * @returns the current grid
  73331. */
  73332. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73333. /**
  73334. * Update a column definition
  73335. * @param index defines the index of the column to update
  73336. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73337. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73338. * @returns the current grid
  73339. */
  73340. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73341. /**
  73342. * Gets the list of children stored in a specific cell
  73343. * @param row defines the row to check
  73344. * @param column defines the column to check
  73345. * @returns the list of controls
  73346. */
  73347. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73348. /**
  73349. * Gets a string representing the child cell info (row x column)
  73350. * @param child defines the control to get info from
  73351. * @returns a string containing the child cell info (row x column)
  73352. */
  73353. getChildCellInfo(child: Control): string;
  73354. private _removeCell;
  73355. private _offsetCell;
  73356. /**
  73357. * Remove a column definition at specified index
  73358. * @param index defines the index of the column to remove
  73359. * @returns the current grid
  73360. */
  73361. removeColumnDefinition(index: number): Grid;
  73362. /**
  73363. * Remove a row definition at specified index
  73364. * @param index defines the index of the row to remove
  73365. * @returns the current grid
  73366. */
  73367. removeRowDefinition(index: number): Grid;
  73368. /**
  73369. * Adds a new control to the current grid
  73370. * @param control defines the control to add
  73371. * @param row defines the row where to add the control (0 by default)
  73372. * @param column defines the column where to add the control (0 by default)
  73373. * @returns the current grid
  73374. */
  73375. addControl(control: Control, row?: number, column?: number): Grid;
  73376. /**
  73377. * Removes a control from the current container
  73378. * @param control defines the control to remove
  73379. * @returns the current container
  73380. */
  73381. removeControl(control: Control): Container;
  73382. /**
  73383. * Creates a new Grid
  73384. * @param name defines control name
  73385. */
  73386. constructor(name?: string | undefined);
  73387. protected _getTypeName(): string;
  73388. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73389. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73390. _flagDescendantsAsMatrixDirty(): void;
  73391. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73392. /** Releases associated resources */
  73393. dispose(): void;
  73394. }
  73395. }
  73396. declare module BABYLON.GUI {
  73397. /** Class used to create color pickers */
  73398. export class ColorPicker extends Control {
  73399. name?: string | undefined;
  73400. private static _Epsilon;
  73401. private _colorWheelCanvas;
  73402. private _value;
  73403. private _tmpColor;
  73404. private _pointerStartedOnSquare;
  73405. private _pointerStartedOnWheel;
  73406. private _squareLeft;
  73407. private _squareTop;
  73408. private _squareSize;
  73409. private _h;
  73410. private _s;
  73411. private _v;
  73412. private _lastPointerDownID;
  73413. /**
  73414. * BABYLON.Observable raised when the value changes
  73415. */
  73416. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73417. /** Gets or sets the color of the color picker */
  73418. get value(): BABYLON.Color3;
  73419. set value(value: BABYLON.Color3);
  73420. /**
  73421. * Gets or sets control width
  73422. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73423. */
  73424. get width(): string | number;
  73425. set width(value: string | number);
  73426. /**
  73427. * Gets or sets control height
  73428. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73429. */
  73430. get height(): string | number;
  73431. /** Gets or sets control height */
  73432. set height(value: string | number);
  73433. /** Gets or sets control size */
  73434. get size(): string | number;
  73435. set size(value: string | number);
  73436. /**
  73437. * Creates a new ColorPicker
  73438. * @param name defines the control name
  73439. */
  73440. constructor(name?: string | undefined);
  73441. protected _getTypeName(): string;
  73442. /** @hidden */
  73443. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73444. private _updateSquareProps;
  73445. private _drawGradientSquare;
  73446. private _drawCircle;
  73447. private _createColorWheelCanvas;
  73448. /** @hidden */
  73449. _draw(context: CanvasRenderingContext2D): void;
  73450. private _pointerIsDown;
  73451. private _updateValueFromPointer;
  73452. private _isPointOnSquare;
  73453. private _isPointOnWheel;
  73454. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73455. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73456. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73457. /**
  73458. * This function expands the color picker by creating a color picker dialog with manual
  73459. * color value input and the ability to save colors into an array to be used later in
  73460. * subsequent launches of the dialogue.
  73461. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73462. * @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.
  73463. * @returns picked color as a hex string and the saved colors array as hex strings.
  73464. */
  73465. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73466. pickerWidth?: string;
  73467. pickerHeight?: string;
  73468. headerHeight?: string;
  73469. lastColor?: string;
  73470. swatchLimit?: number;
  73471. numSwatchesPerLine?: number;
  73472. savedColors?: Array<string>;
  73473. }): Promise<{
  73474. savedColors?: string[];
  73475. pickedColor: string;
  73476. }>;
  73477. }
  73478. }
  73479. declare module BABYLON.GUI {
  73480. /** Class used to create 2D ellipse containers */
  73481. export class Ellipse extends Container {
  73482. name?: string | undefined;
  73483. private _thickness;
  73484. /** Gets or sets border thickness */
  73485. get thickness(): number;
  73486. set thickness(value: number);
  73487. /**
  73488. * Creates a new Ellipse
  73489. * @param name defines the control name
  73490. */
  73491. constructor(name?: string | undefined);
  73492. protected _getTypeName(): string;
  73493. protected _localDraw(context: CanvasRenderingContext2D): void;
  73494. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73495. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73496. }
  73497. }
  73498. declare module BABYLON.GUI {
  73499. /**
  73500. * Class used to create a password control
  73501. */
  73502. export class InputPassword extends InputText {
  73503. protected _beforeRenderText(text: string): string;
  73504. }
  73505. }
  73506. declare module BABYLON.GUI {
  73507. /** Class used to render 2D lines */
  73508. export class Line extends Control {
  73509. name?: string | undefined;
  73510. private _lineWidth;
  73511. private _x1;
  73512. private _y1;
  73513. private _x2;
  73514. private _y2;
  73515. private _dash;
  73516. private _connectedControl;
  73517. private _connectedControlDirtyObserver;
  73518. /** Gets or sets the dash pattern */
  73519. get dash(): Array<number>;
  73520. set dash(value: Array<number>);
  73521. /** Gets or sets the control connected with the line end */
  73522. get connectedControl(): Control;
  73523. set connectedControl(value: Control);
  73524. /** Gets or sets start coordinates on X axis */
  73525. get x1(): string | number;
  73526. set x1(value: string | number);
  73527. /** Gets or sets start coordinates on Y axis */
  73528. get y1(): string | number;
  73529. set y1(value: string | number);
  73530. /** Gets or sets end coordinates on X axis */
  73531. get x2(): string | number;
  73532. set x2(value: string | number);
  73533. /** Gets or sets end coordinates on Y axis */
  73534. get y2(): string | number;
  73535. set y2(value: string | number);
  73536. /** Gets or sets line width */
  73537. get lineWidth(): number;
  73538. set lineWidth(value: number);
  73539. /** Gets or sets horizontal alignment */
  73540. set horizontalAlignment(value: number);
  73541. /** Gets or sets vertical alignment */
  73542. set verticalAlignment(value: number);
  73543. private get _effectiveX2();
  73544. private get _effectiveY2();
  73545. /**
  73546. * Creates a new Line
  73547. * @param name defines the control name
  73548. */
  73549. constructor(name?: string | undefined);
  73550. protected _getTypeName(): string;
  73551. _draw(context: CanvasRenderingContext2D): void;
  73552. _measure(): void;
  73553. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73554. /**
  73555. * Move one end of the line given 3D cartesian coordinates.
  73556. * @param position Targeted world position
  73557. * @param scene BABYLON.Scene
  73558. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73559. */
  73560. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73561. /**
  73562. * Move one end of the line to a position in screen absolute space.
  73563. * @param projectedPosition Position in screen absolute space (X, Y)
  73564. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73565. */
  73566. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73567. }
  73568. }
  73569. declare module BABYLON.GUI {
  73570. /**
  73571. * Class used to store a point for a MultiLine object.
  73572. * The point can be pure 2D coordinates, a mesh or a control
  73573. */
  73574. export class MultiLinePoint {
  73575. private _multiLine;
  73576. private _x;
  73577. private _y;
  73578. private _control;
  73579. private _mesh;
  73580. private _controlObserver;
  73581. private _meshObserver;
  73582. /** @hidden */
  73583. _point: BABYLON.Vector2;
  73584. /**
  73585. * Creates a new MultiLinePoint
  73586. * @param multiLine defines the source MultiLine object
  73587. */
  73588. constructor(multiLine: MultiLine);
  73589. /** Gets or sets x coordinate */
  73590. get x(): string | number;
  73591. set x(value: string | number);
  73592. /** Gets or sets y coordinate */
  73593. get y(): string | number;
  73594. set y(value: string | number);
  73595. /** Gets or sets the control associated with this point */
  73596. get control(): BABYLON.Nullable<Control>;
  73597. set control(value: BABYLON.Nullable<Control>);
  73598. /** Gets or sets the mesh associated with this point */
  73599. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73600. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73601. /** Resets links */
  73602. resetLinks(): void;
  73603. /**
  73604. * Gets a translation vector
  73605. * @returns the translation vector
  73606. */
  73607. translate(): BABYLON.Vector2;
  73608. private _translatePoint;
  73609. /** Release associated resources */
  73610. dispose(): void;
  73611. }
  73612. }
  73613. declare module BABYLON.GUI {
  73614. /**
  73615. * Class used to create multi line control
  73616. */
  73617. export class MultiLine extends Control {
  73618. name?: string | undefined;
  73619. private _lineWidth;
  73620. private _dash;
  73621. private _points;
  73622. private _minX;
  73623. private _minY;
  73624. private _maxX;
  73625. private _maxY;
  73626. /**
  73627. * Creates a new MultiLine
  73628. * @param name defines the control name
  73629. */
  73630. constructor(name?: string | undefined);
  73631. /** Gets or sets dash pattern */
  73632. get dash(): Array<number>;
  73633. set dash(value: Array<number>);
  73634. /**
  73635. * Gets point stored at specified index
  73636. * @param index defines the index to look for
  73637. * @returns the requested point if found
  73638. */
  73639. getAt(index: number): MultiLinePoint;
  73640. /** Function called when a point is updated */
  73641. onPointUpdate: () => void;
  73642. /**
  73643. * Adds new points to the point collection
  73644. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73645. * @returns the list of created MultiLinePoint
  73646. */
  73647. add(...items: (AbstractMesh | Control | {
  73648. x: string | number;
  73649. y: string | number;
  73650. })[]): MultiLinePoint[];
  73651. /**
  73652. * Adds a new point to the point collection
  73653. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73654. * @returns the created MultiLinePoint
  73655. */
  73656. push(item?: (AbstractMesh | Control | {
  73657. x: string | number;
  73658. y: string | number;
  73659. })): MultiLinePoint;
  73660. /**
  73661. * Remove a specific value or point from the active point collection
  73662. * @param value defines the value or point to remove
  73663. */
  73664. remove(value: number | MultiLinePoint): void;
  73665. /**
  73666. * Resets this object to initial state (no point)
  73667. */
  73668. reset(): void;
  73669. /**
  73670. * Resets all links
  73671. */
  73672. resetLinks(): void;
  73673. /** Gets or sets line width */
  73674. get lineWidth(): number;
  73675. set lineWidth(value: number);
  73676. set horizontalAlignment(value: number);
  73677. set verticalAlignment(value: number);
  73678. protected _getTypeName(): string;
  73679. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73680. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73681. _measure(): void;
  73682. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73683. dispose(): void;
  73684. }
  73685. }
  73686. declare module BABYLON.GUI {
  73687. /**
  73688. * Class used to create radio button controls
  73689. */
  73690. export class RadioButton extends Control {
  73691. name?: string | undefined;
  73692. private _isChecked;
  73693. private _background;
  73694. private _checkSizeRatio;
  73695. private _thickness;
  73696. /** Gets or sets border thickness */
  73697. get thickness(): number;
  73698. set thickness(value: number);
  73699. /** Gets or sets group name */
  73700. group: string;
  73701. /** BABYLON.Observable raised when isChecked is changed */
  73702. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73703. /** Gets or sets a value indicating the ratio between overall size and check size */
  73704. get checkSizeRatio(): number;
  73705. set checkSizeRatio(value: number);
  73706. /** Gets or sets background color */
  73707. get background(): string;
  73708. set background(value: string);
  73709. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73710. get isChecked(): boolean;
  73711. set isChecked(value: boolean);
  73712. /**
  73713. * Creates a new RadioButton
  73714. * @param name defines the control name
  73715. */
  73716. constructor(name?: string | undefined);
  73717. protected _getTypeName(): string;
  73718. _draw(context: CanvasRenderingContext2D): void;
  73719. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73720. /**
  73721. * Utility function to easily create a radio button with a header
  73722. * @param title defines the label to use for the header
  73723. * @param group defines the group to use for the radio button
  73724. * @param isChecked defines the initial state of the radio button
  73725. * @param onValueChanged defines the callback to call when value changes
  73726. * @returns a StackPanel containing the radio button and a textBlock
  73727. */
  73728. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73729. }
  73730. }
  73731. declare module BABYLON.GUI {
  73732. /**
  73733. * Class used to create slider controls
  73734. */
  73735. export class BaseSlider extends Control {
  73736. name?: string | undefined;
  73737. protected _thumbWidth: ValueAndUnit;
  73738. private _minimum;
  73739. private _maximum;
  73740. private _value;
  73741. private _isVertical;
  73742. protected _barOffset: ValueAndUnit;
  73743. private _isThumbClamped;
  73744. protected _displayThumb: boolean;
  73745. private _step;
  73746. private _lastPointerDownID;
  73747. protected _effectiveBarOffset: number;
  73748. protected _renderLeft: number;
  73749. protected _renderTop: number;
  73750. protected _renderWidth: number;
  73751. protected _renderHeight: number;
  73752. protected _backgroundBoxLength: number;
  73753. protected _backgroundBoxThickness: number;
  73754. protected _effectiveThumbThickness: number;
  73755. /** BABYLON.Observable raised when the sldier value changes */
  73756. onValueChangedObservable: BABYLON.Observable<number>;
  73757. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73758. get displayThumb(): boolean;
  73759. set displayThumb(value: boolean);
  73760. /** Gets or sets a step to apply to values (0 by default) */
  73761. get step(): number;
  73762. set step(value: number);
  73763. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73764. get barOffset(): string | number;
  73765. /** Gets main bar offset in pixels*/
  73766. get barOffsetInPixels(): number;
  73767. set barOffset(value: string | number);
  73768. /** Gets or sets thumb width */
  73769. get thumbWidth(): string | number;
  73770. /** Gets thumb width in pixels */
  73771. get thumbWidthInPixels(): number;
  73772. set thumbWidth(value: string | number);
  73773. /** Gets or sets minimum value */
  73774. get minimum(): number;
  73775. set minimum(value: number);
  73776. /** Gets or sets maximum value */
  73777. get maximum(): number;
  73778. set maximum(value: number);
  73779. /** Gets or sets current value */
  73780. get value(): number;
  73781. set value(value: number);
  73782. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73783. get isVertical(): boolean;
  73784. set isVertical(value: boolean);
  73785. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73786. get isThumbClamped(): boolean;
  73787. set isThumbClamped(value: boolean);
  73788. /**
  73789. * Creates a new BaseSlider
  73790. * @param name defines the control name
  73791. */
  73792. constructor(name?: string | undefined);
  73793. protected _getTypeName(): string;
  73794. protected _getThumbPosition(): number;
  73795. protected _getThumbThickness(type: string): number;
  73796. protected _prepareRenderingData(type: string): void;
  73797. private _pointerIsDown;
  73798. /** @hidden */
  73799. protected _updateValueFromPointer(x: number, y: number): void;
  73800. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73801. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73802. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73803. }
  73804. }
  73805. declare module BABYLON.GUI {
  73806. /**
  73807. * Class used to create slider controls
  73808. */
  73809. export class Slider extends BaseSlider {
  73810. name?: string | undefined;
  73811. private _background;
  73812. private _borderColor;
  73813. private _isThumbCircle;
  73814. protected _displayValueBar: boolean;
  73815. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73816. get displayValueBar(): boolean;
  73817. set displayValueBar(value: boolean);
  73818. /** Gets or sets border color */
  73819. get borderColor(): string;
  73820. set borderColor(value: string);
  73821. /** Gets or sets background color */
  73822. get background(): string;
  73823. set background(value: string);
  73824. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73825. get isThumbCircle(): boolean;
  73826. set isThumbCircle(value: boolean);
  73827. /**
  73828. * Creates a new Slider
  73829. * @param name defines the control name
  73830. */
  73831. constructor(name?: string | undefined);
  73832. protected _getTypeName(): string;
  73833. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73834. }
  73835. }
  73836. declare module BABYLON.GUI {
  73837. /** Class used to create a RadioGroup
  73838. * which contains groups of radio buttons
  73839. */
  73840. export class SelectorGroup {
  73841. /** name of SelectorGroup */
  73842. name: string;
  73843. private _groupPanel;
  73844. private _selectors;
  73845. private _groupHeader;
  73846. /**
  73847. * Creates a new SelectorGroup
  73848. * @param name of group, used as a group heading
  73849. */
  73850. constructor(
  73851. /** name of SelectorGroup */
  73852. name: string);
  73853. /** Gets the groupPanel of the SelectorGroup */
  73854. get groupPanel(): StackPanel;
  73855. /** Gets the selectors array */
  73856. get selectors(): StackPanel[];
  73857. /** Gets and sets the group header */
  73858. get header(): string;
  73859. set header(label: string);
  73860. /** @hidden */
  73861. private _addGroupHeader;
  73862. /** @hidden*/
  73863. _getSelector(selectorNb: number): StackPanel | undefined;
  73864. /** Removes the selector at the given position
  73865. * @param selectorNb the position of the selector within the group
  73866. */
  73867. removeSelector(selectorNb: number): void;
  73868. }
  73869. /** Class used to create a CheckboxGroup
  73870. * which contains groups of checkbox buttons
  73871. */
  73872. export class CheckboxGroup extends SelectorGroup {
  73873. /** Adds a checkbox as a control
  73874. * @param text is the label for the selector
  73875. * @param func is the function called when the Selector is checked
  73876. * @param checked is true when Selector is checked
  73877. */
  73878. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73879. /** @hidden */
  73880. _setSelectorLabel(selectorNb: number, label: string): void;
  73881. /** @hidden */
  73882. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73883. /** @hidden */
  73884. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73885. /** @hidden */
  73886. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73887. }
  73888. /** Class used to create a RadioGroup
  73889. * which contains groups of radio buttons
  73890. */
  73891. export class RadioGroup extends SelectorGroup {
  73892. private _selectNb;
  73893. /** Adds a radio button as a control
  73894. * @param label is the label for the selector
  73895. * @param func is the function called when the Selector is checked
  73896. * @param checked is true when Selector is checked
  73897. */
  73898. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73899. /** @hidden */
  73900. _setSelectorLabel(selectorNb: number, label: string): void;
  73901. /** @hidden */
  73902. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73903. /** @hidden */
  73904. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73905. /** @hidden */
  73906. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73907. }
  73908. /** Class used to create a SliderGroup
  73909. * which contains groups of slider buttons
  73910. */
  73911. export class SliderGroup extends SelectorGroup {
  73912. /**
  73913. * Adds a slider to the SelectorGroup
  73914. * @param label is the label for the SliderBar
  73915. * @param func is the function called when the Slider moves
  73916. * @param unit is a string describing the units used, eg degrees or metres
  73917. * @param min is the minimum value for the Slider
  73918. * @param max is the maximum value for the Slider
  73919. * @param value is the start value for the Slider between min and max
  73920. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73921. */
  73922. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73923. /** @hidden */
  73924. _setSelectorLabel(selectorNb: number, label: string): void;
  73925. /** @hidden */
  73926. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73927. /** @hidden */
  73928. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73929. /** @hidden */
  73930. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73931. }
  73932. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73933. * @see http://doc.babylonjs.com/how_to/selector
  73934. */
  73935. export class SelectionPanel extends Rectangle {
  73936. /** name of SelectionPanel */
  73937. name: string;
  73938. /** an array of SelectionGroups */
  73939. groups: SelectorGroup[];
  73940. private _panel;
  73941. private _buttonColor;
  73942. private _buttonBackground;
  73943. private _headerColor;
  73944. private _barColor;
  73945. private _barHeight;
  73946. private _spacerHeight;
  73947. private _labelColor;
  73948. private _groups;
  73949. private _bars;
  73950. /**
  73951. * Creates a new SelectionPanel
  73952. * @param name of SelectionPanel
  73953. * @param groups is an array of SelectionGroups
  73954. */
  73955. constructor(
  73956. /** name of SelectionPanel */
  73957. name: string,
  73958. /** an array of SelectionGroups */
  73959. groups?: SelectorGroup[]);
  73960. protected _getTypeName(): string;
  73961. /** Gets or sets the headerColor */
  73962. get headerColor(): string;
  73963. set headerColor(color: string);
  73964. private _setHeaderColor;
  73965. /** Gets or sets the button color */
  73966. get buttonColor(): string;
  73967. set buttonColor(color: string);
  73968. private _setbuttonColor;
  73969. /** Gets or sets the label color */
  73970. get labelColor(): string;
  73971. set labelColor(color: string);
  73972. private _setLabelColor;
  73973. /** Gets or sets the button background */
  73974. get buttonBackground(): string;
  73975. set buttonBackground(color: string);
  73976. private _setButtonBackground;
  73977. /** Gets or sets the color of separator bar */
  73978. get barColor(): string;
  73979. set barColor(color: string);
  73980. private _setBarColor;
  73981. /** Gets or sets the height of separator bar */
  73982. get barHeight(): string;
  73983. set barHeight(value: string);
  73984. private _setBarHeight;
  73985. /** Gets or sets the height of spacers*/
  73986. get spacerHeight(): string;
  73987. set spacerHeight(value: string);
  73988. private _setSpacerHeight;
  73989. /** Adds a bar between groups */
  73990. private _addSpacer;
  73991. /** Add a group to the selection panel
  73992. * @param group is the selector group to add
  73993. */
  73994. addGroup(group: SelectorGroup): void;
  73995. /** Remove the group from the given position
  73996. * @param groupNb is the position of the group in the list
  73997. */
  73998. removeGroup(groupNb: number): void;
  73999. /** Change a group header label
  74000. * @param label is the new group header label
  74001. * @param groupNb is the number of the group to relabel
  74002. * */
  74003. setHeaderName(label: string, groupNb: number): void;
  74004. /** Change selector label to the one given
  74005. * @param label is the new selector label
  74006. * @param groupNb is the number of the groupcontaining the selector
  74007. * @param selectorNb is the number of the selector within a group to relabel
  74008. * */
  74009. relabel(label: string, groupNb: number, selectorNb: number): void;
  74010. /** For a given group position remove the selector at the given position
  74011. * @param groupNb is the number of the group to remove the selector from
  74012. * @param selectorNb is the number of the selector within the group
  74013. */
  74014. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  74015. /** For a given group position of correct type add a checkbox button
  74016. * @param groupNb is the number of the group to remove the selector from
  74017. * @param label is the label for the selector
  74018. * @param func is the function called when the Selector is checked
  74019. * @param checked is true when Selector is checked
  74020. */
  74021. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74022. /** For a given group position of correct type add a radio button
  74023. * @param groupNb is the number of the group to remove the selector from
  74024. * @param label is the label for the selector
  74025. * @param func is the function called when the Selector is checked
  74026. * @param checked is true when Selector is checked
  74027. */
  74028. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74029. /**
  74030. * For a given slider group add a slider
  74031. * @param groupNb is the number of the group to add the slider to
  74032. * @param label is the label for the Slider
  74033. * @param func is the function called when the Slider moves
  74034. * @param unit is a string describing the units used, eg degrees or metres
  74035. * @param min is the minimum value for the Slider
  74036. * @param max is the maximum value for the Slider
  74037. * @param value is the start value for the Slider between min and max
  74038. * @param onVal is the function used to format the value displayed, eg radians to degrees
  74039. */
  74040. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  74041. }
  74042. }
  74043. declare module BABYLON.GUI {
  74044. /**
  74045. * Class used to hold a the container for ScrollViewer
  74046. * @hidden
  74047. */
  74048. export class _ScrollViewerWindow extends Container {
  74049. parentClientWidth: number;
  74050. parentClientHeight: number;
  74051. private _freezeControls;
  74052. private _parentMeasure;
  74053. private _oldLeft;
  74054. private _oldTop;
  74055. get freezeControls(): boolean;
  74056. set freezeControls(value: boolean);
  74057. private _bucketWidth;
  74058. private _bucketHeight;
  74059. private _buckets;
  74060. private _bucketLen;
  74061. get bucketWidth(): number;
  74062. get bucketHeight(): number;
  74063. setBucketSizes(width: number, height: number): void;
  74064. private _useBuckets;
  74065. private _makeBuckets;
  74066. private _dispatchInBuckets;
  74067. private _updateMeasures;
  74068. private _updateChildrenMeasures;
  74069. private _restoreMeasures;
  74070. /**
  74071. * Creates a new ScrollViewerWindow
  74072. * @param name of ScrollViewerWindow
  74073. */
  74074. constructor(name?: string);
  74075. protected _getTypeName(): string;
  74076. /** @hidden */
  74077. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74078. /** @hidden */
  74079. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74080. private _scrollChildren;
  74081. private _scrollChildrenWithBuckets;
  74082. /** @hidden */
  74083. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74084. protected _postMeasure(): void;
  74085. }
  74086. }
  74087. declare module BABYLON.GUI {
  74088. /**
  74089. * Class used to create slider controls
  74090. */
  74091. export class ScrollBar extends BaseSlider {
  74092. name?: string | undefined;
  74093. private _background;
  74094. private _borderColor;
  74095. private _tempMeasure;
  74096. /** Gets or sets border color */
  74097. get borderColor(): string;
  74098. set borderColor(value: string);
  74099. /** Gets or sets background color */
  74100. get background(): string;
  74101. set background(value: string);
  74102. /**
  74103. * Creates a new Slider
  74104. * @param name defines the control name
  74105. */
  74106. constructor(name?: string | undefined);
  74107. protected _getTypeName(): string;
  74108. protected _getThumbThickness(): number;
  74109. _draw(context: CanvasRenderingContext2D): void;
  74110. private _first;
  74111. private _originX;
  74112. private _originY;
  74113. /** @hidden */
  74114. protected _updateValueFromPointer(x: number, y: number): void;
  74115. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74116. }
  74117. }
  74118. declare module BABYLON.GUI {
  74119. /**
  74120. * Class used to create slider controls
  74121. */
  74122. export class ImageScrollBar extends BaseSlider {
  74123. name?: string | undefined;
  74124. private _backgroundBaseImage;
  74125. private _backgroundImage;
  74126. private _thumbImage;
  74127. private _thumbBaseImage;
  74128. private _thumbLength;
  74129. private _thumbHeight;
  74130. private _barImageHeight;
  74131. private _tempMeasure;
  74132. /** Number of 90° rotation to apply on the images when in vertical mode */
  74133. num90RotationInVerticalMode: number;
  74134. /**
  74135. * Gets or sets the image used to render the background for horizontal bar
  74136. */
  74137. get backgroundImage(): Image;
  74138. set backgroundImage(value: Image);
  74139. /**
  74140. * Gets or sets the image used to render the thumb
  74141. */
  74142. get thumbImage(): Image;
  74143. set thumbImage(value: Image);
  74144. /**
  74145. * Gets or sets the length of the thumb
  74146. */
  74147. get thumbLength(): number;
  74148. set thumbLength(value: number);
  74149. /**
  74150. * Gets or sets the height of the thumb
  74151. */
  74152. get thumbHeight(): number;
  74153. set thumbHeight(value: number);
  74154. /**
  74155. * Gets or sets the height of the bar image
  74156. */
  74157. get barImageHeight(): number;
  74158. set barImageHeight(value: number);
  74159. /**
  74160. * Creates a new ImageScrollBar
  74161. * @param name defines the control name
  74162. */
  74163. constructor(name?: string | undefined);
  74164. protected _getTypeName(): string;
  74165. protected _getThumbThickness(): number;
  74166. _draw(context: CanvasRenderingContext2D): void;
  74167. private _first;
  74168. private _originX;
  74169. private _originY;
  74170. /** @hidden */
  74171. protected _updateValueFromPointer(x: number, y: number): void;
  74172. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74173. }
  74174. }
  74175. declare module BABYLON.GUI {
  74176. /**
  74177. * Class used to hold a viewer window and sliders in a grid
  74178. */
  74179. export class ScrollViewer extends Rectangle {
  74180. private _grid;
  74181. private _horizontalBarSpace;
  74182. private _verticalBarSpace;
  74183. private _dragSpace;
  74184. private _horizontalBar;
  74185. private _verticalBar;
  74186. private _barColor;
  74187. private _barBackground;
  74188. private _barImage;
  74189. private _horizontalBarImage;
  74190. private _verticalBarImage;
  74191. private _barBackgroundImage;
  74192. private _horizontalBarBackgroundImage;
  74193. private _verticalBarBackgroundImage;
  74194. private _barSize;
  74195. private _window;
  74196. private _pointerIsOver;
  74197. private _wheelPrecision;
  74198. private _onWheelObserver;
  74199. private _clientWidth;
  74200. private _clientHeight;
  74201. private _useImageBar;
  74202. private _thumbLength;
  74203. private _thumbHeight;
  74204. private _barImageHeight;
  74205. private _horizontalBarImageHeight;
  74206. private _verticalBarImageHeight;
  74207. private _oldWindowContentsWidth;
  74208. private _oldWindowContentsHeight;
  74209. /**
  74210. * Gets the horizontal scrollbar
  74211. */
  74212. get horizontalBar(): ScrollBar | ImageScrollBar;
  74213. /**
  74214. * Gets the vertical scrollbar
  74215. */
  74216. get verticalBar(): ScrollBar | ImageScrollBar;
  74217. /**
  74218. * Adds a new control to the current container
  74219. * @param control defines the control to add
  74220. * @returns the current container
  74221. */
  74222. addControl(control: BABYLON.Nullable<Control>): Container;
  74223. /**
  74224. * Removes a control from the current container
  74225. * @param control defines the control to remove
  74226. * @returns the current container
  74227. */
  74228. removeControl(control: Control): Container;
  74229. /** Gets the list of children */
  74230. get children(): Control[];
  74231. _flagDescendantsAsMatrixDirty(): void;
  74232. /**
  74233. * Freezes or unfreezes the controls in the window.
  74234. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74235. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74236. */
  74237. get freezeControls(): boolean;
  74238. set freezeControls(value: boolean);
  74239. /** Gets the bucket width */
  74240. get bucketWidth(): number;
  74241. /** Gets the bucket height */
  74242. get bucketHeight(): number;
  74243. /**
  74244. * Sets the bucket sizes.
  74245. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74246. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74247. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74248. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74249. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74250. * used), that's why it is not enabled by default.
  74251. * @param width width of the bucket
  74252. * @param height height of the bucket
  74253. */
  74254. setBucketSizes(width: number, height: number): void;
  74255. private _forceHorizontalBar;
  74256. private _forceVerticalBar;
  74257. /**
  74258. * Forces the horizontal scroll bar to be displayed
  74259. */
  74260. get forceHorizontalBar(): boolean;
  74261. set forceHorizontalBar(value: boolean);
  74262. /**
  74263. * Forces the vertical scroll bar to be displayed
  74264. */
  74265. get forceVerticalBar(): boolean;
  74266. set forceVerticalBar(value: boolean);
  74267. /**
  74268. * Creates a new ScrollViewer
  74269. * @param name of ScrollViewer
  74270. */
  74271. constructor(name?: string, isImageBased?: boolean);
  74272. /** Reset the scroll viewer window to initial size */
  74273. resetWindow(): void;
  74274. protected _getTypeName(): string;
  74275. private _buildClientSizes;
  74276. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74277. protected _postMeasure(): void;
  74278. /**
  74279. * Gets or sets the mouse wheel precision
  74280. * from 0 to 1 with a default value of 0.05
  74281. * */
  74282. get wheelPrecision(): number;
  74283. set wheelPrecision(value: number);
  74284. /** Gets or sets the scroll bar container background color */
  74285. get scrollBackground(): string;
  74286. set scrollBackground(color: string);
  74287. /** Gets or sets the bar color */
  74288. get barColor(): string;
  74289. set barColor(color: string);
  74290. /** Gets or sets the bar image */
  74291. get thumbImage(): Image;
  74292. set thumbImage(value: Image);
  74293. /** Gets or sets the horizontal bar image */
  74294. get horizontalThumbImage(): Image;
  74295. set horizontalThumbImage(value: Image);
  74296. /** Gets or sets the vertical bar image */
  74297. get verticalThumbImage(): Image;
  74298. set verticalThumbImage(value: Image);
  74299. /** Gets or sets the size of the bar */
  74300. get barSize(): number;
  74301. set barSize(value: number);
  74302. /** Gets or sets the length of the thumb */
  74303. get thumbLength(): number;
  74304. set thumbLength(value: number);
  74305. /** Gets or sets the height of the thumb */
  74306. get thumbHeight(): number;
  74307. set thumbHeight(value: number);
  74308. /** Gets or sets the height of the bar image */
  74309. get barImageHeight(): number;
  74310. set barImageHeight(value: number);
  74311. /** Gets or sets the height of the horizontal bar image */
  74312. get horizontalBarImageHeight(): number;
  74313. set horizontalBarImageHeight(value: number);
  74314. /** Gets or sets the height of the vertical bar image */
  74315. get verticalBarImageHeight(): number;
  74316. set verticalBarImageHeight(value: number);
  74317. /** Gets or sets the bar background */
  74318. get barBackground(): string;
  74319. set barBackground(color: string);
  74320. /** Gets or sets the bar background image */
  74321. get barImage(): Image;
  74322. set barImage(value: Image);
  74323. /** Gets or sets the horizontal bar background image */
  74324. get horizontalBarImage(): Image;
  74325. set horizontalBarImage(value: Image);
  74326. /** Gets or sets the vertical bar background image */
  74327. get verticalBarImage(): Image;
  74328. set verticalBarImage(value: Image);
  74329. private _setWindowPosition;
  74330. /** @hidden */
  74331. private _updateScroller;
  74332. _link(host: AdvancedDynamicTexture): void;
  74333. /** @hidden */
  74334. private _addBar;
  74335. /** @hidden */
  74336. private _attachWheel;
  74337. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74338. /** Releases associated resources */
  74339. dispose(): void;
  74340. }
  74341. }
  74342. declare module BABYLON.GUI {
  74343. /** Class used to render a grid */
  74344. export class DisplayGrid extends Control {
  74345. name?: string | undefined;
  74346. private _cellWidth;
  74347. private _cellHeight;
  74348. private _minorLineTickness;
  74349. private _minorLineColor;
  74350. private _majorLineTickness;
  74351. private _majorLineColor;
  74352. private _majorLineFrequency;
  74353. private _background;
  74354. private _displayMajorLines;
  74355. private _displayMinorLines;
  74356. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74357. get displayMinorLines(): boolean;
  74358. set displayMinorLines(value: boolean);
  74359. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74360. get displayMajorLines(): boolean;
  74361. set displayMajorLines(value: boolean);
  74362. /** Gets or sets background color (Black by default) */
  74363. get background(): string;
  74364. set background(value: string);
  74365. /** Gets or sets the width of each cell (20 by default) */
  74366. get cellWidth(): number;
  74367. set cellWidth(value: number);
  74368. /** Gets or sets the height of each cell (20 by default) */
  74369. get cellHeight(): number;
  74370. set cellHeight(value: number);
  74371. /** Gets or sets the tickness of minor lines (1 by default) */
  74372. get minorLineTickness(): number;
  74373. set minorLineTickness(value: number);
  74374. /** Gets or sets the color of minor lines (DarkGray by default) */
  74375. get minorLineColor(): string;
  74376. set minorLineColor(value: string);
  74377. /** Gets or sets the tickness of major lines (2 by default) */
  74378. get majorLineTickness(): number;
  74379. set majorLineTickness(value: number);
  74380. /** Gets or sets the color of major lines (White by default) */
  74381. get majorLineColor(): string;
  74382. set majorLineColor(value: string);
  74383. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74384. get majorLineFrequency(): number;
  74385. set majorLineFrequency(value: number);
  74386. /**
  74387. * Creates a new GridDisplayRectangle
  74388. * @param name defines the control name
  74389. */
  74390. constructor(name?: string | undefined);
  74391. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74392. protected _getTypeName(): string;
  74393. }
  74394. }
  74395. declare module BABYLON.GUI {
  74396. /**
  74397. * Class used to create slider controls based on images
  74398. */
  74399. export class ImageBasedSlider extends BaseSlider {
  74400. name?: string | undefined;
  74401. private _backgroundImage;
  74402. private _thumbImage;
  74403. private _valueBarImage;
  74404. private _tempMeasure;
  74405. get displayThumb(): boolean;
  74406. set displayThumb(value: boolean);
  74407. /**
  74408. * Gets or sets the image used to render the background
  74409. */
  74410. get backgroundImage(): Image;
  74411. set backgroundImage(value: Image);
  74412. /**
  74413. * Gets or sets the image used to render the value bar
  74414. */
  74415. get valueBarImage(): Image;
  74416. set valueBarImage(value: Image);
  74417. /**
  74418. * Gets or sets the image used to render the thumb
  74419. */
  74420. get thumbImage(): Image;
  74421. set thumbImage(value: Image);
  74422. /**
  74423. * Creates a new ImageBasedSlider
  74424. * @param name defines the control name
  74425. */
  74426. constructor(name?: string | undefined);
  74427. protected _getTypeName(): string;
  74428. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74429. }
  74430. }
  74431. declare module BABYLON.GUI {
  74432. /**
  74433. * Forcing an export so that this code will execute
  74434. * @hidden
  74435. */
  74436. const name = "Statics";
  74437. }
  74438. declare module BABYLON.GUI {
  74439. /**
  74440. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74441. */
  74442. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74443. /**
  74444. * Define the instrumented AdvancedDynamicTexture.
  74445. */
  74446. texture: AdvancedDynamicTexture;
  74447. private _captureRenderTime;
  74448. private _renderTime;
  74449. private _captureLayoutTime;
  74450. private _layoutTime;
  74451. private _onBeginRenderObserver;
  74452. private _onEndRenderObserver;
  74453. private _onBeginLayoutObserver;
  74454. private _onEndLayoutObserver;
  74455. /**
  74456. * Gets the perf counter used to capture render time
  74457. */
  74458. get renderTimeCounter(): BABYLON.PerfCounter;
  74459. /**
  74460. * Gets the perf counter used to capture layout time
  74461. */
  74462. get layoutTimeCounter(): BABYLON.PerfCounter;
  74463. /**
  74464. * Enable or disable the render time capture
  74465. */
  74466. get captureRenderTime(): boolean;
  74467. set captureRenderTime(value: boolean);
  74468. /**
  74469. * Enable or disable the layout time capture
  74470. */
  74471. get captureLayoutTime(): boolean;
  74472. set captureLayoutTime(value: boolean);
  74473. /**
  74474. * Instantiates a new advanced dynamic texture instrumentation.
  74475. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74476. * @param texture Defines the AdvancedDynamicTexture to instrument
  74477. */
  74478. constructor(
  74479. /**
  74480. * Define the instrumented AdvancedDynamicTexture.
  74481. */
  74482. texture: AdvancedDynamicTexture);
  74483. /**
  74484. * Dispose and release associated resources.
  74485. */
  74486. dispose(): void;
  74487. }
  74488. }
  74489. declare module BABYLON.GUI {
  74490. /**
  74491. * Class used to load GUI via XML.
  74492. */
  74493. export class XmlLoader {
  74494. private _nodes;
  74495. private _nodeTypes;
  74496. private _isLoaded;
  74497. private _objectAttributes;
  74498. private _parentClass;
  74499. /**
  74500. * Create a new xml loader
  74501. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74502. */
  74503. constructor(parentClass?: null);
  74504. private _getChainElement;
  74505. private _getClassAttribute;
  74506. private _createGuiElement;
  74507. private _parseGrid;
  74508. private _parseElement;
  74509. private _prepareSourceElement;
  74510. private _parseElementsFromSource;
  74511. private _parseXml;
  74512. /**
  74513. * Gets if the loading has finished.
  74514. * @returns whether the loading has finished or not
  74515. */
  74516. isLoaded(): boolean;
  74517. /**
  74518. * Gets a loaded node / control by id.
  74519. * @param id the Controls id set in the xml
  74520. * @returns element of type Control
  74521. */
  74522. getNodeById(id: string): any;
  74523. /**
  74524. * Gets all loaded nodes / controls
  74525. * @returns Array of controls
  74526. */
  74527. getNodes(): any;
  74528. /**
  74529. * Initiates the xml layout loading
  74530. * @param xmlFile defines the xml layout to load
  74531. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74532. * @param callback defines the callback called on layout load.
  74533. */
  74534. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74535. }
  74536. }
  74537. declare module BABYLON.GUI {
  74538. /**
  74539. * Class used to create containers for controls
  74540. */
  74541. export class Container3D extends Control3D {
  74542. private _blockLayout;
  74543. /**
  74544. * Gets the list of child controls
  74545. */
  74546. protected _children: Control3D[];
  74547. /**
  74548. * Gets the list of child controls
  74549. */
  74550. get children(): Array<Control3D>;
  74551. /**
  74552. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74553. * This is helpful to optimize layout operation when adding multiple children in a row
  74554. */
  74555. get blockLayout(): boolean;
  74556. set blockLayout(value: boolean);
  74557. /**
  74558. * Creates a new container
  74559. * @param name defines the container name
  74560. */
  74561. constructor(name?: string);
  74562. /**
  74563. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74564. * @returns the current container
  74565. */
  74566. updateLayout(): Container3D;
  74567. /**
  74568. * Gets a boolean indicating if the given control is in the children of this control
  74569. * @param control defines the control to check
  74570. * @returns true if the control is in the child list
  74571. */
  74572. containsControl(control: Control3D): boolean;
  74573. /**
  74574. * Adds a control to the children of this control
  74575. * @param control defines the control to add
  74576. * @returns the current container
  74577. */
  74578. addControl(control: Control3D): Container3D;
  74579. /**
  74580. * This function will be called everytime a new control is added
  74581. */
  74582. protected _arrangeChildren(): void;
  74583. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74584. /**
  74585. * Removes a control from the children of this control
  74586. * @param control defines the control to remove
  74587. * @returns the current container
  74588. */
  74589. removeControl(control: Control3D): Container3D;
  74590. protected _getTypeName(): string;
  74591. /**
  74592. * Releases all associated resources
  74593. */
  74594. dispose(): void;
  74595. /** Control rotation will remain unchanged */
  74596. static readonly UNSET_ORIENTATION: number;
  74597. /** Control will rotate to make it look at sphere central axis */
  74598. static readonly FACEORIGIN_ORIENTATION: number;
  74599. /** Control will rotate to make it look back at sphere central axis */
  74600. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74601. /** Control will rotate to look at z axis (0, 0, 1) */
  74602. static readonly FACEFORWARD_ORIENTATION: number;
  74603. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74604. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74605. }
  74606. }
  74607. declare module BABYLON.GUI {
  74608. /**
  74609. * Class used to manage 3D user interface
  74610. * @see http://doc.babylonjs.com/how_to/gui3d
  74611. */
  74612. export class GUI3DManager implements BABYLON.IDisposable {
  74613. private _scene;
  74614. private _sceneDisposeObserver;
  74615. private _utilityLayer;
  74616. private _rootContainer;
  74617. private _pointerObserver;
  74618. private _pointerOutObserver;
  74619. /** @hidden */
  74620. _lastPickedControl: Control3D;
  74621. /** @hidden */
  74622. _lastControlOver: {
  74623. [pointerId: number]: Control3D;
  74624. };
  74625. /** @hidden */
  74626. _lastControlDown: {
  74627. [pointerId: number]: Control3D;
  74628. };
  74629. /**
  74630. * BABYLON.Observable raised when the point picked by the pointer events changed
  74631. */
  74632. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74633. /** @hidden */
  74634. _sharedMaterials: {
  74635. [key: string]: BABYLON.Material;
  74636. };
  74637. /** Gets the hosting scene */
  74638. get scene(): BABYLON.Scene;
  74639. /** Gets associated utility layer */
  74640. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74641. /**
  74642. * Creates a new GUI3DManager
  74643. * @param scene
  74644. */
  74645. constructor(scene?: BABYLON.Scene);
  74646. private _handlePointerOut;
  74647. private _doPicking;
  74648. /**
  74649. * Gets the root container
  74650. */
  74651. get rootContainer(): Container3D;
  74652. /**
  74653. * Gets a boolean indicating if the given control is in the root child list
  74654. * @param control defines the control to check
  74655. * @returns true if the control is in the root child list
  74656. */
  74657. containsControl(control: Control3D): boolean;
  74658. /**
  74659. * Adds a control to the root child list
  74660. * @param control defines the control to add
  74661. * @returns the current manager
  74662. */
  74663. addControl(control: Control3D): GUI3DManager;
  74664. /**
  74665. * Removes a control from the root child list
  74666. * @param control defines the control to remove
  74667. * @returns the current container
  74668. */
  74669. removeControl(control: Control3D): GUI3DManager;
  74670. /**
  74671. * Releases all associated resources
  74672. */
  74673. dispose(): void;
  74674. }
  74675. }
  74676. declare module BABYLON.GUI {
  74677. /**
  74678. * Class used to transport BABYLON.Vector3 information for pointer events
  74679. */
  74680. export class Vector3WithInfo extends BABYLON.Vector3 {
  74681. /** defines the current mouse button index */
  74682. buttonIndex: number;
  74683. /**
  74684. * Creates a new Vector3WithInfo
  74685. * @param source defines the vector3 data to transport
  74686. * @param buttonIndex defines the current mouse button index
  74687. */
  74688. constructor(source: BABYLON.Vector3,
  74689. /** defines the current mouse button index */
  74690. buttonIndex?: number);
  74691. }
  74692. }
  74693. declare module BABYLON.GUI {
  74694. /**
  74695. * Class used as base class for controls
  74696. */
  74697. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74698. /** Defines the control name */
  74699. name?: string | undefined;
  74700. /** @hidden */
  74701. _host: GUI3DManager;
  74702. private _node;
  74703. private _downCount;
  74704. private _enterCount;
  74705. private _downPointerIds;
  74706. private _isVisible;
  74707. /** Gets or sets the control position in world space */
  74708. get position(): BABYLON.Vector3;
  74709. set position(value: BABYLON.Vector3);
  74710. /** Gets or sets the control scaling in world space */
  74711. get scaling(): BABYLON.Vector3;
  74712. set scaling(value: BABYLON.Vector3);
  74713. /** Callback used to start pointer enter animation */
  74714. pointerEnterAnimation: () => void;
  74715. /** Callback used to start pointer out animation */
  74716. pointerOutAnimation: () => void;
  74717. /** Callback used to start pointer down animation */
  74718. pointerDownAnimation: () => void;
  74719. /** Callback used to start pointer up animation */
  74720. pointerUpAnimation: () => void;
  74721. /**
  74722. * An event triggered when the pointer move over the control
  74723. */
  74724. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74725. /**
  74726. * An event triggered when the pointer move out of the control
  74727. */
  74728. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74729. /**
  74730. * An event triggered when the pointer taps the control
  74731. */
  74732. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74733. /**
  74734. * An event triggered when pointer is up
  74735. */
  74736. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74737. /**
  74738. * An event triggered when a control is clicked on (with a mouse)
  74739. */
  74740. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74741. /**
  74742. * An event triggered when pointer enters the control
  74743. */
  74744. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74745. /**
  74746. * Gets or sets the parent container
  74747. */
  74748. parent: BABYLON.Nullable<Container3D>;
  74749. private _behaviors;
  74750. /**
  74751. * Gets the list of attached behaviors
  74752. * @see http://doc.babylonjs.com/features/behaviour
  74753. */
  74754. get behaviors(): BABYLON.Behavior<Control3D>[];
  74755. /**
  74756. * Attach a behavior to the control
  74757. * @see http://doc.babylonjs.com/features/behaviour
  74758. * @param behavior defines the behavior to attach
  74759. * @returns the current control
  74760. */
  74761. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74762. /**
  74763. * Remove an attached behavior
  74764. * @see http://doc.babylonjs.com/features/behaviour
  74765. * @param behavior defines the behavior to attach
  74766. * @returns the current control
  74767. */
  74768. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74769. /**
  74770. * Gets an attached behavior by name
  74771. * @param name defines the name of the behavior to look for
  74772. * @see http://doc.babylonjs.com/features/behaviour
  74773. * @returns null if behavior was not found else the requested behavior
  74774. */
  74775. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74776. /** Gets or sets a boolean indicating if the control is visible */
  74777. get isVisible(): boolean;
  74778. set isVisible(value: boolean);
  74779. /**
  74780. * Creates a new control
  74781. * @param name defines the control name
  74782. */
  74783. constructor(
  74784. /** Defines the control name */
  74785. name?: string | undefined);
  74786. /**
  74787. * Gets a string representing the class name
  74788. */
  74789. get typeName(): string;
  74790. /**
  74791. * Get the current class name of the control.
  74792. * @returns current class name
  74793. */
  74794. getClassName(): string;
  74795. protected _getTypeName(): string;
  74796. /**
  74797. * Gets the transform node used by this control
  74798. */
  74799. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74800. /**
  74801. * Gets the mesh used to render this control
  74802. */
  74803. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74804. /**
  74805. * Link the control as child of the given node
  74806. * @param node defines the node to link to. Use null to unlink the control
  74807. * @returns the current control
  74808. */
  74809. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74810. /** @hidden **/
  74811. _prepareNode(scene: BABYLON.Scene): void;
  74812. /**
  74813. * Node creation.
  74814. * Can be overriden by children
  74815. * @param scene defines the scene where the node must be attached
  74816. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74817. */
  74818. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74819. /**
  74820. * Affect a material to the given mesh
  74821. * @param mesh defines the mesh which will represent the control
  74822. */
  74823. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74824. /** @hidden */
  74825. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74826. /** @hidden */
  74827. _onPointerEnter(target: Control3D): boolean;
  74828. /** @hidden */
  74829. _onPointerOut(target: Control3D): void;
  74830. /** @hidden */
  74831. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74832. /** @hidden */
  74833. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74834. /** @hidden */
  74835. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74836. /** @hidden */
  74837. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74838. /** @hidden */
  74839. _disposeNode(): void;
  74840. /**
  74841. * Releases all associated resources
  74842. */
  74843. dispose(): void;
  74844. }
  74845. }
  74846. declare module BABYLON.GUI {
  74847. /**
  74848. * Class used as a root to all buttons
  74849. */
  74850. export class AbstractButton3D extends Control3D {
  74851. /**
  74852. * Creates a new button
  74853. * @param name defines the control name
  74854. */
  74855. constructor(name?: string);
  74856. protected _getTypeName(): string;
  74857. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74858. }
  74859. }
  74860. declare module BABYLON.GUI {
  74861. /**
  74862. * Class used to create a button in 3D
  74863. */
  74864. export class Button3D extends AbstractButton3D {
  74865. /** @hidden */
  74866. protected _currentMaterial: BABYLON.Material;
  74867. private _facadeTexture;
  74868. private _content;
  74869. private _contentResolution;
  74870. private _contentScaleRatio;
  74871. /**
  74872. * Gets or sets the texture resolution used to render content (512 by default)
  74873. */
  74874. get contentResolution(): BABYLON.int;
  74875. set contentResolution(value: BABYLON.int);
  74876. /**
  74877. * Gets or sets the texture scale ratio used to render content (2 by default)
  74878. */
  74879. get contentScaleRatio(): number;
  74880. set contentScaleRatio(value: number);
  74881. protected _disposeFacadeTexture(): void;
  74882. protected _resetContent(): void;
  74883. /**
  74884. * Creates a new button
  74885. * @param name defines the control name
  74886. */
  74887. constructor(name?: string);
  74888. /**
  74889. * Gets or sets the GUI 2D content used to display the button's facade
  74890. */
  74891. get content(): Control;
  74892. set content(value: Control);
  74893. /**
  74894. * Apply the facade texture (created from the content property).
  74895. * This function can be overloaded by child classes
  74896. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74897. */
  74898. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74899. protected _getTypeName(): string;
  74900. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74901. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74902. /**
  74903. * Releases all associated resources
  74904. */
  74905. dispose(): void;
  74906. }
  74907. }
  74908. declare module BABYLON.GUI {
  74909. /**
  74910. * Abstract class used to create a container panel deployed on the surface of a volume
  74911. */
  74912. export abstract class VolumeBasedPanel extends Container3D {
  74913. private _columns;
  74914. private _rows;
  74915. private _rowThenColum;
  74916. private _orientation;
  74917. protected _cellWidth: number;
  74918. protected _cellHeight: number;
  74919. /**
  74920. * Gets or sets the distance between elements
  74921. */
  74922. margin: number;
  74923. /**
  74924. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74925. * | Value | Type | Description |
  74926. * | ----- | ----------------------------------- | ----------- |
  74927. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74928. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74929. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74930. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74931. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74932. */
  74933. get orientation(): number;
  74934. set orientation(value: number);
  74935. /**
  74936. * Gets or sets the number of columns requested (10 by default).
  74937. * The panel will automatically compute the number of rows based on number of child controls.
  74938. */
  74939. get columns(): BABYLON.int;
  74940. set columns(value: BABYLON.int);
  74941. /**
  74942. * Gets or sets a the number of rows requested.
  74943. * The panel will automatically compute the number of columns based on number of child controls.
  74944. */
  74945. get rows(): BABYLON.int;
  74946. set rows(value: BABYLON.int);
  74947. /**
  74948. * Creates new VolumeBasedPanel
  74949. */
  74950. constructor();
  74951. protected _arrangeChildren(): void;
  74952. /** Child classes must implement this function to provide correct control positioning */
  74953. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74954. /** Child classes can implement this function to provide additional processing */
  74955. protected _finalProcessing(): void;
  74956. }
  74957. }
  74958. declare module BABYLON.GUI {
  74959. /**
  74960. * Class used to create a container panel deployed on the surface of a cylinder
  74961. */
  74962. export class CylinderPanel extends VolumeBasedPanel {
  74963. private _radius;
  74964. /**
  74965. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74966. */
  74967. get radius(): BABYLON.float;
  74968. set radius(value: BABYLON.float);
  74969. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74970. private _cylindricalMapping;
  74971. }
  74972. }
  74973. declare module BABYLON.GUI {
  74974. /** @hidden */
  74975. export var fluentVertexShader: {
  74976. name: string;
  74977. shader: string;
  74978. };
  74979. }
  74980. declare module BABYLON.GUI {
  74981. /** @hidden */
  74982. export var fluentPixelShader: {
  74983. name: string;
  74984. shader: string;
  74985. };
  74986. }
  74987. declare module BABYLON.GUI {
  74988. /** @hidden */
  74989. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74990. INNERGLOW: boolean;
  74991. BORDER: boolean;
  74992. HOVERLIGHT: boolean;
  74993. TEXTURE: boolean;
  74994. constructor();
  74995. }
  74996. /**
  74997. * Class used to render controls with fluent desgin
  74998. */
  74999. export class FluentMaterial extends BABYLON.PushMaterial {
  75000. /**
  75001. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  75002. */
  75003. innerGlowColorIntensity: number;
  75004. /**
  75005. * Gets or sets the inner glow color (white by default)
  75006. */
  75007. innerGlowColor: BABYLON.Color3;
  75008. /**
  75009. * Gets or sets alpha value (default is 1.0)
  75010. */
  75011. alpha: number;
  75012. /**
  75013. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  75014. */
  75015. albedoColor: BABYLON.Color3;
  75016. /**
  75017. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  75018. */
  75019. renderBorders: boolean;
  75020. /**
  75021. * Gets or sets border width (default is 0.5)
  75022. */
  75023. borderWidth: number;
  75024. /**
  75025. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  75026. */
  75027. edgeSmoothingValue: number;
  75028. /**
  75029. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  75030. */
  75031. borderMinValue: number;
  75032. /**
  75033. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  75034. */
  75035. renderHoverLight: boolean;
  75036. /**
  75037. * Gets or sets the radius used to render the hover light (default is 1.0)
  75038. */
  75039. hoverRadius: number;
  75040. /**
  75041. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  75042. */
  75043. hoverColor: BABYLON.Color4;
  75044. /**
  75045. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  75046. */
  75047. hoverPosition: BABYLON.Vector3;
  75048. private _albedoTexture;
  75049. /** Gets or sets the texture to use for albedo color */
  75050. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75051. /**
  75052. * Creates a new Fluent material
  75053. * @param name defines the name of the material
  75054. * @param scene defines the hosting scene
  75055. */
  75056. constructor(name: string, scene: BABYLON.Scene);
  75057. needAlphaBlending(): boolean;
  75058. needAlphaTesting(): boolean;
  75059. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75061. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75062. getActiveTextures(): BABYLON.BaseTexture[];
  75063. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75064. dispose(forceDisposeEffect?: boolean): void;
  75065. clone(name: string): FluentMaterial;
  75066. serialize(): any;
  75067. getClassName(): string;
  75068. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  75069. }
  75070. }
  75071. declare module BABYLON.GUI {
  75072. /**
  75073. * Class used to create a holographic button in 3D
  75074. */
  75075. export class HolographicButton extends Button3D {
  75076. private _backPlate;
  75077. private _textPlate;
  75078. private _frontPlate;
  75079. private _text;
  75080. private _imageUrl;
  75081. private _shareMaterials;
  75082. private _frontMaterial;
  75083. private _backMaterial;
  75084. private _plateMaterial;
  75085. private _pickedPointObserver;
  75086. private _tooltipFade;
  75087. private _tooltipTextBlock;
  75088. private _tooltipTexture;
  75089. private _tooltipMesh;
  75090. private _tooltipHoverObserver;
  75091. private _tooltipOutObserver;
  75092. private _disposeTooltip;
  75093. /**
  75094. * Rendering ground id of all the mesh in the button
  75095. */
  75096. set renderingGroupId(id: number);
  75097. get renderingGroupId(): number;
  75098. /**
  75099. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  75100. */
  75101. set tooltipText(text: BABYLON.Nullable<string>);
  75102. get tooltipText(): BABYLON.Nullable<string>;
  75103. /**
  75104. * Gets or sets text for the button
  75105. */
  75106. get text(): string;
  75107. set text(value: string);
  75108. /**
  75109. * Gets or sets the image url for the button
  75110. */
  75111. get imageUrl(): string;
  75112. set imageUrl(value: string);
  75113. /**
  75114. * Gets the back material used by this button
  75115. */
  75116. get backMaterial(): FluentMaterial;
  75117. /**
  75118. * Gets the front material used by this button
  75119. */
  75120. get frontMaterial(): FluentMaterial;
  75121. /**
  75122. * Gets the plate material used by this button
  75123. */
  75124. get plateMaterial(): BABYLON.StandardMaterial;
  75125. /**
  75126. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75127. */
  75128. get shareMaterials(): boolean;
  75129. /**
  75130. * Creates a new button
  75131. * @param name defines the control name
  75132. */
  75133. constructor(name?: string, shareMaterials?: boolean);
  75134. protected _getTypeName(): string;
  75135. private _rebuildContent;
  75136. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75137. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75138. private _createBackMaterial;
  75139. private _createFrontMaterial;
  75140. private _createPlateMaterial;
  75141. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75142. /**
  75143. * Releases all associated resources
  75144. */
  75145. dispose(): void;
  75146. }
  75147. }
  75148. declare module BABYLON.GUI {
  75149. /**
  75150. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75151. */
  75152. export class MeshButton3D extends Button3D {
  75153. /** @hidden */
  75154. protected _currentMesh: BABYLON.Mesh;
  75155. /**
  75156. * Creates a new 3D button based on a mesh
  75157. * @param mesh mesh to become a 3D button
  75158. * @param name defines the control name
  75159. */
  75160. constructor(mesh: BABYLON.Mesh, name?: string);
  75161. protected _getTypeName(): string;
  75162. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75163. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75164. }
  75165. }
  75166. declare module BABYLON.GUI {
  75167. /**
  75168. * Class used to create a container panel deployed on the surface of a plane
  75169. */
  75170. export class PlanePanel extends VolumeBasedPanel {
  75171. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75172. }
  75173. }
  75174. declare module BABYLON.GUI {
  75175. /**
  75176. * Class used to create a container panel where items get randomized planar mapping
  75177. */
  75178. export class ScatterPanel extends VolumeBasedPanel {
  75179. private _iteration;
  75180. /**
  75181. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75182. */
  75183. get iteration(): BABYLON.float;
  75184. set iteration(value: BABYLON.float);
  75185. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75186. private _scatterMapping;
  75187. protected _finalProcessing(): void;
  75188. }
  75189. }
  75190. declare module BABYLON.GUI {
  75191. /**
  75192. * Class used to create a container panel deployed on the surface of a sphere
  75193. */
  75194. export class SpherePanel extends VolumeBasedPanel {
  75195. private _radius;
  75196. /**
  75197. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75198. */
  75199. get radius(): BABYLON.float;
  75200. set radius(value: BABYLON.float);
  75201. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75202. private _sphericalMapping;
  75203. }
  75204. }
  75205. declare module BABYLON.GUI {
  75206. /**
  75207. * Class used to create a stack panel in 3D on XY plane
  75208. */
  75209. export class StackPanel3D extends Container3D {
  75210. private _isVertical;
  75211. /**
  75212. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75213. */
  75214. get isVertical(): boolean;
  75215. set isVertical(value: boolean);
  75216. /**
  75217. * Gets or sets the distance between elements
  75218. */
  75219. margin: number;
  75220. /**
  75221. * Creates new StackPanel
  75222. * @param isVertical
  75223. */
  75224. constructor(isVertical?: boolean);
  75225. protected _arrangeChildren(): void;
  75226. }
  75227. }
  75228. declare module BABYLON {
  75229. /**
  75230. * Configuration for glTF validation
  75231. */
  75232. export interface IGLTFValidationConfiguration {
  75233. /**
  75234. * The url of the glTF validator.
  75235. */
  75236. url: string;
  75237. }
  75238. /**
  75239. * glTF validation
  75240. */
  75241. export class GLTFValidation {
  75242. /**
  75243. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75244. */
  75245. static Configuration: IGLTFValidationConfiguration;
  75246. private static _LoadScriptPromise;
  75247. /**
  75248. * Validate a glTF asset using the glTF-Validator.
  75249. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75250. * @param rootUrl The root url for the glTF
  75251. * @param fileName The file name for the glTF
  75252. * @param getExternalResource The callback to get external resources for the glTF validator
  75253. * @returns A promise that resolves with the glTF validation results once complete
  75254. */
  75255. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75256. }
  75257. }
  75258. declare module BABYLON {
  75259. /**
  75260. * Mode that determines the coordinate system to use.
  75261. */
  75262. export enum GLTFLoaderCoordinateSystemMode {
  75263. /**
  75264. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75265. */
  75266. AUTO = 0,
  75267. /**
  75268. * Sets the useRightHandedSystem flag on the scene.
  75269. */
  75270. FORCE_RIGHT_HANDED = 1
  75271. }
  75272. /**
  75273. * Mode that determines what animations will start.
  75274. */
  75275. export enum GLTFLoaderAnimationStartMode {
  75276. /**
  75277. * No animation will start.
  75278. */
  75279. NONE = 0,
  75280. /**
  75281. * The first animation will start.
  75282. */
  75283. FIRST = 1,
  75284. /**
  75285. * All animations will start.
  75286. */
  75287. ALL = 2
  75288. }
  75289. /**
  75290. * Interface that contains the data for the glTF asset.
  75291. */
  75292. export interface IGLTFLoaderData {
  75293. /**
  75294. * The object that represents the glTF JSON.
  75295. */
  75296. json: Object;
  75297. /**
  75298. * The BIN chunk of a binary glTF.
  75299. */
  75300. bin: Nullable<IDataBuffer>;
  75301. }
  75302. /**
  75303. * Interface for extending the loader.
  75304. */
  75305. export interface IGLTFLoaderExtension {
  75306. /**
  75307. * The name of this extension.
  75308. */
  75309. readonly name: string;
  75310. /**
  75311. * Defines whether this extension is enabled.
  75312. */
  75313. enabled: boolean;
  75314. /**
  75315. * Defines the order of this extension.
  75316. * The loader sorts the extensions using these values when loading.
  75317. */
  75318. order?: number;
  75319. }
  75320. /**
  75321. * Loader state.
  75322. */
  75323. export enum GLTFLoaderState {
  75324. /**
  75325. * The asset is loading.
  75326. */
  75327. LOADING = 0,
  75328. /**
  75329. * The asset is ready for rendering.
  75330. */
  75331. READY = 1,
  75332. /**
  75333. * The asset is completely loaded.
  75334. */
  75335. COMPLETE = 2
  75336. }
  75337. /** @hidden */
  75338. export interface IImportMeshAsyncOutput {
  75339. meshes: AbstractMesh[];
  75340. particleSystems: IParticleSystem[];
  75341. skeletons: Skeleton[];
  75342. animationGroups: AnimationGroup[];
  75343. lights: Light[];
  75344. transformNodes: TransformNode[];
  75345. }
  75346. /** @hidden */
  75347. export interface IGLTFLoader extends IDisposable {
  75348. readonly state: Nullable<GLTFLoaderState>;
  75349. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75350. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75351. }
  75352. /**
  75353. * File loader for loading glTF files into a scene.
  75354. */
  75355. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75356. /** @hidden */
  75357. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75358. /** @hidden */
  75359. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75360. /**
  75361. * Raised when the asset has been parsed
  75362. */
  75363. onParsedObservable: Observable<IGLTFLoaderData>;
  75364. private _onParsedObserver;
  75365. /**
  75366. * Raised when the asset has been parsed
  75367. */
  75368. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75369. /**
  75370. * 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.
  75371. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75372. * Defaults to true.
  75373. * @hidden
  75374. */
  75375. static IncrementalLoading: boolean;
  75376. /**
  75377. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75378. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75379. * @hidden
  75380. */
  75381. static HomogeneousCoordinates: boolean;
  75382. /**
  75383. * The coordinate system mode. Defaults to AUTO.
  75384. */
  75385. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75386. /**
  75387. * The animation start mode. Defaults to FIRST.
  75388. */
  75389. animationStartMode: GLTFLoaderAnimationStartMode;
  75390. /**
  75391. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75392. */
  75393. compileMaterials: boolean;
  75394. /**
  75395. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75396. */
  75397. useClipPlane: boolean;
  75398. /**
  75399. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75400. */
  75401. compileShadowGenerators: boolean;
  75402. /**
  75403. * Defines if the Alpha blended materials are only applied as coverage.
  75404. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75405. * If true, no extra effects are applied to transparent pixels.
  75406. */
  75407. transparencyAsCoverage: boolean;
  75408. /**
  75409. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75410. * Enabling will disable offline support and glTF validator.
  75411. * Defaults to false.
  75412. */
  75413. useRangeRequests: boolean;
  75414. /**
  75415. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75416. */
  75417. createInstances: boolean;
  75418. /**
  75419. * Function called before loading a url referenced by the asset.
  75420. */
  75421. preprocessUrlAsync: (url: string) => Promise<string>;
  75422. /**
  75423. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75424. */
  75425. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75426. private _onMeshLoadedObserver;
  75427. /**
  75428. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75429. */
  75430. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75431. /**
  75432. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75433. */
  75434. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75435. private _onTextureLoadedObserver;
  75436. /**
  75437. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75438. */
  75439. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75440. /**
  75441. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75442. */
  75443. readonly onMaterialLoadedObservable: Observable<Material>;
  75444. private _onMaterialLoadedObserver;
  75445. /**
  75446. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75447. */
  75448. set onMaterialLoaded(callback: (material: Material) => void);
  75449. /**
  75450. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75451. */
  75452. readonly onCameraLoadedObservable: Observable<Camera>;
  75453. private _onCameraLoadedObserver;
  75454. /**
  75455. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75456. */
  75457. set onCameraLoaded(callback: (camera: Camera) => void);
  75458. /**
  75459. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75460. * For assets with LODs, raised when all of the LODs are complete.
  75461. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75462. */
  75463. readonly onCompleteObservable: Observable<void>;
  75464. private _onCompleteObserver;
  75465. /**
  75466. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75467. * For assets with LODs, raised when all of the LODs are complete.
  75468. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75469. */
  75470. set onComplete(callback: () => void);
  75471. /**
  75472. * Observable raised when an error occurs.
  75473. */
  75474. readonly onErrorObservable: Observable<any>;
  75475. private _onErrorObserver;
  75476. /**
  75477. * Callback raised when an error occurs.
  75478. */
  75479. set onError(callback: (reason: any) => void);
  75480. /**
  75481. * Observable raised after the loader is disposed.
  75482. */
  75483. readonly onDisposeObservable: Observable<void>;
  75484. private _onDisposeObserver;
  75485. /**
  75486. * Callback raised after the loader is disposed.
  75487. */
  75488. set onDispose(callback: () => void);
  75489. /**
  75490. * Observable raised after a loader extension is created.
  75491. * Set additional options for a loader extension in this event.
  75492. */
  75493. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75494. private _onExtensionLoadedObserver;
  75495. /**
  75496. * Callback raised after a loader extension is created.
  75497. */
  75498. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75499. /**
  75500. * Defines if the loader logging is enabled.
  75501. */
  75502. get loggingEnabled(): boolean;
  75503. set loggingEnabled(value: boolean);
  75504. /**
  75505. * Defines if the loader should capture performance counters.
  75506. */
  75507. get capturePerformanceCounters(): boolean;
  75508. set capturePerformanceCounters(value: boolean);
  75509. /**
  75510. * Defines if the loader should validate the asset.
  75511. */
  75512. validate: boolean;
  75513. /**
  75514. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75515. */
  75516. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75517. private _onValidatedObserver;
  75518. /**
  75519. * Callback raised after a loader extension is created.
  75520. */
  75521. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75522. private _loader;
  75523. /**
  75524. * Name of the loader ("gltf")
  75525. */
  75526. name: string;
  75527. /** @hidden */
  75528. extensions: ISceneLoaderPluginExtensions;
  75529. /**
  75530. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75531. */
  75532. dispose(): void;
  75533. /** @hidden */
  75534. _clear(): void;
  75535. /** @hidden */
  75536. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75537. /** @hidden */
  75538. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75539. /** @hidden */
  75540. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75541. meshes: AbstractMesh[];
  75542. particleSystems: IParticleSystem[];
  75543. skeletons: Skeleton[];
  75544. animationGroups: AnimationGroup[];
  75545. }>;
  75546. /** @hidden */
  75547. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75548. /** @hidden */
  75549. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75550. /** @hidden */
  75551. canDirectLoad(data: string): boolean;
  75552. /** @hidden */
  75553. directLoad(scene: Scene, data: string): any;
  75554. /**
  75555. * The callback that allows custom handling of the root url based on the response url.
  75556. * @param rootUrl the original root url
  75557. * @param responseURL the response url if available
  75558. * @returns the new root url
  75559. */
  75560. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75561. /** @hidden */
  75562. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75563. /**
  75564. * The loader state or null if the loader is not active.
  75565. */
  75566. get loaderState(): Nullable<GLTFLoaderState>;
  75567. /**
  75568. * Returns a promise that resolves when the asset is completely loaded.
  75569. * @returns a promise that resolves when the asset is completely loaded.
  75570. */
  75571. whenCompleteAsync(): Promise<void>;
  75572. private _validate;
  75573. private _getLoader;
  75574. private _parseJson;
  75575. private _unpackBinaryAsync;
  75576. private _unpackBinaryV1Async;
  75577. private _unpackBinaryV2Async;
  75578. private static _parseVersion;
  75579. private static _compareVersion;
  75580. private static readonly _logSpaces;
  75581. private _logIndentLevel;
  75582. private _loggingEnabled;
  75583. /** @hidden */
  75584. _log: (message: string) => void;
  75585. /** @hidden */
  75586. _logOpen(message: string): void;
  75587. /** @hidden */
  75588. _logClose(): void;
  75589. private _logEnabled;
  75590. private _logDisabled;
  75591. private _capturePerformanceCounters;
  75592. /** @hidden */
  75593. _startPerformanceCounter: (counterName: string) => void;
  75594. /** @hidden */
  75595. _endPerformanceCounter: (counterName: string) => void;
  75596. private _startPerformanceCounterEnabled;
  75597. private _startPerformanceCounterDisabled;
  75598. private _endPerformanceCounterEnabled;
  75599. private _endPerformanceCounterDisabled;
  75600. }
  75601. }
  75602. declare module BABYLON.GLTF1 {
  75603. /**
  75604. * Enums
  75605. * @hidden
  75606. */
  75607. export enum EComponentType {
  75608. BYTE = 5120,
  75609. UNSIGNED_BYTE = 5121,
  75610. SHORT = 5122,
  75611. UNSIGNED_SHORT = 5123,
  75612. FLOAT = 5126
  75613. }
  75614. /** @hidden */
  75615. export enum EShaderType {
  75616. FRAGMENT = 35632,
  75617. VERTEX = 35633
  75618. }
  75619. /** @hidden */
  75620. export enum EParameterType {
  75621. BYTE = 5120,
  75622. UNSIGNED_BYTE = 5121,
  75623. SHORT = 5122,
  75624. UNSIGNED_SHORT = 5123,
  75625. INT = 5124,
  75626. UNSIGNED_INT = 5125,
  75627. FLOAT = 5126,
  75628. FLOAT_VEC2 = 35664,
  75629. FLOAT_VEC3 = 35665,
  75630. FLOAT_VEC4 = 35666,
  75631. INT_VEC2 = 35667,
  75632. INT_VEC3 = 35668,
  75633. INT_VEC4 = 35669,
  75634. BOOL = 35670,
  75635. BOOL_VEC2 = 35671,
  75636. BOOL_VEC3 = 35672,
  75637. BOOL_VEC4 = 35673,
  75638. FLOAT_MAT2 = 35674,
  75639. FLOAT_MAT3 = 35675,
  75640. FLOAT_MAT4 = 35676,
  75641. SAMPLER_2D = 35678
  75642. }
  75643. /** @hidden */
  75644. export enum ETextureWrapMode {
  75645. CLAMP_TO_EDGE = 33071,
  75646. MIRRORED_REPEAT = 33648,
  75647. REPEAT = 10497
  75648. }
  75649. /** @hidden */
  75650. export enum ETextureFilterType {
  75651. NEAREST = 9728,
  75652. LINEAR = 9728,
  75653. NEAREST_MIPMAP_NEAREST = 9984,
  75654. LINEAR_MIPMAP_NEAREST = 9985,
  75655. NEAREST_MIPMAP_LINEAR = 9986,
  75656. LINEAR_MIPMAP_LINEAR = 9987
  75657. }
  75658. /** @hidden */
  75659. export enum ETextureFormat {
  75660. ALPHA = 6406,
  75661. RGB = 6407,
  75662. RGBA = 6408,
  75663. LUMINANCE = 6409,
  75664. LUMINANCE_ALPHA = 6410
  75665. }
  75666. /** @hidden */
  75667. export enum ECullingType {
  75668. FRONT = 1028,
  75669. BACK = 1029,
  75670. FRONT_AND_BACK = 1032
  75671. }
  75672. /** @hidden */
  75673. export enum EBlendingFunction {
  75674. ZERO = 0,
  75675. ONE = 1,
  75676. SRC_COLOR = 768,
  75677. ONE_MINUS_SRC_COLOR = 769,
  75678. DST_COLOR = 774,
  75679. ONE_MINUS_DST_COLOR = 775,
  75680. SRC_ALPHA = 770,
  75681. ONE_MINUS_SRC_ALPHA = 771,
  75682. DST_ALPHA = 772,
  75683. ONE_MINUS_DST_ALPHA = 773,
  75684. CONSTANT_COLOR = 32769,
  75685. ONE_MINUS_CONSTANT_COLOR = 32770,
  75686. CONSTANT_ALPHA = 32771,
  75687. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75688. SRC_ALPHA_SATURATE = 776
  75689. }
  75690. /** @hidden */
  75691. export interface IGLTFProperty {
  75692. extensions?: {
  75693. [key: string]: any;
  75694. };
  75695. extras?: Object;
  75696. }
  75697. /** @hidden */
  75698. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75699. name?: string;
  75700. }
  75701. /** @hidden */
  75702. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75703. bufferView: string;
  75704. byteOffset: number;
  75705. byteStride: number;
  75706. count: number;
  75707. type: string;
  75708. componentType: EComponentType;
  75709. max?: number[];
  75710. min?: number[];
  75711. name?: string;
  75712. }
  75713. /** @hidden */
  75714. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75715. buffer: string;
  75716. byteOffset: number;
  75717. byteLength: number;
  75718. byteStride: number;
  75719. target?: number;
  75720. }
  75721. /** @hidden */
  75722. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75723. uri: string;
  75724. byteLength?: number;
  75725. type?: string;
  75726. }
  75727. /** @hidden */
  75728. export interface IGLTFShader extends IGLTFChildRootProperty {
  75729. uri: string;
  75730. type: EShaderType;
  75731. }
  75732. /** @hidden */
  75733. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75734. attributes: string[];
  75735. fragmentShader: string;
  75736. vertexShader: string;
  75737. }
  75738. /** @hidden */
  75739. export interface IGLTFTechniqueParameter {
  75740. type: number;
  75741. count?: number;
  75742. semantic?: string;
  75743. node?: string;
  75744. value?: number | boolean | string | Array<any>;
  75745. source?: string;
  75746. babylonValue?: any;
  75747. }
  75748. /** @hidden */
  75749. export interface IGLTFTechniqueCommonProfile {
  75750. lightingModel: string;
  75751. texcoordBindings: Object;
  75752. parameters?: Array<any>;
  75753. }
  75754. /** @hidden */
  75755. export interface IGLTFTechniqueStatesFunctions {
  75756. blendColor?: number[];
  75757. blendEquationSeparate?: number[];
  75758. blendFuncSeparate?: number[];
  75759. colorMask: boolean[];
  75760. cullFace: number[];
  75761. }
  75762. /** @hidden */
  75763. export interface IGLTFTechniqueStates {
  75764. enable: number[];
  75765. functions: IGLTFTechniqueStatesFunctions;
  75766. }
  75767. /** @hidden */
  75768. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75769. parameters: {
  75770. [key: string]: IGLTFTechniqueParameter;
  75771. };
  75772. program: string;
  75773. attributes: {
  75774. [key: string]: string;
  75775. };
  75776. uniforms: {
  75777. [key: string]: string;
  75778. };
  75779. states: IGLTFTechniqueStates;
  75780. }
  75781. /** @hidden */
  75782. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75783. technique?: string;
  75784. values: string[];
  75785. }
  75786. /** @hidden */
  75787. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75788. attributes: {
  75789. [key: string]: string;
  75790. };
  75791. indices: string;
  75792. material: string;
  75793. mode?: number;
  75794. }
  75795. /** @hidden */
  75796. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75797. primitives: IGLTFMeshPrimitive[];
  75798. }
  75799. /** @hidden */
  75800. export interface IGLTFImage extends IGLTFChildRootProperty {
  75801. uri: string;
  75802. }
  75803. /** @hidden */
  75804. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75805. magFilter?: number;
  75806. minFilter?: number;
  75807. wrapS?: number;
  75808. wrapT?: number;
  75809. }
  75810. /** @hidden */
  75811. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75812. sampler: string;
  75813. source: string;
  75814. format?: ETextureFormat;
  75815. internalFormat?: ETextureFormat;
  75816. target?: number;
  75817. type?: number;
  75818. babylonTexture?: Texture;
  75819. }
  75820. /** @hidden */
  75821. export interface IGLTFAmbienLight {
  75822. color?: number[];
  75823. }
  75824. /** @hidden */
  75825. export interface IGLTFDirectionalLight {
  75826. color?: number[];
  75827. }
  75828. /** @hidden */
  75829. export interface IGLTFPointLight {
  75830. color?: number[];
  75831. constantAttenuation?: number;
  75832. linearAttenuation?: number;
  75833. quadraticAttenuation?: number;
  75834. }
  75835. /** @hidden */
  75836. export interface IGLTFSpotLight {
  75837. color?: number[];
  75838. constantAttenuation?: number;
  75839. fallOfAngle?: number;
  75840. fallOffExponent?: number;
  75841. linearAttenuation?: number;
  75842. quadraticAttenuation?: number;
  75843. }
  75844. /** @hidden */
  75845. export interface IGLTFLight extends IGLTFChildRootProperty {
  75846. type: string;
  75847. }
  75848. /** @hidden */
  75849. export interface IGLTFCameraOrthographic {
  75850. xmag: number;
  75851. ymag: number;
  75852. zfar: number;
  75853. znear: number;
  75854. }
  75855. /** @hidden */
  75856. export interface IGLTFCameraPerspective {
  75857. aspectRatio: number;
  75858. yfov: number;
  75859. zfar: number;
  75860. znear: number;
  75861. }
  75862. /** @hidden */
  75863. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75864. type: string;
  75865. }
  75866. /** @hidden */
  75867. export interface IGLTFAnimationChannelTarget {
  75868. id: string;
  75869. path: string;
  75870. }
  75871. /** @hidden */
  75872. export interface IGLTFAnimationChannel {
  75873. sampler: string;
  75874. target: IGLTFAnimationChannelTarget;
  75875. }
  75876. /** @hidden */
  75877. export interface IGLTFAnimationSampler {
  75878. input: string;
  75879. output: string;
  75880. interpolation?: string;
  75881. }
  75882. /** @hidden */
  75883. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75884. channels?: IGLTFAnimationChannel[];
  75885. parameters?: {
  75886. [key: string]: string;
  75887. };
  75888. samplers?: {
  75889. [key: string]: IGLTFAnimationSampler;
  75890. };
  75891. }
  75892. /** @hidden */
  75893. export interface IGLTFNodeInstanceSkin {
  75894. skeletons: string[];
  75895. skin: string;
  75896. meshes: string[];
  75897. }
  75898. /** @hidden */
  75899. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75900. bindShapeMatrix: number[];
  75901. inverseBindMatrices: string;
  75902. jointNames: string[];
  75903. babylonSkeleton?: Skeleton;
  75904. }
  75905. /** @hidden */
  75906. export interface IGLTFNode extends IGLTFChildRootProperty {
  75907. camera?: string;
  75908. children: string[];
  75909. skin?: string;
  75910. jointName?: string;
  75911. light?: string;
  75912. matrix: number[];
  75913. mesh?: string;
  75914. meshes?: string[];
  75915. rotation?: number[];
  75916. scale?: number[];
  75917. translation?: number[];
  75918. babylonNode?: Node;
  75919. }
  75920. /** @hidden */
  75921. export interface IGLTFScene extends IGLTFChildRootProperty {
  75922. nodes: string[];
  75923. }
  75924. /** @hidden */
  75925. export interface IGLTFRuntime {
  75926. extensions: {
  75927. [key: string]: any;
  75928. };
  75929. accessors: {
  75930. [key: string]: IGLTFAccessor;
  75931. };
  75932. buffers: {
  75933. [key: string]: IGLTFBuffer;
  75934. };
  75935. bufferViews: {
  75936. [key: string]: IGLTFBufferView;
  75937. };
  75938. meshes: {
  75939. [key: string]: IGLTFMesh;
  75940. };
  75941. lights: {
  75942. [key: string]: IGLTFLight;
  75943. };
  75944. cameras: {
  75945. [key: string]: IGLTFCamera;
  75946. };
  75947. nodes: {
  75948. [key: string]: IGLTFNode;
  75949. };
  75950. images: {
  75951. [key: string]: IGLTFImage;
  75952. };
  75953. textures: {
  75954. [key: string]: IGLTFTexture;
  75955. };
  75956. shaders: {
  75957. [key: string]: IGLTFShader;
  75958. };
  75959. programs: {
  75960. [key: string]: IGLTFProgram;
  75961. };
  75962. samplers: {
  75963. [key: string]: IGLTFSampler;
  75964. };
  75965. techniques: {
  75966. [key: string]: IGLTFTechnique;
  75967. };
  75968. materials: {
  75969. [key: string]: IGLTFMaterial;
  75970. };
  75971. animations: {
  75972. [key: string]: IGLTFAnimation;
  75973. };
  75974. skins: {
  75975. [key: string]: IGLTFSkins;
  75976. };
  75977. currentScene?: Object;
  75978. scenes: {
  75979. [key: string]: IGLTFScene;
  75980. };
  75981. extensionsUsed: string[];
  75982. extensionsRequired?: string[];
  75983. buffersCount: number;
  75984. shaderscount: number;
  75985. scene: Scene;
  75986. rootUrl: string;
  75987. loadedBufferCount: number;
  75988. loadedBufferViews: {
  75989. [name: string]: ArrayBufferView;
  75990. };
  75991. loadedShaderCount: number;
  75992. importOnlyMeshes: boolean;
  75993. importMeshesNames?: string[];
  75994. dummyNodes: Node[];
  75995. forAssetContainer: boolean;
  75996. }
  75997. /** @hidden */
  75998. export interface INodeToRoot {
  75999. bone: Bone;
  76000. node: IGLTFNode;
  76001. id: string;
  76002. }
  76003. /** @hidden */
  76004. export interface IJointNode {
  76005. node: IGLTFNode;
  76006. id: string;
  76007. }
  76008. }
  76009. declare module BABYLON.GLTF1 {
  76010. /**
  76011. * Utils functions for GLTF
  76012. * @hidden
  76013. */
  76014. export class GLTFUtils {
  76015. /**
  76016. * Sets the given "parameter" matrix
  76017. * @param scene: the Scene object
  76018. * @param source: the source node where to pick the matrix
  76019. * @param parameter: the GLTF technique parameter
  76020. * @param uniformName: the name of the shader's uniform
  76021. * @param shaderMaterial: the shader material
  76022. */
  76023. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  76024. /**
  76025. * Sets the given "parameter" matrix
  76026. * @param shaderMaterial: the shader material
  76027. * @param uniform: the name of the shader's uniform
  76028. * @param value: the value of the uniform
  76029. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  76030. */
  76031. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  76032. /**
  76033. * Returns the wrap mode of the texture
  76034. * @param mode: the mode value
  76035. */
  76036. static GetWrapMode(mode: number): number;
  76037. /**
  76038. * Returns the byte stride giving an accessor
  76039. * @param accessor: the GLTF accessor objet
  76040. */
  76041. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  76042. /**
  76043. * Returns the texture filter mode giving a mode value
  76044. * @param mode: the filter mode value
  76045. */
  76046. static GetTextureFilterMode(mode: number): ETextureFilterType;
  76047. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  76048. /**
  76049. * Returns a buffer from its accessor
  76050. * @param gltfRuntime: the GLTF runtime
  76051. * @param accessor: the GLTF accessor
  76052. */
  76053. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  76054. /**
  76055. * Decodes a buffer view into a string
  76056. * @param view: the buffer view
  76057. */
  76058. static DecodeBufferToText(view: ArrayBufferView): string;
  76059. /**
  76060. * Returns the default material of gltf. Related to
  76061. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  76062. * @param scene: the Babylon.js scene
  76063. */
  76064. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  76065. private static _DefaultMaterial;
  76066. }
  76067. }
  76068. declare module BABYLON.GLTF1 {
  76069. /**
  76070. * Implementation of the base glTF spec
  76071. * @hidden
  76072. */
  76073. export class GLTFLoaderBase {
  76074. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  76075. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76076. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  76077. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76078. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  76079. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76080. }
  76081. /**
  76082. * glTF V1 Loader
  76083. * @hidden
  76084. */
  76085. export class GLTFLoader implements IGLTFLoader {
  76086. static Extensions: {
  76087. [name: string]: GLTFLoaderExtension;
  76088. };
  76089. static RegisterExtension(extension: GLTFLoaderExtension): void;
  76090. state: Nullable<GLTFLoaderState>;
  76091. dispose(): void;
  76092. private _importMeshAsync;
  76093. /**
  76094. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  76095. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76096. * @param scene the scene the meshes should be added to
  76097. * @param forAssetContainer defines if the entities must be stored in the scene
  76098. * @param data gltf data containing information of the meshes in a loaded file
  76099. * @param rootUrl root url to load from
  76100. * @param onProgress event that fires when loading progress has occured
  76101. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76102. */
  76103. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  76104. private _loadAsync;
  76105. /**
  76106. * Imports all objects from a loaded gltf file and adds them to the scene
  76107. * @param scene the scene the objects should be added to
  76108. * @param data gltf data containing information of the meshes in a loaded file
  76109. * @param rootUrl root url to load from
  76110. * @param onProgress event that fires when loading progress has occured
  76111. * @returns a promise which completes when objects have been loaded to the scene
  76112. */
  76113. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  76114. private _loadShadersAsync;
  76115. private _loadBuffersAsync;
  76116. private _createNodes;
  76117. }
  76118. /** @hidden */
  76119. export abstract class GLTFLoaderExtension {
  76120. private _name;
  76121. constructor(name: string);
  76122. get name(): string;
  76123. /**
  76124. * Defines an override for loading the runtime
  76125. * Return true to stop further extensions from loading the runtime
  76126. */
  76127. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76128. /**
  76129. * Defines an onverride for creating gltf runtime
  76130. * Return true to stop further extensions from creating the runtime
  76131. */
  76132. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76133. /**
  76134. * Defines an override for loading buffers
  76135. * Return true to stop further extensions from loading this buffer
  76136. */
  76137. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76138. /**
  76139. * Defines an override for loading texture buffers
  76140. * Return true to stop further extensions from loading this texture data
  76141. */
  76142. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76143. /**
  76144. * Defines an override for creating textures
  76145. * Return true to stop further extensions from loading this texture
  76146. */
  76147. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76148. /**
  76149. * Defines an override for loading shader strings
  76150. * Return true to stop further extensions from loading this shader data
  76151. */
  76152. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76153. /**
  76154. * Defines an override for loading materials
  76155. * Return true to stop further extensions from loading this material
  76156. */
  76157. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76158. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76159. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76160. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76161. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76162. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76163. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76164. private static LoadTextureBufferAsync;
  76165. private static CreateTextureAsync;
  76166. private static ApplyExtensions;
  76167. }
  76168. }
  76169. declare module BABYLON.GLTF1 {
  76170. /** @hidden */
  76171. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76172. private _bin;
  76173. constructor();
  76174. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76175. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76176. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76177. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76178. }
  76179. }
  76180. declare module BABYLON.GLTF1 {
  76181. /** @hidden */
  76182. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76183. constructor();
  76184. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76185. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76186. private _loadTexture;
  76187. }
  76188. }
  76189. declare module BABYLON.GLTF2.Loader {
  76190. /**
  76191. * Loader interface with an index field.
  76192. */
  76193. export interface IArrayItem {
  76194. /**
  76195. * The index of this item in the array.
  76196. */
  76197. index: number;
  76198. }
  76199. /**
  76200. * Loader interface with additional members.
  76201. */
  76202. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76203. /** @hidden */
  76204. _data?: Promise<ArrayBufferView>;
  76205. /** @hidden */
  76206. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76207. }
  76208. /**
  76209. * Loader interface with additional members.
  76210. */
  76211. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76212. }
  76213. /** @hidden */
  76214. export interface _IAnimationSamplerData {
  76215. input: Float32Array;
  76216. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76217. output: Float32Array;
  76218. }
  76219. /**
  76220. * Loader interface with additional members.
  76221. */
  76222. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76223. /** @hidden */
  76224. _data?: Promise<_IAnimationSamplerData>;
  76225. }
  76226. /**
  76227. * Loader interface with additional members.
  76228. */
  76229. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76230. channels: IAnimationChannel[];
  76231. samplers: IAnimationSampler[];
  76232. /** @hidden */
  76233. _babylonAnimationGroup?: AnimationGroup;
  76234. }
  76235. /**
  76236. * Loader interface with additional members.
  76237. */
  76238. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76239. /** @hidden */
  76240. _data?: Promise<ArrayBufferView>;
  76241. }
  76242. /**
  76243. * Loader interface with additional members.
  76244. */
  76245. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76246. /** @hidden */
  76247. _data?: Promise<ArrayBufferView>;
  76248. /** @hidden */
  76249. _babylonBuffer?: Promise<Buffer>;
  76250. }
  76251. /**
  76252. * Loader interface with additional members.
  76253. */
  76254. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76255. }
  76256. /**
  76257. * Loader interface with additional members.
  76258. */
  76259. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76260. /** @hidden */
  76261. _data?: Promise<ArrayBufferView>;
  76262. }
  76263. /**
  76264. * Loader interface with additional members.
  76265. */
  76266. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76267. }
  76268. /**
  76269. * Loader interface with additional members.
  76270. */
  76271. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76272. }
  76273. /**
  76274. * Loader interface with additional members.
  76275. */
  76276. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76277. baseColorTexture?: ITextureInfo;
  76278. metallicRoughnessTexture?: ITextureInfo;
  76279. }
  76280. /**
  76281. * Loader interface with additional members.
  76282. */
  76283. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76284. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76285. normalTexture?: IMaterialNormalTextureInfo;
  76286. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76287. emissiveTexture?: ITextureInfo;
  76288. /** @hidden */
  76289. _data?: {
  76290. [babylonDrawMode: number]: {
  76291. babylonMaterial: Material;
  76292. babylonMeshes: AbstractMesh[];
  76293. promise: Promise<void>;
  76294. };
  76295. };
  76296. }
  76297. /**
  76298. * Loader interface with additional members.
  76299. */
  76300. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76301. primitives: IMeshPrimitive[];
  76302. }
  76303. /**
  76304. * Loader interface with additional members.
  76305. */
  76306. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76307. /** @hidden */
  76308. _instanceData?: {
  76309. babylonSourceMesh: Mesh;
  76310. promise: Promise<any>;
  76311. };
  76312. }
  76313. /**
  76314. * Loader interface with additional members.
  76315. */
  76316. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76317. /**
  76318. * The parent glTF node.
  76319. */
  76320. parent?: INode;
  76321. /** @hidden */
  76322. _babylonTransformNode?: TransformNode;
  76323. /** @hidden */
  76324. _primitiveBabylonMeshes?: AbstractMesh[];
  76325. /** @hidden */
  76326. _babylonBones?: Bone[];
  76327. /** @hidden */
  76328. _numMorphTargets?: number;
  76329. }
  76330. /** @hidden */
  76331. export interface _ISamplerData {
  76332. noMipMaps: boolean;
  76333. samplingMode: number;
  76334. wrapU: number;
  76335. wrapV: number;
  76336. }
  76337. /**
  76338. * Loader interface with additional members.
  76339. */
  76340. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76341. /** @hidden */
  76342. _data?: _ISamplerData;
  76343. }
  76344. /**
  76345. * Loader interface with additional members.
  76346. */
  76347. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76348. }
  76349. /**
  76350. * Loader interface with additional members.
  76351. */
  76352. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76353. /** @hidden */
  76354. _data?: {
  76355. babylonSkeleton: Skeleton;
  76356. promise: Promise<void>;
  76357. };
  76358. }
  76359. /**
  76360. * Loader interface with additional members.
  76361. */
  76362. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76363. }
  76364. /**
  76365. * Loader interface with additional members.
  76366. */
  76367. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76368. }
  76369. /**
  76370. * Loader interface with additional members.
  76371. */
  76372. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76373. accessors?: IAccessor[];
  76374. animations?: IAnimation[];
  76375. buffers?: IBuffer[];
  76376. bufferViews?: IBufferView[];
  76377. cameras?: ICamera[];
  76378. images?: IImage[];
  76379. materials?: IMaterial[];
  76380. meshes?: IMesh[];
  76381. nodes?: INode[];
  76382. samplers?: ISampler[];
  76383. scenes?: IScene[];
  76384. skins?: ISkin[];
  76385. textures?: ITexture[];
  76386. }
  76387. }
  76388. declare module BABYLON.GLTF2 {
  76389. /**
  76390. * Interface for a glTF loader extension.
  76391. */
  76392. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76393. /**
  76394. * Called after the loader state changes to LOADING.
  76395. */
  76396. onLoading?(): void;
  76397. /**
  76398. * Called after the loader state changes to READY.
  76399. */
  76400. onReady?(): void;
  76401. /**
  76402. * Define this method to modify the default behavior when loading scenes.
  76403. * @param context The context when loading the asset
  76404. * @param scene The glTF scene property
  76405. * @returns A promise that resolves when the load is complete or null if not handled
  76406. */
  76407. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76408. /**
  76409. * Define this method to modify the default behavior when loading nodes.
  76410. * @param context The context when loading the asset
  76411. * @param node The glTF node property
  76412. * @param assign A function called synchronously after parsing the glTF properties
  76413. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76414. */
  76415. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76416. /**
  76417. * Define this method to modify the default behavior when loading cameras.
  76418. * @param context The context when loading the asset
  76419. * @param camera The glTF camera property
  76420. * @param assign A function called synchronously after parsing the glTF properties
  76421. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76422. */
  76423. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76424. /**
  76425. * @hidden
  76426. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76427. * @param context The context when loading the asset
  76428. * @param primitive The glTF mesh primitive property
  76429. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76430. */
  76431. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76432. /**
  76433. * @hidden
  76434. * Define this method to modify the default behavior when loading data for mesh primitives.
  76435. * @param context The context when loading the asset
  76436. * @param name The mesh name when loading the asset
  76437. * @param node The glTF node when loading the asset
  76438. * @param mesh The glTF mesh when loading the asset
  76439. * @param primitive The glTF mesh primitive property
  76440. * @param assign A function called synchronously after parsing the glTF properties
  76441. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76442. */
  76443. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76444. /**
  76445. * @hidden
  76446. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76447. * @param context The context when loading the asset
  76448. * @param material The glTF material property
  76449. * @param assign A function called synchronously after parsing the glTF properties
  76450. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76451. */
  76452. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76453. /**
  76454. * Define this method to modify the default behavior when creating materials.
  76455. * @param context The context when loading the asset
  76456. * @param material The glTF material property
  76457. * @param babylonDrawMode The draw mode for the Babylon material
  76458. * @returns The Babylon material or null if not handled
  76459. */
  76460. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76461. /**
  76462. * Define this method to modify the default behavior when loading material properties.
  76463. * @param context The context when loading the asset
  76464. * @param material The glTF material property
  76465. * @param babylonMaterial The Babylon material
  76466. * @returns A promise that resolves when the load is complete or null if not handled
  76467. */
  76468. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76469. /**
  76470. * Define this method to modify the default behavior when loading texture infos.
  76471. * @param context The context when loading the asset
  76472. * @param textureInfo The glTF texture info property
  76473. * @param assign A function called synchronously after parsing the glTF properties
  76474. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76475. */
  76476. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76477. /**
  76478. * @hidden
  76479. * Define this method to modify the default behavior when loading textures.
  76480. * @param context The context when loading the asset
  76481. * @param texture The glTF texture property
  76482. * @param assign A function called synchronously after parsing the glTF properties
  76483. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76484. */
  76485. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76486. /**
  76487. * Define this method to modify the default behavior when loading animations.
  76488. * @param context The context when loading the asset
  76489. * @param animation The glTF animation property
  76490. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76491. */
  76492. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76493. /**
  76494. * @hidden
  76495. * Define this method to modify the default behavior when loading skins.
  76496. * @param context The context when loading the asset
  76497. * @param node The glTF node property
  76498. * @param skin The glTF skin property
  76499. * @returns A promise that resolves when the load is complete or null if not handled
  76500. */
  76501. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76502. /**
  76503. * @hidden
  76504. * Define this method to modify the default behavior when loading uris.
  76505. * @param context The context when loading the asset
  76506. * @param property The glTF property associated with the uri
  76507. * @param uri The uri to load
  76508. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76509. */
  76510. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76511. /**
  76512. * Define this method to modify the default behavior when loading buffer views.
  76513. * @param context The context when loading the asset
  76514. * @param bufferView The glTF buffer view property
  76515. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76516. */
  76517. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76518. /**
  76519. * Define this method to modify the default behavior when loading buffers.
  76520. * @param context The context when loading the asset
  76521. * @param buffer The glTF buffer property
  76522. * @param byteOffset The byte offset to load
  76523. * @param byteLength The byte length to load
  76524. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76525. */
  76526. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76527. }
  76528. }
  76529. declare module BABYLON.GLTF2 {
  76530. /**
  76531. * Helper class for working with arrays when loading the glTF asset
  76532. */
  76533. export class ArrayItem {
  76534. /**
  76535. * Gets an item from the given array.
  76536. * @param context The context when loading the asset
  76537. * @param array The array to get the item from
  76538. * @param index The index to the array
  76539. * @returns The array item
  76540. */
  76541. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76542. /**
  76543. * Assign an `index` field to each item of the given array.
  76544. * @param array The array of items
  76545. */
  76546. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76547. }
  76548. /**
  76549. * The glTF 2.0 loader
  76550. */
  76551. export class GLTFLoader implements IGLTFLoader {
  76552. /** @hidden */
  76553. _completePromises: Promise<any>[];
  76554. /** @hidden */
  76555. _forAssetContainer: boolean;
  76556. /** Storage */
  76557. _babylonLights: Light[];
  76558. private _disposed;
  76559. private _parent;
  76560. private _state;
  76561. private _extensions;
  76562. private _rootUrl;
  76563. private _fileName;
  76564. private _uniqueRootUrl;
  76565. private _gltf;
  76566. private _bin;
  76567. private _babylonScene;
  76568. private _rootBabylonMesh;
  76569. private _defaultBabylonMaterialData;
  76570. private _progressCallback?;
  76571. private _requests;
  76572. private static _RegisteredExtensions;
  76573. /**
  76574. * The default glTF sampler.
  76575. */
  76576. static readonly DefaultSampler: ISampler;
  76577. /**
  76578. * Registers a loader extension.
  76579. * @param name The name of the loader extension.
  76580. * @param factory The factory function that creates the loader extension.
  76581. */
  76582. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76583. /**
  76584. * Unregisters a loader extension.
  76585. * @param name The name of the loader extension.
  76586. * @returns A boolean indicating whether the extension has been unregistered
  76587. */
  76588. static UnregisterExtension(name: string): boolean;
  76589. /**
  76590. * The loader state.
  76591. */
  76592. get state(): Nullable<GLTFLoaderState>;
  76593. /**
  76594. * The object that represents the glTF JSON.
  76595. */
  76596. get gltf(): IGLTF;
  76597. /**
  76598. * The BIN chunk of a binary glTF.
  76599. */
  76600. get bin(): Nullable<IDataBuffer>;
  76601. /**
  76602. * The parent file loader.
  76603. */
  76604. get parent(): GLTFFileLoader;
  76605. /**
  76606. * The Babylon scene when loading the asset.
  76607. */
  76608. get babylonScene(): Scene;
  76609. /**
  76610. * The root Babylon mesh when loading the asset.
  76611. */
  76612. get rootBabylonMesh(): Mesh;
  76613. /** @hidden */
  76614. constructor(parent: GLTFFileLoader);
  76615. /** @hidden */
  76616. dispose(): void;
  76617. /** @hidden */
  76618. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76619. /** @hidden */
  76620. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76621. private _loadAsync;
  76622. private _loadData;
  76623. private _setupData;
  76624. private _loadExtensions;
  76625. private _checkExtensions;
  76626. private _setState;
  76627. private _createRootNode;
  76628. /**
  76629. * Loads a glTF scene.
  76630. * @param context The context when loading the asset
  76631. * @param scene The glTF scene property
  76632. * @returns A promise that resolves when the load is complete
  76633. */
  76634. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76635. private _forEachPrimitive;
  76636. private _getMeshes;
  76637. private _getTransformNodes;
  76638. private _getSkeletons;
  76639. private _getAnimationGroups;
  76640. private _startAnimations;
  76641. /**
  76642. * Loads a glTF node.
  76643. * @param context The context when loading the asset
  76644. * @param node The glTF node property
  76645. * @param assign A function called synchronously after parsing the glTF properties
  76646. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76647. */
  76648. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76649. private _loadMeshAsync;
  76650. /**
  76651. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76652. * @param context The context when loading the asset
  76653. * @param name The mesh name when loading the asset
  76654. * @param node The glTF node when loading the asset
  76655. * @param mesh The glTF mesh when loading the asset
  76656. * @param primitive The glTF mesh primitive property
  76657. * @param assign A function called synchronously after parsing the glTF properties
  76658. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76659. */
  76660. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76661. private _loadVertexDataAsync;
  76662. private _createMorphTargets;
  76663. private _loadMorphTargetsAsync;
  76664. private _loadMorphTargetVertexDataAsync;
  76665. private static _LoadTransform;
  76666. private _loadSkinAsync;
  76667. private _loadBones;
  76668. private _loadBone;
  76669. private _loadSkinInverseBindMatricesDataAsync;
  76670. private _updateBoneMatrices;
  76671. private _getNodeMatrix;
  76672. /**
  76673. * Loads a glTF camera.
  76674. * @param context The context when loading the asset
  76675. * @param camera The glTF camera property
  76676. * @param assign A function called synchronously after parsing the glTF properties
  76677. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76678. */
  76679. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76680. private _loadAnimationsAsync;
  76681. /**
  76682. * Loads a glTF animation.
  76683. * @param context The context when loading the asset
  76684. * @param animation The glTF animation property
  76685. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76686. */
  76687. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76688. /**
  76689. * @hidden Loads a glTF animation channel.
  76690. * @param context The context when loading the asset
  76691. * @param animationContext The context of the animation when loading the asset
  76692. * @param animation The glTF animation property
  76693. * @param channel The glTF animation channel property
  76694. * @param babylonAnimationGroup The babylon animation group property
  76695. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76696. * @returns A void promise when the channel load is complete
  76697. */
  76698. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76699. private _loadAnimationSamplerAsync;
  76700. private _loadBufferAsync;
  76701. /**
  76702. * Loads a glTF buffer view.
  76703. * @param context The context when loading the asset
  76704. * @param bufferView The glTF buffer view property
  76705. * @returns A promise that resolves with the loaded data when the load is complete
  76706. */
  76707. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76708. private _loadAccessorAsync;
  76709. /** @hidden */
  76710. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76711. private _loadIndicesAccessorAsync;
  76712. private _loadVertexBufferViewAsync;
  76713. private _loadVertexAccessorAsync;
  76714. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76715. /** @hidden */
  76716. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76717. private _createDefaultMaterial;
  76718. /**
  76719. * Creates a Babylon material from a glTF material.
  76720. * @param context The context when loading the asset
  76721. * @param material The glTF material property
  76722. * @param babylonDrawMode The draw mode for the Babylon material
  76723. * @returns The Babylon material
  76724. */
  76725. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76726. /**
  76727. * Loads properties from a glTF material into a Babylon material.
  76728. * @param context The context when loading the asset
  76729. * @param material The glTF material property
  76730. * @param babylonMaterial The Babylon material
  76731. * @returns A promise that resolves when the load is complete
  76732. */
  76733. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76734. /**
  76735. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76736. * @param context The context when loading the asset
  76737. * @param material The glTF material property
  76738. * @param babylonMaterial The Babylon material
  76739. * @returns A promise that resolves when the load is complete
  76740. */
  76741. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76742. /**
  76743. * Loads the alpha properties from a glTF material into a Babylon material.
  76744. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76745. * @param context The context when loading the asset
  76746. * @param material The glTF material property
  76747. * @param babylonMaterial The Babylon material
  76748. */
  76749. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76750. /**
  76751. * Loads a glTF texture info.
  76752. * @param context The context when loading the asset
  76753. * @param textureInfo The glTF texture info property
  76754. * @param assign A function called synchronously after parsing the glTF properties
  76755. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76756. */
  76757. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76758. /** @hidden */
  76759. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76760. /** @hidden */
  76761. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76762. private _loadSampler;
  76763. /**
  76764. * Loads a glTF image.
  76765. * @param context The context when loading the asset
  76766. * @param image The glTF image property
  76767. * @returns A promise that resolves with the loaded data when the load is complete
  76768. */
  76769. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76770. /**
  76771. * Loads a glTF uri.
  76772. * @param context The context when loading the asset
  76773. * @param property The glTF property associated with the uri
  76774. * @param uri The base64 or relative uri
  76775. * @returns A promise that resolves with the loaded data when the load is complete
  76776. */
  76777. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76778. private _onProgress;
  76779. /**
  76780. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76781. * @param babylonObject the Babylon object with metadata
  76782. * @param pointer the JSON pointer
  76783. */
  76784. static AddPointerMetadata(babylonObject: {
  76785. metadata: any;
  76786. }, pointer: string): void;
  76787. private static _GetTextureWrapMode;
  76788. private static _GetTextureSamplingMode;
  76789. private static _GetTypedArrayConstructor;
  76790. private static _GetTypedArray;
  76791. private static _GetNumComponents;
  76792. private static _ValidateUri;
  76793. private static _GetDrawMode;
  76794. private _compileMaterialsAsync;
  76795. private _compileShadowGeneratorsAsync;
  76796. private _forEachExtensions;
  76797. private _applyExtensions;
  76798. private _extensionsOnLoading;
  76799. private _extensionsOnReady;
  76800. private _extensionsLoadSceneAsync;
  76801. private _extensionsLoadNodeAsync;
  76802. private _extensionsLoadCameraAsync;
  76803. private _extensionsLoadVertexDataAsync;
  76804. private _extensionsLoadMeshPrimitiveAsync;
  76805. private _extensionsLoadMaterialAsync;
  76806. private _extensionsCreateMaterial;
  76807. private _extensionsLoadMaterialPropertiesAsync;
  76808. private _extensionsLoadTextureInfoAsync;
  76809. private _extensionsLoadTextureAsync;
  76810. private _extensionsLoadAnimationAsync;
  76811. private _extensionsLoadSkinAsync;
  76812. private _extensionsLoadUriAsync;
  76813. private _extensionsLoadBufferViewAsync;
  76814. private _extensionsLoadBufferAsync;
  76815. /**
  76816. * Helper method called by a loader extension to load an glTF extension.
  76817. * @param context The context when loading the asset
  76818. * @param property The glTF property to load the extension from
  76819. * @param extensionName The name of the extension to load
  76820. * @param actionAsync The action to run
  76821. * @returns The promise returned by actionAsync or null if the extension does not exist
  76822. */
  76823. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76824. /**
  76825. * Helper method called by a loader extension to load a glTF extra.
  76826. * @param context The context when loading the asset
  76827. * @param property The glTF property to load the extra from
  76828. * @param extensionName The name of the extension to load
  76829. * @param actionAsync The action to run
  76830. * @returns The promise returned by actionAsync or null if the extra does not exist
  76831. */
  76832. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76833. /**
  76834. * Checks for presence of an extension.
  76835. * @param name The name of the extension to check
  76836. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76837. */
  76838. isExtensionUsed(name: string): boolean;
  76839. /**
  76840. * Increments the indentation level and logs a message.
  76841. * @param message The message to log
  76842. */
  76843. logOpen(message: string): void;
  76844. /**
  76845. * Decrements the indentation level.
  76846. */
  76847. logClose(): void;
  76848. /**
  76849. * Logs a message
  76850. * @param message The message to log
  76851. */
  76852. log(message: string): void;
  76853. /**
  76854. * Starts a performance counter.
  76855. * @param counterName The name of the performance counter
  76856. */
  76857. startPerformanceCounter(counterName: string): void;
  76858. /**
  76859. * Ends a performance counter.
  76860. * @param counterName The name of the performance counter
  76861. */
  76862. endPerformanceCounter(counterName: string): void;
  76863. }
  76864. }
  76865. declare module BABYLON.GLTF2.Loader.Extensions {
  76866. /**
  76867. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76868. */
  76869. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76870. /**
  76871. * The name of this extension.
  76872. */
  76873. readonly name: string;
  76874. /**
  76875. * Defines whether this extension is enabled.
  76876. */
  76877. enabled: boolean;
  76878. private _loader;
  76879. private _lights?;
  76880. /** @hidden */
  76881. constructor(loader: GLTFLoader);
  76882. /** @hidden */
  76883. dispose(): void;
  76884. /** @hidden */
  76885. onLoading(): void;
  76886. /** @hidden */
  76887. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76888. private _loadLightAsync;
  76889. }
  76890. }
  76891. declare module BABYLON.GLTF2.Loader.Extensions {
  76892. /**
  76893. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76894. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  76895. * !!! Experimental Extension Subject to Changes !!!
  76896. */
  76897. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  76898. /**
  76899. * The name of this extension.
  76900. */
  76901. readonly name: string;
  76902. /**
  76903. * Defines whether this extension is enabled.
  76904. */
  76905. enabled: boolean;
  76906. private _loader;
  76907. /** @hidden */
  76908. constructor(loader: GLTFLoader);
  76909. /** @hidden */
  76910. dispose(): void;
  76911. /** @hidden */
  76912. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76913. }
  76914. }
  76915. declare module BABYLON.GLTF2.Loader.Extensions {
  76916. /**
  76917. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76918. */
  76919. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76920. /**
  76921. * The name of this extension.
  76922. */
  76923. readonly name: string;
  76924. /**
  76925. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76926. */
  76927. dracoCompression?: DracoCompression;
  76928. /**
  76929. * Defines whether this extension is enabled.
  76930. */
  76931. enabled: boolean;
  76932. private _loader;
  76933. /** @hidden */
  76934. constructor(loader: GLTFLoader);
  76935. /** @hidden */
  76936. dispose(): void;
  76937. /** @hidden */
  76938. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76939. }
  76940. }
  76941. declare module BABYLON.GLTF2.Loader.Extensions {
  76942. /**
  76943. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76944. */
  76945. export class KHR_lights implements IGLTFLoaderExtension {
  76946. /**
  76947. * The name of this extension.
  76948. */
  76949. readonly name: string;
  76950. /**
  76951. * Defines whether this extension is enabled.
  76952. */
  76953. enabled: boolean;
  76954. private _loader;
  76955. private _lights?;
  76956. /** @hidden */
  76957. constructor(loader: GLTFLoader);
  76958. /** @hidden */
  76959. dispose(): void;
  76960. /** @hidden */
  76961. onLoading(): void;
  76962. /** @hidden */
  76963. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76964. }
  76965. }
  76966. declare module BABYLON.GLTF2.Loader.Extensions {
  76967. /**
  76968. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76969. */
  76970. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76971. /**
  76972. * The name of this extension.
  76973. */
  76974. readonly name: string;
  76975. /**
  76976. * Defines whether this extension is enabled.
  76977. */
  76978. enabled: boolean;
  76979. /**
  76980. * Defines a number that determines the order the extensions are applied.
  76981. */
  76982. order: number;
  76983. private _loader;
  76984. /** @hidden */
  76985. constructor(loader: GLTFLoader);
  76986. /** @hidden */
  76987. dispose(): void;
  76988. /** @hidden */
  76989. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76990. private _loadSpecularGlossinessPropertiesAsync;
  76991. }
  76992. }
  76993. declare module BABYLON.GLTF2.Loader.Extensions {
  76994. /**
  76995. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76996. */
  76997. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76998. /**
  76999. * The name of this extension.
  77000. */
  77001. readonly name: string;
  77002. /**
  77003. * Defines whether this extension is enabled.
  77004. */
  77005. enabled: boolean;
  77006. /**
  77007. * Defines a number that determines the order the extensions are applied.
  77008. */
  77009. order: number;
  77010. private _loader;
  77011. /** @hidden */
  77012. constructor(loader: GLTFLoader);
  77013. /** @hidden */
  77014. dispose(): void;
  77015. /** @hidden */
  77016. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77017. private _loadUnlitPropertiesAsync;
  77018. }
  77019. }
  77020. declare module BABYLON.GLTF2.Loader.Extensions {
  77021. /**
  77022. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77023. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  77024. * !!! Experimental Extension Subject to Changes !!!
  77025. */
  77026. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  77027. /**
  77028. * The name of this extension.
  77029. */
  77030. readonly name: string;
  77031. /**
  77032. * Defines whether this extension is enabled.
  77033. */
  77034. enabled: boolean;
  77035. /**
  77036. * Defines a number that determines the order the extensions are applied.
  77037. */
  77038. order: number;
  77039. private _loader;
  77040. /** @hidden */
  77041. constructor(loader: GLTFLoader);
  77042. /** @hidden */
  77043. dispose(): void;
  77044. /** @hidden */
  77045. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77046. private _loadClearCoatPropertiesAsync;
  77047. }
  77048. }
  77049. declare module BABYLON.GLTF2.Loader.Extensions {
  77050. /**
  77051. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  77052. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77053. * !!! Experimental Extension Subject to Changes !!!
  77054. */
  77055. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  77056. /**
  77057. * The name of this extension.
  77058. */
  77059. readonly name: string;
  77060. /**
  77061. * Defines whether this extension is enabled.
  77062. */
  77063. enabled: boolean;
  77064. /**
  77065. * Defines a number that determines the order the extensions are applied.
  77066. */
  77067. order: number;
  77068. private _loader;
  77069. /** @hidden */
  77070. constructor(loader: GLTFLoader);
  77071. /** @hidden */
  77072. dispose(): void;
  77073. /** @hidden */
  77074. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77075. private _loadSheenPropertiesAsync;
  77076. }
  77077. }
  77078. declare module BABYLON.GLTF2.Loader.Extensions {
  77079. /**
  77080. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77081. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77082. * !!! Experimental Extension Subject to Changes !!!
  77083. */
  77084. export class KHR_materials_specular implements IGLTFLoaderExtension {
  77085. /**
  77086. * The name of this extension.
  77087. */
  77088. readonly name: string;
  77089. /**
  77090. * Defines whether this extension is enabled.
  77091. */
  77092. enabled: boolean;
  77093. /**
  77094. * Defines a number that determines the order the extensions are applied.
  77095. */
  77096. order: number;
  77097. private _loader;
  77098. /** @hidden */
  77099. constructor(loader: GLTFLoader);
  77100. /** @hidden */
  77101. dispose(): void;
  77102. /** @hidden */
  77103. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77104. private _loadSpecularPropertiesAsync;
  77105. }
  77106. }
  77107. declare module BABYLON.GLTF2.Loader.Extensions {
  77108. /**
  77109. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  77110. */
  77111. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  77112. /**
  77113. * The name of this extension.
  77114. */
  77115. readonly name: string;
  77116. /**
  77117. * Defines whether this extension is enabled.
  77118. */
  77119. enabled: boolean;
  77120. /** @hidden */
  77121. constructor(loader: GLTFLoader);
  77122. /** @hidden */
  77123. dispose(): void;
  77124. }
  77125. }
  77126. declare module BABYLON.GLTF2.Loader.Extensions {
  77127. /**
  77128. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77129. * !!! Experimental Extension Subject to Changes !!!
  77130. */
  77131. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77132. /** The name of this extension. */
  77133. readonly name: string;
  77134. /** Defines whether this extension is enabled. */
  77135. enabled: boolean;
  77136. private _loader;
  77137. /** @hidden */
  77138. constructor(loader: GLTFLoader);
  77139. /** @hidden */
  77140. dispose(): void;
  77141. /** @hidden */
  77142. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77143. }
  77144. }
  77145. declare module BABYLON.GLTF2.Loader.Extensions {
  77146. /**
  77147. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77148. */
  77149. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77150. /**
  77151. * The name of this extension.
  77152. */
  77153. readonly name: string;
  77154. /**
  77155. * Defines whether this extension is enabled.
  77156. */
  77157. enabled: boolean;
  77158. private _loader;
  77159. /** @hidden */
  77160. constructor(loader: GLTFLoader);
  77161. /** @hidden */
  77162. dispose(): void;
  77163. /** @hidden */
  77164. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77165. }
  77166. }
  77167. declare module BABYLON.GLTF2.Loader.Extensions {
  77168. /**
  77169. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77170. */
  77171. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77172. /**
  77173. * The name of this extension.
  77174. */
  77175. readonly name: string;
  77176. /**
  77177. * Defines whether this extension is enabled.
  77178. */
  77179. enabled: boolean;
  77180. private _loader;
  77181. private _clips;
  77182. private _emitters;
  77183. /** @hidden */
  77184. constructor(loader: GLTFLoader);
  77185. /** @hidden */
  77186. dispose(): void;
  77187. /** @hidden */
  77188. onLoading(): void;
  77189. /** @hidden */
  77190. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77191. /** @hidden */
  77192. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77193. /** @hidden */
  77194. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77195. private _loadClipAsync;
  77196. private _loadEmitterAsync;
  77197. private _getEventAction;
  77198. private _loadAnimationEventAsync;
  77199. }
  77200. }
  77201. declare module BABYLON.GLTF2.Loader.Extensions {
  77202. /**
  77203. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77204. */
  77205. export class MSFT_lod implements IGLTFLoaderExtension {
  77206. /**
  77207. * The name of this extension.
  77208. */
  77209. readonly name: string;
  77210. /**
  77211. * Defines whether this extension is enabled.
  77212. */
  77213. enabled: boolean;
  77214. /**
  77215. * Defines a number that determines the order the extensions are applied.
  77216. */
  77217. order: number;
  77218. /**
  77219. * Maximum number of LODs to load, starting from the lowest LOD.
  77220. */
  77221. maxLODsToLoad: number;
  77222. /**
  77223. * Observable raised when all node LODs of one level are loaded.
  77224. * The event data is the index of the loaded LOD starting from zero.
  77225. * Dispose the loader to cancel the loading of the next level of LODs.
  77226. */
  77227. onNodeLODsLoadedObservable: Observable<number>;
  77228. /**
  77229. * Observable raised when all material LODs of one level are loaded.
  77230. * The event data is the index of the loaded LOD starting from zero.
  77231. * Dispose the loader to cancel the loading of the next level of LODs.
  77232. */
  77233. onMaterialLODsLoadedObservable: Observable<number>;
  77234. private _loader;
  77235. private _nodeIndexLOD;
  77236. private _nodeSignalLODs;
  77237. private _nodePromiseLODs;
  77238. private _materialIndexLOD;
  77239. private _materialSignalLODs;
  77240. private _materialPromiseLODs;
  77241. private _indexLOD;
  77242. private _bufferLODs;
  77243. /** @hidden */
  77244. constructor(loader: GLTFLoader);
  77245. /** @hidden */
  77246. dispose(): void;
  77247. /** @hidden */
  77248. onReady(): void;
  77249. /** @hidden */
  77250. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77251. /** @hidden */
  77252. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77253. /** @hidden */
  77254. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77255. /** @hidden */
  77256. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77257. /** @hidden */
  77258. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77259. private _loadBufferLOD;
  77260. /**
  77261. * Gets an array of LOD properties from lowest to highest.
  77262. */
  77263. private _getLODs;
  77264. private _disposeTransformNode;
  77265. private _disposeMaterials;
  77266. }
  77267. }
  77268. declare module BABYLON.GLTF2.Loader.Extensions {
  77269. /** @hidden */
  77270. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77271. readonly name: string;
  77272. enabled: boolean;
  77273. private _loader;
  77274. constructor(loader: GLTFLoader);
  77275. dispose(): void;
  77276. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77277. }
  77278. }
  77279. declare module BABYLON.GLTF2.Loader.Extensions {
  77280. /** @hidden */
  77281. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77282. readonly name: string;
  77283. enabled: boolean;
  77284. private _loader;
  77285. constructor(loader: GLTFLoader);
  77286. dispose(): void;
  77287. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77288. }
  77289. }
  77290. declare module BABYLON.GLTF2.Loader.Extensions {
  77291. /**
  77292. * Store glTF extras (if present) in BJS objects' metadata
  77293. */
  77294. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77295. /**
  77296. * The name of this extension.
  77297. */
  77298. readonly name: string;
  77299. /**
  77300. * Defines whether this extension is enabled.
  77301. */
  77302. enabled: boolean;
  77303. private _loader;
  77304. private _assignExtras;
  77305. /** @hidden */
  77306. constructor(loader: GLTFLoader);
  77307. /** @hidden */
  77308. dispose(): void;
  77309. /** @hidden */
  77310. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77311. /** @hidden */
  77312. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77313. /** @hidden */
  77314. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77315. }
  77316. }
  77317. declare module BABYLON {
  77318. /**
  77319. * Class reading and parsing the MTL file bundled with the obj file.
  77320. */
  77321. export class MTLFileLoader {
  77322. /**
  77323. * Invert Y-Axis of referenced textures on load
  77324. */
  77325. static INVERT_TEXTURE_Y: boolean;
  77326. /**
  77327. * All material loaded from the mtl will be set here
  77328. */
  77329. materials: StandardMaterial[];
  77330. /**
  77331. * This function will read the mtl file and create each material described inside
  77332. * This function could be improve by adding :
  77333. * -some component missing (Ni, Tf...)
  77334. * -including the specific options available
  77335. *
  77336. * @param scene defines the scene the material will be created in
  77337. * @param data defines the mtl data to parse
  77338. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77339. * @param forAssetContainer defines if the material should be registered in the scene
  77340. */
  77341. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77342. /**
  77343. * Gets the texture for the material.
  77344. *
  77345. * If the material is imported from input file,
  77346. * We sanitize the url to ensure it takes the textre from aside the material.
  77347. *
  77348. * @param rootUrl The root url to load from
  77349. * @param value The value stored in the mtl
  77350. * @return The Texture
  77351. */
  77352. private static _getTexture;
  77353. }
  77354. }
  77355. declare module BABYLON {
  77356. /**
  77357. * Options for loading OBJ/MTL files
  77358. */
  77359. type MeshLoadOptions = {
  77360. /**
  77361. * Defines if UVs are optimized by default during load.
  77362. */
  77363. OptimizeWithUV: boolean;
  77364. /**
  77365. * Defines custom scaling of UV coordinates of loaded meshes.
  77366. */
  77367. UVScaling: Vector2;
  77368. /**
  77369. * Invert model on y-axis (does a model scaling inversion)
  77370. */
  77371. InvertY: boolean;
  77372. /**
  77373. * Invert Y-Axis of referenced textures on load
  77374. */
  77375. InvertTextureY: boolean;
  77376. /**
  77377. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77378. */
  77379. ImportVertexColors: boolean;
  77380. /**
  77381. * Compute the normals for the model, even if normals are present in the file.
  77382. */
  77383. ComputeNormals: boolean;
  77384. /**
  77385. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77386. */
  77387. SkipMaterials: boolean;
  77388. /**
  77389. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77390. */
  77391. MaterialLoadingFailsSilently: boolean;
  77392. };
  77393. /**
  77394. * OBJ file type loader.
  77395. * This is a babylon scene loader plugin.
  77396. */
  77397. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77398. /**
  77399. * Defines if UVs are optimized by default during load.
  77400. */
  77401. static OPTIMIZE_WITH_UV: boolean;
  77402. /**
  77403. * Invert model on y-axis (does a model scaling inversion)
  77404. */
  77405. static INVERT_Y: boolean;
  77406. /**
  77407. * Invert Y-Axis of referenced textures on load
  77408. */
  77409. static get INVERT_TEXTURE_Y(): boolean;
  77410. static set INVERT_TEXTURE_Y(value: boolean);
  77411. /**
  77412. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77413. */
  77414. static IMPORT_VERTEX_COLORS: boolean;
  77415. /**
  77416. * Compute the normals for the model, even if normals are present in the file.
  77417. */
  77418. static COMPUTE_NORMALS: boolean;
  77419. /**
  77420. * Defines custom scaling of UV coordinates of loaded meshes.
  77421. */
  77422. static UV_SCALING: Vector2;
  77423. /**
  77424. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77425. */
  77426. static SKIP_MATERIALS: boolean;
  77427. /**
  77428. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77429. *
  77430. * Defaults to true for backwards compatibility.
  77431. */
  77432. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77433. /**
  77434. * Defines the name of the plugin.
  77435. */
  77436. name: string;
  77437. /**
  77438. * Defines the extension the plugin is able to load.
  77439. */
  77440. extensions: string;
  77441. /** @hidden */
  77442. obj: RegExp;
  77443. /** @hidden */
  77444. group: RegExp;
  77445. /** @hidden */
  77446. mtllib: RegExp;
  77447. /** @hidden */
  77448. usemtl: RegExp;
  77449. /** @hidden */
  77450. smooth: RegExp;
  77451. /** @hidden */
  77452. vertexPattern: RegExp;
  77453. /** @hidden */
  77454. normalPattern: RegExp;
  77455. /** @hidden */
  77456. uvPattern: RegExp;
  77457. /** @hidden */
  77458. facePattern1: RegExp;
  77459. /** @hidden */
  77460. facePattern2: RegExp;
  77461. /** @hidden */
  77462. facePattern3: RegExp;
  77463. /** @hidden */
  77464. facePattern4: RegExp;
  77465. /** @hidden */
  77466. facePattern5: RegExp;
  77467. private _forAssetContainer;
  77468. private _meshLoadOptions;
  77469. /**
  77470. * Creates loader for .OBJ files
  77471. *
  77472. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77473. */
  77474. constructor(meshLoadOptions?: MeshLoadOptions);
  77475. private static get currentMeshLoadOptions();
  77476. /**
  77477. * Calls synchronously the MTL file attached to this obj.
  77478. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77479. * Without this function materials are not displayed in the first frame (but displayed after).
  77480. * In consequence it is impossible to get material information in your HTML file
  77481. *
  77482. * @param url The URL of the MTL file
  77483. * @param rootUrl
  77484. * @param onSuccess Callback function to be called when the MTL file is loaded
  77485. * @private
  77486. */
  77487. private _loadMTL;
  77488. /**
  77489. * Instantiates a OBJ file loader plugin.
  77490. * @returns the created plugin
  77491. */
  77492. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77493. /**
  77494. * If the data string can be loaded directly.
  77495. *
  77496. * @param data string containing the file data
  77497. * @returns if the data can be loaded directly
  77498. */
  77499. canDirectLoad(data: string): boolean;
  77500. /**
  77501. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77502. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77503. * @param scene the scene the meshes should be added to
  77504. * @param data the OBJ data to load
  77505. * @param rootUrl root url to load from
  77506. * @param onProgress event that fires when loading progress has occured
  77507. * @param fileName Defines the name of the file to load
  77508. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77509. */
  77510. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77511. meshes: AbstractMesh[];
  77512. particleSystems: IParticleSystem[];
  77513. skeletons: Skeleton[];
  77514. animationGroups: AnimationGroup[];
  77515. }>;
  77516. /**
  77517. * Imports all objects from the loaded OBJ data and adds them to the scene
  77518. * @param scene the scene the objects should be added to
  77519. * @param data the OBJ data to load
  77520. * @param rootUrl root url to load from
  77521. * @param onProgress event that fires when loading progress has occured
  77522. * @param fileName Defines the name of the file to load
  77523. * @returns a promise which completes when objects have been loaded to the scene
  77524. */
  77525. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77526. /**
  77527. * Load into an asset container.
  77528. * @param scene The scene to load into
  77529. * @param data The data to import
  77530. * @param rootUrl The root url for scene and resources
  77531. * @param onProgress The callback when the load progresses
  77532. * @param fileName Defines the name of the file to load
  77533. * @returns The loaded asset container
  77534. */
  77535. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77536. /**
  77537. * Read the OBJ file and create an Array of meshes.
  77538. * Each mesh contains all information given by the OBJ and the MTL file.
  77539. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77540. *
  77541. * @param meshesNames
  77542. * @param scene Scene The scene where are displayed the data
  77543. * @param data String The content of the obj file
  77544. * @param rootUrl String The path to the folder
  77545. * @returns Array<AbstractMesh>
  77546. * @private
  77547. */
  77548. private _parseSolid;
  77549. }
  77550. }
  77551. declare module BABYLON {
  77552. /**
  77553. * STL file type loader.
  77554. * This is a babylon scene loader plugin.
  77555. */
  77556. export class STLFileLoader implements ISceneLoaderPlugin {
  77557. /** @hidden */
  77558. solidPattern: RegExp;
  77559. /** @hidden */
  77560. facetsPattern: RegExp;
  77561. /** @hidden */
  77562. normalPattern: RegExp;
  77563. /** @hidden */
  77564. vertexPattern: RegExp;
  77565. /**
  77566. * Defines the name of the plugin.
  77567. */
  77568. name: string;
  77569. /**
  77570. * Defines the extensions the stl loader is able to load.
  77571. * force data to come in as an ArrayBuffer
  77572. * we'll convert to string if it looks like it's an ASCII .stl
  77573. */
  77574. extensions: ISceneLoaderPluginExtensions;
  77575. /**
  77576. * Import meshes into a scene.
  77577. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77578. * @param scene The scene to import into
  77579. * @param data The data to import
  77580. * @param rootUrl The root url for scene and resources
  77581. * @param meshes The meshes array to import into
  77582. * @param particleSystems The particle systems array to import into
  77583. * @param skeletons The skeletons array to import into
  77584. * @param onError The callback when import fails
  77585. * @returns True if successful or false otherwise
  77586. */
  77587. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77588. /**
  77589. * Load into a scene.
  77590. * @param scene The scene to load into
  77591. * @param data The data to import
  77592. * @param rootUrl The root url for scene and resources
  77593. * @param onError The callback when import fails
  77594. * @returns true if successful or false otherwise
  77595. */
  77596. load(scene: Scene, data: any, rootUrl: string): boolean;
  77597. /**
  77598. * Load into an asset container.
  77599. * @param scene The scene to load into
  77600. * @param data The data to import
  77601. * @param rootUrl The root url for scene and resources
  77602. * @param onError The callback when import fails
  77603. * @returns The loaded asset container
  77604. */
  77605. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77606. private _isBinary;
  77607. private _parseBinary;
  77608. private _parseASCII;
  77609. }
  77610. }
  77611. declare module BABYLON {
  77612. /**
  77613. * Class for generating OBJ data from a Babylon scene.
  77614. */
  77615. export class OBJExport {
  77616. /**
  77617. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77618. * @param mesh defines the list of meshes to serialize
  77619. * @param materials defines if materials should be exported
  77620. * @param matlibname defines the name of the associated mtl file
  77621. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77622. * @returns the OBJ content
  77623. */
  77624. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77625. /**
  77626. * Exports the material(s) of a mesh in .MTL file format (text)
  77627. * @param mesh defines the mesh to extract the material from
  77628. * @returns the mtl content
  77629. */
  77630. static MTL(mesh: Mesh): string;
  77631. }
  77632. }
  77633. declare module BABYLON {
  77634. /** @hidden */
  77635. export var __IGLTFExporterExtension: number;
  77636. /**
  77637. * Interface for extending the exporter
  77638. * @hidden
  77639. */
  77640. export interface IGLTFExporterExtension {
  77641. /**
  77642. * The name of this extension
  77643. */
  77644. readonly name: string;
  77645. /**
  77646. * Defines whether this extension is enabled
  77647. */
  77648. enabled: boolean;
  77649. /**
  77650. * Defines whether this extension is required
  77651. */
  77652. required: boolean;
  77653. }
  77654. }
  77655. declare module BABYLON.GLTF2.Exporter {
  77656. /** @hidden */
  77657. export var __IGLTFExporterExtensionV2: number;
  77658. /**
  77659. * Interface for a glTF exporter extension
  77660. * @hidden
  77661. */
  77662. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77663. /**
  77664. * Define this method to modify the default behavior before exporting a texture
  77665. * @param context The context when loading the asset
  77666. * @param babylonTexture The Babylon.js texture
  77667. * @param mimeType The mime-type of the generated image
  77668. * @returns A promise that resolves with the exported texture
  77669. */
  77670. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77671. /**
  77672. * Define this method to get notified when a texture info is created
  77673. * @param context The context when loading the asset
  77674. * @param textureInfo The glTF texture info
  77675. * @param babylonTexture The Babylon.js texture
  77676. */
  77677. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77678. /**
  77679. * Define this method to modify the default behavior when exporting texture info
  77680. * @param context The context when loading the asset
  77681. * @param meshPrimitive glTF mesh primitive
  77682. * @param babylonSubMesh Babylon submesh
  77683. * @param binaryWriter glTF serializer binary writer instance
  77684. * @returns nullable IMeshPrimitive promise
  77685. */
  77686. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77687. /**
  77688. * Define this method to modify the default behavior when exporting a node
  77689. * @param context The context when exporting the node
  77690. * @param node glTF node
  77691. * @param babylonNode BabylonJS node
  77692. * @returns nullable INode promise
  77693. */
  77694. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77695. [key: number]: number;
  77696. }): Promise<Nullable<INode>>;
  77697. /**
  77698. * Define this method to modify the default behavior when exporting a material
  77699. * @param material glTF material
  77700. * @param babylonMaterial BabylonJS material
  77701. * @returns nullable IMaterial promise
  77702. */
  77703. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77704. /**
  77705. * Define this method to return additional textures to export from a material
  77706. * @param material glTF material
  77707. * @param babylonMaterial BabylonJS material
  77708. * @returns List of textures
  77709. */
  77710. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77711. /** Gets a boolean indicating that this extension was used */
  77712. wasUsed: boolean;
  77713. /** Gets a boolean indicating that this extension is required for the file to work */
  77714. required: boolean;
  77715. /**
  77716. * Called after the exporter state changes to EXPORTING
  77717. */
  77718. onExporting?(): void;
  77719. }
  77720. }
  77721. declare module BABYLON.GLTF2.Exporter {
  77722. /**
  77723. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77724. * @hidden
  77725. */
  77726. export class _GLTFMaterialExporter {
  77727. /**
  77728. * Represents the dielectric specular values for R, G and B
  77729. */
  77730. private static readonly _DielectricSpecular;
  77731. /**
  77732. * Allows the maximum specular power to be defined for material calculations
  77733. */
  77734. private static readonly _MaxSpecularPower;
  77735. /**
  77736. * Mapping to store textures
  77737. */
  77738. private _textureMap;
  77739. /**
  77740. * Numeric tolerance value
  77741. */
  77742. private static readonly _Epsilon;
  77743. /**
  77744. * Reference to the glTF Exporter
  77745. */
  77746. private _exporter;
  77747. constructor(exporter: _Exporter);
  77748. /**
  77749. * Specifies if two colors are approximately equal in value
  77750. * @param color1 first color to compare to
  77751. * @param color2 second color to compare to
  77752. * @param epsilon threshold value
  77753. */
  77754. private static FuzzyEquals;
  77755. /**
  77756. * Gets the materials from a Babylon scene and converts them to glTF materials
  77757. * @param scene babylonjs scene
  77758. * @param mimeType texture mime type
  77759. * @param images array of images
  77760. * @param textures array of textures
  77761. * @param materials array of materials
  77762. * @param imageData mapping of texture names to base64 textures
  77763. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77764. */
  77765. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77766. /**
  77767. * Makes a copy of the glTF material without the texture parameters
  77768. * @param originalMaterial original glTF material
  77769. * @returns glTF material without texture parameters
  77770. */
  77771. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77772. /**
  77773. * Specifies if the material has any texture parameters present
  77774. * @param material glTF Material
  77775. * @returns boolean specifying if texture parameters are present
  77776. */
  77777. _hasTexturesPresent(material: IMaterial): boolean;
  77778. /**
  77779. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77780. * @param babylonStandardMaterial
  77781. * @returns glTF Metallic Roughness Material representation
  77782. */
  77783. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77784. /**
  77785. * Computes the metallic factor
  77786. * @param diffuse diffused value
  77787. * @param specular specular value
  77788. * @param oneMinusSpecularStrength one minus the specular strength
  77789. * @returns metallic value
  77790. */
  77791. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77792. /**
  77793. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77794. * @param glTFMaterial glTF material
  77795. * @param babylonMaterial Babylon material
  77796. */
  77797. private static _SetAlphaMode;
  77798. /**
  77799. * Converts a Babylon Standard Material to a glTF Material
  77800. * @param babylonStandardMaterial BJS Standard Material
  77801. * @param mimeType mime type to use for the textures
  77802. * @param images array of glTF image interfaces
  77803. * @param textures array of glTF texture interfaces
  77804. * @param materials array of glTF material interfaces
  77805. * @param imageData map of image file name to data
  77806. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77807. */
  77808. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77809. private _finishMaterial;
  77810. /**
  77811. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77812. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77813. * @param mimeType mime type to use for the textures
  77814. * @param images array of glTF image interfaces
  77815. * @param textures array of glTF texture interfaces
  77816. * @param materials array of glTF material interfaces
  77817. * @param imageData map of image file name to data
  77818. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77819. */
  77820. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77821. /**
  77822. * Converts an image typed array buffer to a base64 image
  77823. * @param buffer typed array buffer
  77824. * @param width width of the image
  77825. * @param height height of the image
  77826. * @param mimeType mimetype of the image
  77827. * @returns base64 image string
  77828. */
  77829. private _createBase64FromCanvasAsync;
  77830. /**
  77831. * Generates a white texture based on the specified width and height
  77832. * @param width width of the texture in pixels
  77833. * @param height height of the texture in pixels
  77834. * @param scene babylonjs scene
  77835. * @returns white texture
  77836. */
  77837. private _createWhiteTexture;
  77838. /**
  77839. * 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
  77840. * @param texture1 first texture to resize
  77841. * @param texture2 second texture to resize
  77842. * @param scene babylonjs scene
  77843. * @returns resized textures or null
  77844. */
  77845. private _resizeTexturesToSameDimensions;
  77846. /**
  77847. * Converts an array of pixels to a Float32Array
  77848. * Throws an error if the pixel format is not supported
  77849. * @param pixels - array buffer containing pixel values
  77850. * @returns Float32 of pixels
  77851. */
  77852. private _convertPixelArrayToFloat32;
  77853. /**
  77854. * Convert Specular Glossiness Textures to Metallic Roughness
  77855. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77856. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77857. * @param diffuseTexture texture used to store diffuse information
  77858. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77859. * @param factors specular glossiness material factors
  77860. * @param mimeType the mime type to use for the texture
  77861. * @returns pbr metallic roughness interface or null
  77862. */
  77863. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77864. /**
  77865. * Converts specular glossiness material properties to metallic roughness
  77866. * @param specularGlossiness interface with specular glossiness material properties
  77867. * @returns interface with metallic roughness material properties
  77868. */
  77869. private _convertSpecularGlossinessToMetallicRoughness;
  77870. /**
  77871. * Calculates the surface reflectance, independent of lighting conditions
  77872. * @param color Color source to calculate brightness from
  77873. * @returns number representing the perceived brightness, or zero if color is undefined
  77874. */
  77875. private _getPerceivedBrightness;
  77876. /**
  77877. * Returns the maximum color component value
  77878. * @param color
  77879. * @returns maximum color component value, or zero if color is null or undefined
  77880. */
  77881. private _getMaxComponent;
  77882. /**
  77883. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77884. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77885. * @param mimeType mime type to use for the textures
  77886. * @param images array of glTF image interfaces
  77887. * @param textures array of glTF texture interfaces
  77888. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77889. * @param imageData map of image file name to data
  77890. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77891. * @returns glTF PBR Metallic Roughness factors
  77892. */
  77893. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77894. private _getGLTFTextureSampler;
  77895. private _getGLTFTextureWrapMode;
  77896. private _getGLTFTextureWrapModesSampler;
  77897. /**
  77898. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77899. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77900. * @param mimeType mime type to use for the textures
  77901. * @param images array of glTF image interfaces
  77902. * @param textures array of glTF texture interfaces
  77903. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77904. * @param imageData map of image file name to data
  77905. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77906. * @returns glTF PBR Metallic Roughness factors
  77907. */
  77908. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77909. /**
  77910. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77911. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77912. * @param mimeType mime type to use for the textures
  77913. * @param images array of glTF image interfaces
  77914. * @param textures array of glTF texture interfaces
  77915. * @param materials array of glTF material interfaces
  77916. * @param imageData map of image file name to data
  77917. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77918. */
  77919. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77920. private setMetallicRoughnessPbrMaterial;
  77921. private getPixelsFromTexture;
  77922. /**
  77923. * Extracts a texture from a Babylon texture into file data and glTF data
  77924. * @param babylonTexture Babylon texture to extract
  77925. * @param mimeType Mime Type of the babylonTexture
  77926. * @return glTF texture info, or null if the texture format is not supported
  77927. */
  77928. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77929. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77930. /**
  77931. * Builds a texture from base64 string
  77932. * @param base64Texture base64 texture string
  77933. * @param baseTextureName Name to use for the texture
  77934. * @param mimeType image mime type for the texture
  77935. * @param images array of images
  77936. * @param textures array of textures
  77937. * @param imageData map of image data
  77938. * @returns glTF texture info, or null if the texture format is not supported
  77939. */
  77940. private _getTextureInfoFromBase64;
  77941. }
  77942. }
  77943. declare module BABYLON {
  77944. /**
  77945. * Class for holding and downloading glTF file data
  77946. */
  77947. export class GLTFData {
  77948. /**
  77949. * Object which contains the file name as the key and its data as the value
  77950. */
  77951. glTFFiles: {
  77952. [fileName: string]: string | Blob;
  77953. };
  77954. /**
  77955. * Initializes the glTF file object
  77956. */
  77957. constructor();
  77958. /**
  77959. * Downloads the glTF data as files based on their names and data
  77960. */
  77961. downloadFiles(): void;
  77962. }
  77963. }
  77964. declare module BABYLON {
  77965. /**
  77966. * Holds a collection of exporter options and parameters
  77967. */
  77968. export interface IExportOptions {
  77969. /**
  77970. * Function which indicates whether a babylon node should be exported or not
  77971. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77972. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77973. */
  77974. shouldExportNode?(node: Node): boolean;
  77975. /**
  77976. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77977. * @param metadata source metadata to read from
  77978. * @returns the data to store to glTF node extras
  77979. */
  77980. metadataSelector?(metadata: any): any;
  77981. /**
  77982. * The sample rate to bake animation curves
  77983. */
  77984. animationSampleRate?: number;
  77985. /**
  77986. * Begin serialization without waiting for the scene to be ready
  77987. */
  77988. exportWithoutWaitingForScene?: boolean;
  77989. /**
  77990. * Indicates if coordinate system swapping root nodes should be included in export
  77991. */
  77992. includeCoordinateSystemConversionNodes?: boolean;
  77993. }
  77994. /**
  77995. * Class for generating glTF data from a Babylon scene.
  77996. */
  77997. export class GLTF2Export {
  77998. /**
  77999. * Exports the geometry of the scene to .gltf file format asynchronously
  78000. * @param scene Babylon scene with scene hierarchy information
  78001. * @param filePrefix File prefix to use when generating the glTF file
  78002. * @param options Exporter options
  78003. * @returns Returns an object with a .gltf file and associates texture names
  78004. * as keys and their data and paths as values
  78005. */
  78006. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78007. private static _PreExportAsync;
  78008. private static _PostExportAsync;
  78009. /**
  78010. * Exports the geometry of the scene to .glb file format asychronously
  78011. * @param scene Babylon scene with scene hierarchy information
  78012. * @param filePrefix File prefix to use when generating glb file
  78013. * @param options Exporter options
  78014. * @returns Returns an object with a .glb filename as key and data as value
  78015. */
  78016. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78017. }
  78018. }
  78019. declare module BABYLON.GLTF2.Exporter {
  78020. /**
  78021. * @hidden
  78022. */
  78023. export class _GLTFUtilities {
  78024. /**
  78025. * Creates a buffer view based on the supplied arguments
  78026. * @param bufferIndex index value of the specified buffer
  78027. * @param byteOffset byte offset value
  78028. * @param byteLength byte length of the bufferView
  78029. * @param byteStride byte distance between conequential elements
  78030. * @param name name of the buffer view
  78031. * @returns bufferView for glTF
  78032. */
  78033. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  78034. /**
  78035. * Creates an accessor based on the supplied arguments
  78036. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  78037. * @param name The name of the accessor
  78038. * @param type The type of the accessor
  78039. * @param componentType The datatype of components in the attribute
  78040. * @param count The number of attributes referenced by this accessor
  78041. * @param byteOffset The offset relative to the start of the bufferView in bytes
  78042. * @param min Minimum value of each component in this attribute
  78043. * @param max Maximum value of each component in this attribute
  78044. * @returns accessor for glTF
  78045. */
  78046. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  78047. /**
  78048. * Calculates the minimum and maximum values of an array of position floats
  78049. * @param positions Positions array of a mesh
  78050. * @param vertexStart Starting vertex offset to calculate min and max values
  78051. * @param vertexCount Number of vertices to check for min and max values
  78052. * @returns min number array and max number array
  78053. */
  78054. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  78055. min: number[];
  78056. max: number[];
  78057. };
  78058. /**
  78059. * Converts a new right-handed Vector3
  78060. * @param vector vector3 array
  78061. * @returns right-handed Vector3
  78062. */
  78063. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  78064. /**
  78065. * Converts a Vector3 to right-handed
  78066. * @param vector Vector3 to convert to right-handed
  78067. */
  78068. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  78069. /**
  78070. * Converts a three element number array to right-handed
  78071. * @param vector number array to convert to right-handed
  78072. */
  78073. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  78074. /**
  78075. * Converts a new right-handed Vector3
  78076. * @param vector vector3 array
  78077. * @returns right-handed Vector3
  78078. */
  78079. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  78080. /**
  78081. * Converts a Vector3 to right-handed
  78082. * @param vector Vector3 to convert to right-handed
  78083. */
  78084. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  78085. /**
  78086. * Converts a three element number array to right-handed
  78087. * @param vector number array to convert to right-handed
  78088. */
  78089. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  78090. /**
  78091. * Converts a Vector4 to right-handed
  78092. * @param vector Vector4 to convert to right-handed
  78093. */
  78094. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  78095. /**
  78096. * Converts a Vector4 to right-handed
  78097. * @param vector Vector4 to convert to right-handed
  78098. */
  78099. static _GetRightHandedArray4FromRef(vector: number[]): void;
  78100. /**
  78101. * Converts a Quaternion to right-handed
  78102. * @param quaternion Source quaternion to convert to right-handed
  78103. */
  78104. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  78105. /**
  78106. * Converts a Quaternion to right-handed
  78107. * @param quaternion Source quaternion to convert to right-handed
  78108. */
  78109. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  78110. static _NormalizeTangentFromRef(tangent: Vector4): void;
  78111. }
  78112. }
  78113. declare module BABYLON.GLTF2.Exporter {
  78114. /**
  78115. * Converts Babylon Scene into glTF 2.0.
  78116. * @hidden
  78117. */
  78118. export class _Exporter {
  78119. /**
  78120. * Stores the glTF to export
  78121. */
  78122. _glTF: IGLTF;
  78123. /**
  78124. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78125. */
  78126. _bufferViews: IBufferView[];
  78127. /**
  78128. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78129. */
  78130. _accessors: IAccessor[];
  78131. /**
  78132. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78133. */
  78134. _nodes: INode[];
  78135. /**
  78136. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78137. */
  78138. private _scenes;
  78139. /**
  78140. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78141. */
  78142. private _meshes;
  78143. /**
  78144. * Stores all the generated material information, which represents the appearance of each primitive
  78145. */
  78146. _materials: IMaterial[];
  78147. _materialMap: {
  78148. [materialID: number]: number;
  78149. };
  78150. /**
  78151. * Stores all the generated texture information, which is referenced by glTF materials
  78152. */
  78153. _textures: ITexture[];
  78154. /**
  78155. * Stores all the generated image information, which is referenced by glTF textures
  78156. */
  78157. _images: IImage[];
  78158. /**
  78159. * Stores all the texture samplers
  78160. */
  78161. _samplers: ISampler[];
  78162. /**
  78163. * Stores all the generated animation samplers, which is referenced by glTF animations
  78164. */
  78165. /**
  78166. * Stores the animations for glTF models
  78167. */
  78168. private _animations;
  78169. /**
  78170. * Stores the total amount of bytes stored in the glTF buffer
  78171. */
  78172. private _totalByteLength;
  78173. /**
  78174. * Stores a reference to the Babylon scene containing the source geometry and material information
  78175. */
  78176. _babylonScene: Scene;
  78177. /**
  78178. * Stores a map of the image data, where the key is the file name and the value
  78179. * is the image data
  78180. */
  78181. _imageData: {
  78182. [fileName: string]: {
  78183. data: Uint8Array;
  78184. mimeType: ImageMimeType;
  78185. };
  78186. };
  78187. /**
  78188. * Stores a map of the unique id of a node to its index in the node array
  78189. */
  78190. _nodeMap: {
  78191. [key: number]: number;
  78192. };
  78193. /**
  78194. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78195. */
  78196. _convertToRightHandedSystem: boolean;
  78197. /**
  78198. * Specifies if a Babylon node should be converted to right-handed on export
  78199. */
  78200. _convertToRightHandedSystemMap: {
  78201. [nodeId: number]: boolean;
  78202. };
  78203. _includeCoordinateSystemConversionNodes: boolean;
  78204. /**
  78205. * Baked animation sample rate
  78206. */
  78207. private _animationSampleRate;
  78208. private _options;
  78209. private _localEngine;
  78210. _glTFMaterialExporter: _GLTFMaterialExporter;
  78211. private _extensions;
  78212. private static _ExtensionNames;
  78213. private static _ExtensionFactories;
  78214. private _applyExtension;
  78215. private _applyExtensions;
  78216. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78217. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78218. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78219. [key: number]: number;
  78220. }): Promise<Nullable<INode>>;
  78221. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78222. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78223. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78224. private _forEachExtensions;
  78225. private _extensionsOnExporting;
  78226. /**
  78227. * Load glTF serializer extensions
  78228. */
  78229. private _loadExtensions;
  78230. /**
  78231. * Creates a glTF Exporter instance, which can accept optional exporter options
  78232. * @param babylonScene Babylon scene object
  78233. * @param options Options to modify the behavior of the exporter
  78234. */
  78235. constructor(babylonScene: Scene, options?: IExportOptions);
  78236. dispose(): void;
  78237. /**
  78238. * Registers a glTF exporter extension
  78239. * @param name Name of the extension to export
  78240. * @param factory The factory function that creates the exporter extension
  78241. */
  78242. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78243. /**
  78244. * Un-registers an exporter extension
  78245. * @param name The name fo the exporter extension
  78246. * @returns A boolean indicating whether the extension has been un-registered
  78247. */
  78248. static UnregisterExtension(name: string): boolean;
  78249. /**
  78250. * Lazy load a local engine
  78251. */
  78252. _getLocalEngine(): Engine;
  78253. private reorderIndicesBasedOnPrimitiveMode;
  78254. /**
  78255. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78256. * clock-wise during export to glTF
  78257. * @param submesh BabylonJS submesh
  78258. * @param primitiveMode Primitive mode of the mesh
  78259. * @param sideOrientation the winding order of the submesh
  78260. * @param vertexBufferKind The type of vertex attribute
  78261. * @param meshAttributeArray The vertex attribute data
  78262. * @param byteOffset The offset to the binary data
  78263. * @param binaryWriter The binary data for the glTF file
  78264. * @param convertToRightHandedSystem Converts the values to right-handed
  78265. */
  78266. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78267. /**
  78268. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78269. * clock-wise during export to glTF
  78270. * @param submesh BabylonJS submesh
  78271. * @param primitiveMode Primitive mode of the mesh
  78272. * @param sideOrientation the winding order of the submesh
  78273. * @param vertexBufferKind The type of vertex attribute
  78274. * @param meshAttributeArray The vertex attribute data
  78275. * @param byteOffset The offset to the binary data
  78276. * @param binaryWriter The binary data for the glTF file
  78277. * @param convertToRightHandedSystem Converts the values to right-handed
  78278. */
  78279. private reorderTriangleFillMode;
  78280. /**
  78281. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78282. * clock-wise during export to glTF
  78283. * @param submesh BabylonJS submesh
  78284. * @param primitiveMode Primitive mode of the mesh
  78285. * @param sideOrientation the winding order of the submesh
  78286. * @param vertexBufferKind The type of vertex attribute
  78287. * @param meshAttributeArray The vertex attribute data
  78288. * @param byteOffset The offset to the binary data
  78289. * @param binaryWriter The binary data for the glTF file
  78290. * @param convertToRightHandedSystem Converts the values to right-handed
  78291. */
  78292. private reorderTriangleStripDrawMode;
  78293. /**
  78294. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78295. * clock-wise during export to glTF
  78296. * @param submesh BabylonJS submesh
  78297. * @param primitiveMode Primitive mode of the mesh
  78298. * @param sideOrientation the winding order of the submesh
  78299. * @param vertexBufferKind The type of vertex attribute
  78300. * @param meshAttributeArray The vertex attribute data
  78301. * @param byteOffset The offset to the binary data
  78302. * @param binaryWriter The binary data for the glTF file
  78303. * @param convertToRightHandedSystem Converts the values to right-handed
  78304. */
  78305. private reorderTriangleFanMode;
  78306. /**
  78307. * Writes the vertex attribute data to binary
  78308. * @param vertices The vertices to write to the binary writer
  78309. * @param byteOffset The offset into the binary writer to overwrite binary data
  78310. * @param vertexAttributeKind The vertex attribute type
  78311. * @param meshAttributeArray The vertex attribute data
  78312. * @param binaryWriter The writer containing the binary data
  78313. * @param convertToRightHandedSystem Converts the values to right-handed
  78314. */
  78315. private writeVertexAttributeData;
  78316. /**
  78317. * Writes mesh attribute data to a data buffer
  78318. * Returns the bytelength of the data
  78319. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78320. * @param meshAttributeArray Array containing the attribute data
  78321. * @param binaryWriter The buffer to write the binary data to
  78322. * @param indices Used to specify the order of the vertex data
  78323. * @param convertToRightHandedSystem Converts the values to right-handed
  78324. */
  78325. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78326. /**
  78327. * Generates glTF json data
  78328. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78329. * @param glTFPrefix Text to use when prefixing a glTF file
  78330. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78331. * @returns json data as string
  78332. */
  78333. private generateJSON;
  78334. /**
  78335. * Generates data for .gltf and .bin files based on the glTF prefix string
  78336. * @param glTFPrefix Text to use when prefixing a glTF file
  78337. * @param dispose Dispose the exporter
  78338. * @returns GLTFData with glTF file data
  78339. */
  78340. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78341. /**
  78342. * Creates a binary buffer for glTF
  78343. * @returns array buffer for binary data
  78344. */
  78345. private _generateBinaryAsync;
  78346. /**
  78347. * Pads the number to a multiple of 4
  78348. * @param num number to pad
  78349. * @returns padded number
  78350. */
  78351. private _getPadding;
  78352. /**
  78353. * @hidden
  78354. */
  78355. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78356. /**
  78357. * Sets the TRS for each node
  78358. * @param node glTF Node for storing the transformation data
  78359. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78360. * @param convertToRightHandedSystem Converts the values to right-handed
  78361. */
  78362. private setNodeTransformation;
  78363. private getVertexBufferFromMesh;
  78364. /**
  78365. * Creates a bufferview based on the vertices type for the Babylon mesh
  78366. * @param kind Indicates the type of vertices data
  78367. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78368. * @param binaryWriter The buffer to write the bufferview data to
  78369. * @param convertToRightHandedSystem Converts the values to right-handed
  78370. */
  78371. private createBufferViewKind;
  78372. /**
  78373. * The primitive mode of the Babylon mesh
  78374. * @param babylonMesh The BabylonJS mesh
  78375. */
  78376. private getMeshPrimitiveMode;
  78377. /**
  78378. * Sets the primitive mode of the glTF mesh primitive
  78379. * @param meshPrimitive glTF mesh primitive
  78380. * @param primitiveMode The primitive mode
  78381. */
  78382. private setPrimitiveMode;
  78383. /**
  78384. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78385. * @param meshPrimitive glTF mesh primitive
  78386. * @param attributeKind vertex attribute
  78387. * @returns boolean specifying if uv coordinates are present
  78388. */
  78389. private setAttributeKind;
  78390. /**
  78391. * Sets data for the primitive attributes of each submesh
  78392. * @param mesh glTF Mesh object to store the primitive attribute information
  78393. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78394. * @param binaryWriter Buffer to write the attribute data to
  78395. * @param convertToRightHandedSystem Converts the values to right-handed
  78396. */
  78397. private setPrimitiveAttributesAsync;
  78398. /**
  78399. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78400. * @param node The node to check
  78401. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78402. */
  78403. private isBabylonCoordinateSystemConvertingNode;
  78404. /**
  78405. * Creates a glTF scene based on the array of meshes
  78406. * Returns the the total byte offset
  78407. * @param babylonScene Babylon scene to get the mesh data from
  78408. * @param binaryWriter Buffer to write binary data to
  78409. */
  78410. private createSceneAsync;
  78411. /**
  78412. * Creates a mapping of Node unique id to node index and handles animations
  78413. * @param babylonScene Babylon Scene
  78414. * @param nodes Babylon transform nodes
  78415. * @param binaryWriter Buffer to write binary data to
  78416. * @returns Node mapping of unique id to index
  78417. */
  78418. private createNodeMapAndAnimationsAsync;
  78419. /**
  78420. * Creates a glTF node from a Babylon mesh
  78421. * @param babylonMesh Source Babylon mesh
  78422. * @param binaryWriter Buffer for storing geometry data
  78423. * @param convertToRightHandedSystem Converts the values to right-handed
  78424. * @param nodeMap Node mapping of unique id to glTF node index
  78425. * @returns glTF node
  78426. */
  78427. private createNodeAsync;
  78428. }
  78429. /**
  78430. * @hidden
  78431. *
  78432. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78433. */
  78434. export class _BinaryWriter {
  78435. /**
  78436. * Array buffer which stores all binary data
  78437. */
  78438. private _arrayBuffer;
  78439. /**
  78440. * View of the array buffer
  78441. */
  78442. private _dataView;
  78443. /**
  78444. * byte offset of data in array buffer
  78445. */
  78446. private _byteOffset;
  78447. /**
  78448. * Initialize binary writer with an initial byte length
  78449. * @param byteLength Initial byte length of the array buffer
  78450. */
  78451. constructor(byteLength: number);
  78452. /**
  78453. * Resize the array buffer to the specified byte length
  78454. * @param byteLength
  78455. */
  78456. private resizeBuffer;
  78457. /**
  78458. * Get an array buffer with the length of the byte offset
  78459. * @returns ArrayBuffer resized to the byte offset
  78460. */
  78461. getArrayBuffer(): ArrayBuffer;
  78462. /**
  78463. * Get the byte offset of the array buffer
  78464. * @returns byte offset
  78465. */
  78466. getByteOffset(): number;
  78467. /**
  78468. * Stores an UInt8 in the array buffer
  78469. * @param entry
  78470. * @param byteOffset If defined, specifies where to set the value as an offset.
  78471. */
  78472. setUInt8(entry: number, byteOffset?: number): void;
  78473. /**
  78474. * Gets an UInt32 in the array buffer
  78475. * @param entry
  78476. * @param byteOffset If defined, specifies where to set the value as an offset.
  78477. */
  78478. getUInt32(byteOffset: number): number;
  78479. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78480. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78481. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78482. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78483. /**
  78484. * Stores a Float32 in the array buffer
  78485. * @param entry
  78486. */
  78487. setFloat32(entry: number, byteOffset?: number): void;
  78488. /**
  78489. * Stores an UInt32 in the array buffer
  78490. * @param entry
  78491. * @param byteOffset If defined, specifies where to set the value as an offset.
  78492. */
  78493. setUInt32(entry: number, byteOffset?: number): void;
  78494. }
  78495. }
  78496. declare module BABYLON.GLTF2.Exporter {
  78497. /**
  78498. * @hidden
  78499. * Interface to store animation data.
  78500. */
  78501. export interface _IAnimationData {
  78502. /**
  78503. * Keyframe data.
  78504. */
  78505. inputs: number[];
  78506. /**
  78507. * Value data.
  78508. */
  78509. outputs: number[][];
  78510. /**
  78511. * Animation interpolation data.
  78512. */
  78513. samplerInterpolation: AnimationSamplerInterpolation;
  78514. /**
  78515. * Minimum keyframe value.
  78516. */
  78517. inputsMin: number;
  78518. /**
  78519. * Maximum keyframe value.
  78520. */
  78521. inputsMax: number;
  78522. }
  78523. /**
  78524. * @hidden
  78525. */
  78526. export interface _IAnimationInfo {
  78527. /**
  78528. * The target channel for the animation
  78529. */
  78530. animationChannelTargetPath: AnimationChannelTargetPath;
  78531. /**
  78532. * The glTF accessor type for the data.
  78533. */
  78534. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78535. /**
  78536. * Specifies if quaternions should be used.
  78537. */
  78538. useQuaternion: boolean;
  78539. }
  78540. /**
  78541. * @hidden
  78542. * Utility class for generating glTF animation data from BabylonJS.
  78543. */
  78544. export class _GLTFAnimation {
  78545. /**
  78546. * @ignore
  78547. *
  78548. * Creates glTF channel animation from BabylonJS animation.
  78549. * @param babylonTransformNode - BabylonJS mesh.
  78550. * @param animation - animation.
  78551. * @param animationChannelTargetPath - The target animation channel.
  78552. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78553. * @param useQuaternion - Specifies if quaternions are used.
  78554. * @returns nullable IAnimationData
  78555. */
  78556. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78557. private static _DeduceAnimationInfo;
  78558. /**
  78559. * @ignore
  78560. * Create node animations from the transform node animations
  78561. * @param babylonNode
  78562. * @param runtimeGLTFAnimation
  78563. * @param idleGLTFAnimations
  78564. * @param nodeMap
  78565. * @param nodes
  78566. * @param binaryWriter
  78567. * @param bufferViews
  78568. * @param accessors
  78569. * @param convertToRightHandedSystem
  78570. * @param animationSampleRate
  78571. */
  78572. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78573. [key: number]: number;
  78574. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78575. /**
  78576. * @ignore
  78577. * Create node animations from the animation groups
  78578. * @param babylonScene
  78579. * @param glTFAnimations
  78580. * @param nodeMap
  78581. * @param nodes
  78582. * @param binaryWriter
  78583. * @param bufferViews
  78584. * @param accessors
  78585. * @param convertToRightHandedSystemMap
  78586. * @param animationSampleRate
  78587. */
  78588. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78589. [key: number]: number;
  78590. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78591. [nodeId: number]: boolean;
  78592. }, animationSampleRate: number): void;
  78593. private static AddAnimation;
  78594. /**
  78595. * Create a baked animation
  78596. * @param babylonTransformNode BabylonJS mesh
  78597. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78598. * @param animationChannelTargetPath animation target channel
  78599. * @param minFrame minimum animation frame
  78600. * @param maxFrame maximum animation frame
  78601. * @param fps frames per second of the animation
  78602. * @param inputs input key frames of the animation
  78603. * @param outputs output key frame data of the animation
  78604. * @param convertToRightHandedSystem converts the values to right-handed
  78605. * @param useQuaternion specifies if quaternions should be used
  78606. */
  78607. private static _CreateBakedAnimation;
  78608. private static _ConvertFactorToVector3OrQuaternion;
  78609. private static _SetInterpolatedValue;
  78610. /**
  78611. * Creates linear animation from the animation key frames
  78612. * @param babylonTransformNode BabylonJS mesh
  78613. * @param animation BabylonJS animation
  78614. * @param animationChannelTargetPath The target animation channel
  78615. * @param frameDelta The difference between the last and first frame of the animation
  78616. * @param inputs Array to store the key frame times
  78617. * @param outputs Array to store the key frame data
  78618. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78619. * @param useQuaternion Specifies if quaternions are used in the animation
  78620. */
  78621. private static _CreateLinearOrStepAnimation;
  78622. /**
  78623. * Creates cubic spline animation from the animation key frames
  78624. * @param babylonTransformNode BabylonJS mesh
  78625. * @param animation BabylonJS animation
  78626. * @param animationChannelTargetPath The target animation channel
  78627. * @param frameDelta The difference between the last and first frame of the animation
  78628. * @param inputs Array to store the key frame times
  78629. * @param outputs Array to store the key frame data
  78630. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78631. * @param useQuaternion Specifies if quaternions are used in the animation
  78632. */
  78633. private static _CreateCubicSplineAnimation;
  78634. private static _GetBasePositionRotationOrScale;
  78635. /**
  78636. * Adds a key frame value
  78637. * @param keyFrame
  78638. * @param animation
  78639. * @param outputs
  78640. * @param animationChannelTargetPath
  78641. * @param basePositionRotationOrScale
  78642. * @param convertToRightHandedSystem
  78643. * @param useQuaternion
  78644. */
  78645. private static _AddKeyframeValue;
  78646. /**
  78647. * Determine the interpolation based on the key frames
  78648. * @param keyFrames
  78649. * @param animationChannelTargetPath
  78650. * @param useQuaternion
  78651. */
  78652. private static _DeduceInterpolation;
  78653. /**
  78654. * Adds an input tangent or output tangent to the output data
  78655. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78656. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78657. * @param outputs The animation data by keyframe
  78658. * @param animationChannelTargetPath The target animation channel
  78659. * @param interpolation The interpolation type
  78660. * @param keyFrame The key frame with the animation data
  78661. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78662. * @param useQuaternion Specifies if quaternions are used
  78663. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78664. */
  78665. private static AddSplineTangent;
  78666. /**
  78667. * Get the minimum and maximum key frames' frame values
  78668. * @param keyFrames animation key frames
  78669. * @returns the minimum and maximum key frame value
  78670. */
  78671. private static calculateMinMaxKeyFrames;
  78672. }
  78673. }
  78674. declare module BABYLON.GLTF2.Exporter {
  78675. /** @hidden */
  78676. export var textureTransformPixelShader: {
  78677. name: string;
  78678. shader: string;
  78679. };
  78680. }
  78681. declare module BABYLON.GLTF2.Exporter.Extensions {
  78682. /**
  78683. * @hidden
  78684. */
  78685. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78686. private _recordedTextures;
  78687. /** Name of this extension */
  78688. readonly name: string;
  78689. /** Defines whether this extension is enabled */
  78690. enabled: boolean;
  78691. /** Defines whether this extension is required */
  78692. required: boolean;
  78693. /** Reference to the glTF exporter */
  78694. private _wasUsed;
  78695. constructor(exporter: _Exporter);
  78696. dispose(): void;
  78697. /** @hidden */
  78698. get wasUsed(): boolean;
  78699. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78700. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78701. /**
  78702. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78703. * @param babylonTexture
  78704. * @param offset
  78705. * @param rotation
  78706. * @param scale
  78707. * @param scene
  78708. */
  78709. private _textureTransformTextureAsync;
  78710. }
  78711. }
  78712. declare module BABYLON.GLTF2.Exporter.Extensions {
  78713. /**
  78714. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78715. */
  78716. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78717. /** The name of this extension. */
  78718. readonly name: string;
  78719. /** Defines whether this extension is enabled. */
  78720. enabled: boolean;
  78721. /** Defines whether this extension is required */
  78722. required: boolean;
  78723. /** Reference to the glTF exporter */
  78724. private _exporter;
  78725. private _lights;
  78726. /** @hidden */
  78727. constructor(exporter: _Exporter);
  78728. /** @hidden */
  78729. dispose(): void;
  78730. /** @hidden */
  78731. get wasUsed(): boolean;
  78732. /** @hidden */
  78733. onExporting(): void;
  78734. /**
  78735. * Define this method to modify the default behavior when exporting a node
  78736. * @param context The context when exporting the node
  78737. * @param node glTF node
  78738. * @param babylonNode BabylonJS node
  78739. * @param nodeMap Node mapping of unique id to glTF node index
  78740. * @returns nullable INode promise
  78741. */
  78742. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78743. [key: number]: number;
  78744. }): Promise<Nullable<INode>>;
  78745. }
  78746. }
  78747. declare module BABYLON.GLTF2.Exporter.Extensions {
  78748. /**
  78749. * @hidden
  78750. */
  78751. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78752. /** Name of this extension */
  78753. readonly name: string;
  78754. /** Defines whether this extension is enabled */
  78755. enabled: boolean;
  78756. /** Defines whether this extension is required */
  78757. required: boolean;
  78758. /** Reference to the glTF exporter */
  78759. private _textureInfos;
  78760. private _exportedTextures;
  78761. private _wasUsed;
  78762. constructor(exporter: _Exporter);
  78763. dispose(): void;
  78764. /** @hidden */
  78765. get wasUsed(): boolean;
  78766. private _getTextureIndex;
  78767. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78768. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78769. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78770. }
  78771. }
  78772. declare module BABYLON {
  78773. /**
  78774. * Class for generating STL data from a Babylon scene.
  78775. */
  78776. export class STLExport {
  78777. /**
  78778. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78779. * @param meshes list defines the mesh to serialize
  78780. * @param download triggers the automatic download of the file.
  78781. * @param fileName changes the downloads fileName.
  78782. * @param binary changes the STL to a binary type.
  78783. * @param isLittleEndian toggle for binary type exporter.
  78784. * @returns the STL as UTF8 string
  78785. */
  78786. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78787. }
  78788. }
  78789. declare module "babylonjs-gltf2interface" {
  78790. export = BABYLON.GLTF2;
  78791. }
  78792. /**
  78793. * Module for glTF 2.0 Interface
  78794. */
  78795. declare module BABYLON.GLTF2 {
  78796. /**
  78797. * The datatype of the components in the attribute
  78798. */
  78799. const enum AccessorComponentType {
  78800. /**
  78801. * Byte
  78802. */
  78803. BYTE = 5120,
  78804. /**
  78805. * Unsigned Byte
  78806. */
  78807. UNSIGNED_BYTE = 5121,
  78808. /**
  78809. * Short
  78810. */
  78811. SHORT = 5122,
  78812. /**
  78813. * Unsigned Short
  78814. */
  78815. UNSIGNED_SHORT = 5123,
  78816. /**
  78817. * Unsigned Int
  78818. */
  78819. UNSIGNED_INT = 5125,
  78820. /**
  78821. * Float
  78822. */
  78823. FLOAT = 5126,
  78824. }
  78825. /**
  78826. * Specifies if the attirbute is a scalar, vector, or matrix
  78827. */
  78828. const enum AccessorType {
  78829. /**
  78830. * Scalar
  78831. */
  78832. SCALAR = "SCALAR",
  78833. /**
  78834. * Vector2
  78835. */
  78836. VEC2 = "VEC2",
  78837. /**
  78838. * Vector3
  78839. */
  78840. VEC3 = "VEC3",
  78841. /**
  78842. * Vector4
  78843. */
  78844. VEC4 = "VEC4",
  78845. /**
  78846. * Matrix2x2
  78847. */
  78848. MAT2 = "MAT2",
  78849. /**
  78850. * Matrix3x3
  78851. */
  78852. MAT3 = "MAT3",
  78853. /**
  78854. * Matrix4x4
  78855. */
  78856. MAT4 = "MAT4",
  78857. }
  78858. /**
  78859. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78860. */
  78861. const enum AnimationChannelTargetPath {
  78862. /**
  78863. * Translation
  78864. */
  78865. TRANSLATION = "translation",
  78866. /**
  78867. * Rotation
  78868. */
  78869. ROTATION = "rotation",
  78870. /**
  78871. * Scale
  78872. */
  78873. SCALE = "scale",
  78874. /**
  78875. * Weights
  78876. */
  78877. WEIGHTS = "weights",
  78878. }
  78879. /**
  78880. * Interpolation algorithm
  78881. */
  78882. const enum AnimationSamplerInterpolation {
  78883. /**
  78884. * The animated values are linearly interpolated between keyframes
  78885. */
  78886. LINEAR = "LINEAR",
  78887. /**
  78888. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78889. */
  78890. STEP = "STEP",
  78891. /**
  78892. * The animation's interpolation is computed using a cubic spline with specified tangents
  78893. */
  78894. CUBICSPLINE = "CUBICSPLINE",
  78895. }
  78896. /**
  78897. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78898. */
  78899. const enum CameraType {
  78900. /**
  78901. * A perspective camera containing properties to create a perspective projection matrix
  78902. */
  78903. PERSPECTIVE = "perspective",
  78904. /**
  78905. * An orthographic camera containing properties to create an orthographic projection matrix
  78906. */
  78907. ORTHOGRAPHIC = "orthographic",
  78908. }
  78909. /**
  78910. * The mime-type of the image
  78911. */
  78912. const enum ImageMimeType {
  78913. /**
  78914. * JPEG Mime-type
  78915. */
  78916. JPEG = "image/jpeg",
  78917. /**
  78918. * PNG Mime-type
  78919. */
  78920. PNG = "image/png",
  78921. }
  78922. /**
  78923. * The alpha rendering mode of the material
  78924. */
  78925. const enum MaterialAlphaMode {
  78926. /**
  78927. * The alpha value is ignored and the rendered output is fully opaque
  78928. */
  78929. OPAQUE = "OPAQUE",
  78930. /**
  78931. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78932. */
  78933. MASK = "MASK",
  78934. /**
  78935. * 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)
  78936. */
  78937. BLEND = "BLEND",
  78938. }
  78939. /**
  78940. * The type of the primitives to render
  78941. */
  78942. const enum MeshPrimitiveMode {
  78943. /**
  78944. * Points
  78945. */
  78946. POINTS = 0,
  78947. /**
  78948. * Lines
  78949. */
  78950. LINES = 1,
  78951. /**
  78952. * Line Loop
  78953. */
  78954. LINE_LOOP = 2,
  78955. /**
  78956. * Line Strip
  78957. */
  78958. LINE_STRIP = 3,
  78959. /**
  78960. * Triangles
  78961. */
  78962. TRIANGLES = 4,
  78963. /**
  78964. * Triangle Strip
  78965. */
  78966. TRIANGLE_STRIP = 5,
  78967. /**
  78968. * Triangle Fan
  78969. */
  78970. TRIANGLE_FAN = 6,
  78971. }
  78972. /**
  78973. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78974. */
  78975. const enum TextureMagFilter {
  78976. /**
  78977. * Nearest
  78978. */
  78979. NEAREST = 9728,
  78980. /**
  78981. * Linear
  78982. */
  78983. LINEAR = 9729,
  78984. }
  78985. /**
  78986. * Minification filter. All valid values correspond to WebGL enums
  78987. */
  78988. const enum TextureMinFilter {
  78989. /**
  78990. * Nearest
  78991. */
  78992. NEAREST = 9728,
  78993. /**
  78994. * Linear
  78995. */
  78996. LINEAR = 9729,
  78997. /**
  78998. * Nearest Mip-Map Nearest
  78999. */
  79000. NEAREST_MIPMAP_NEAREST = 9984,
  79001. /**
  79002. * Linear Mipmap Nearest
  79003. */
  79004. LINEAR_MIPMAP_NEAREST = 9985,
  79005. /**
  79006. * Nearest Mipmap Linear
  79007. */
  79008. NEAREST_MIPMAP_LINEAR = 9986,
  79009. /**
  79010. * Linear Mipmap Linear
  79011. */
  79012. LINEAR_MIPMAP_LINEAR = 9987,
  79013. }
  79014. /**
  79015. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79016. */
  79017. const enum TextureWrapMode {
  79018. /**
  79019. * Clamp to Edge
  79020. */
  79021. CLAMP_TO_EDGE = 33071,
  79022. /**
  79023. * Mirrored Repeat
  79024. */
  79025. MIRRORED_REPEAT = 33648,
  79026. /**
  79027. * Repeat
  79028. */
  79029. REPEAT = 10497,
  79030. }
  79031. /**
  79032. * glTF Property
  79033. */
  79034. interface IProperty {
  79035. /**
  79036. * Dictionary object with extension-specific objects
  79037. */
  79038. extensions?: {
  79039. [key: string]: any;
  79040. };
  79041. /**
  79042. * Application-Specific data
  79043. */
  79044. extras?: any;
  79045. }
  79046. /**
  79047. * glTF Child of Root Property
  79048. */
  79049. interface IChildRootProperty extends IProperty {
  79050. /**
  79051. * The user-defined name of this object
  79052. */
  79053. name?: string;
  79054. }
  79055. /**
  79056. * Indices of those attributes that deviate from their initialization value
  79057. */
  79058. interface IAccessorSparseIndices extends IProperty {
  79059. /**
  79060. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79061. */
  79062. bufferView: number;
  79063. /**
  79064. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79065. */
  79066. byteOffset?: number;
  79067. /**
  79068. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  79069. */
  79070. componentType: AccessorComponentType;
  79071. }
  79072. /**
  79073. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  79074. */
  79075. interface IAccessorSparseValues extends IProperty {
  79076. /**
  79077. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79078. */
  79079. bufferView: number;
  79080. /**
  79081. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79082. */
  79083. byteOffset?: number;
  79084. }
  79085. /**
  79086. * Sparse storage of attributes that deviate from their initialization value
  79087. */
  79088. interface IAccessorSparse extends IProperty {
  79089. /**
  79090. * The number of attributes encoded in this sparse accessor
  79091. */
  79092. count: number;
  79093. /**
  79094. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  79095. */
  79096. indices: IAccessorSparseIndices;
  79097. /**
  79098. * 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
  79099. */
  79100. values: IAccessorSparseValues;
  79101. }
  79102. /**
  79103. * 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
  79104. */
  79105. interface IAccessor extends IChildRootProperty {
  79106. /**
  79107. * The index of the bufferview
  79108. */
  79109. bufferView?: number;
  79110. /**
  79111. * The offset relative to the start of the bufferView in bytes
  79112. */
  79113. byteOffset?: number;
  79114. /**
  79115. * The datatype of components in the attribute
  79116. */
  79117. componentType: AccessorComponentType;
  79118. /**
  79119. * Specifies whether integer data values should be normalized
  79120. */
  79121. normalized?: boolean;
  79122. /**
  79123. * The number of attributes referenced by this accessor
  79124. */
  79125. count: number;
  79126. /**
  79127. * Specifies if the attribute is a scalar, vector, or matrix
  79128. */
  79129. type: AccessorType;
  79130. /**
  79131. * Maximum value of each component in this attribute
  79132. */
  79133. max?: number[];
  79134. /**
  79135. * Minimum value of each component in this attribute
  79136. */
  79137. min?: number[];
  79138. /**
  79139. * Sparse storage of attributes that deviate from their initialization value
  79140. */
  79141. sparse?: IAccessorSparse;
  79142. }
  79143. /**
  79144. * Targets an animation's sampler at a node's property
  79145. */
  79146. interface IAnimationChannel extends IProperty {
  79147. /**
  79148. * The index of a sampler in this animation used to compute the value for the target
  79149. */
  79150. sampler: number;
  79151. /**
  79152. * The index of the node and TRS property to target
  79153. */
  79154. target: IAnimationChannelTarget;
  79155. }
  79156. /**
  79157. * The index of the node and TRS property that an animation channel targets
  79158. */
  79159. interface IAnimationChannelTarget extends IProperty {
  79160. /**
  79161. * The index of the node to target
  79162. */
  79163. node: number;
  79164. /**
  79165. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79166. */
  79167. path: AnimationChannelTargetPath;
  79168. }
  79169. /**
  79170. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79171. */
  79172. interface IAnimationSampler extends IProperty {
  79173. /**
  79174. * The index of an accessor containing keyframe input values, e.g., time
  79175. */
  79176. input: number;
  79177. /**
  79178. * Interpolation algorithm
  79179. */
  79180. interpolation?: AnimationSamplerInterpolation;
  79181. /**
  79182. * The index of an accessor, containing keyframe output values
  79183. */
  79184. output: number;
  79185. }
  79186. /**
  79187. * A keyframe animation
  79188. */
  79189. interface IAnimation extends IChildRootProperty {
  79190. /**
  79191. * An array of channels, each of which targets an animation's sampler at a node's property
  79192. */
  79193. channels: IAnimationChannel[];
  79194. /**
  79195. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79196. */
  79197. samplers: IAnimationSampler[];
  79198. }
  79199. /**
  79200. * Metadata about the glTF asset
  79201. */
  79202. interface IAsset extends IChildRootProperty {
  79203. /**
  79204. * A copyright message suitable for display to credit the content creator
  79205. */
  79206. copyright?: string;
  79207. /**
  79208. * Tool that generated this glTF model. Useful for debugging
  79209. */
  79210. generator?: string;
  79211. /**
  79212. * The glTF version that this asset targets
  79213. */
  79214. version: string;
  79215. /**
  79216. * The minimum glTF version that this asset targets
  79217. */
  79218. minVersion?: string;
  79219. }
  79220. /**
  79221. * A buffer points to binary geometry, animation, or skins
  79222. */
  79223. interface IBuffer extends IChildRootProperty {
  79224. /**
  79225. * 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
  79226. */
  79227. uri?: string;
  79228. /**
  79229. * The length of the buffer in bytes
  79230. */
  79231. byteLength: number;
  79232. }
  79233. /**
  79234. * A view into a buffer generally representing a subset of the buffer
  79235. */
  79236. interface IBufferView extends IChildRootProperty {
  79237. /**
  79238. * The index of the buffer
  79239. */
  79240. buffer: number;
  79241. /**
  79242. * The offset into the buffer in bytes
  79243. */
  79244. byteOffset?: number;
  79245. /**
  79246. * The lenth of the bufferView in bytes
  79247. */
  79248. byteLength: number;
  79249. /**
  79250. * The stride, in bytes
  79251. */
  79252. byteStride?: number;
  79253. }
  79254. /**
  79255. * An orthographic camera containing properties to create an orthographic projection matrix
  79256. */
  79257. interface ICameraOrthographic extends IProperty {
  79258. /**
  79259. * The floating-point horizontal magnification of the view. Must not be zero
  79260. */
  79261. xmag: number;
  79262. /**
  79263. * The floating-point vertical magnification of the view. Must not be zero
  79264. */
  79265. ymag: number;
  79266. /**
  79267. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79268. */
  79269. zfar: number;
  79270. /**
  79271. * The floating-point distance to the near clipping plane
  79272. */
  79273. znear: number;
  79274. }
  79275. /**
  79276. * A perspective camera containing properties to create a perspective projection matrix
  79277. */
  79278. interface ICameraPerspective extends IProperty {
  79279. /**
  79280. * The floating-point aspect ratio of the field of view
  79281. */
  79282. aspectRatio?: number;
  79283. /**
  79284. * The floating-point vertical field of view in radians
  79285. */
  79286. yfov: number;
  79287. /**
  79288. * The floating-point distance to the far clipping plane
  79289. */
  79290. zfar?: number;
  79291. /**
  79292. * The floating-point distance to the near clipping plane
  79293. */
  79294. znear: number;
  79295. }
  79296. /**
  79297. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79298. */
  79299. interface ICamera extends IChildRootProperty {
  79300. /**
  79301. * An orthographic camera containing properties to create an orthographic projection matrix
  79302. */
  79303. orthographic?: ICameraOrthographic;
  79304. /**
  79305. * A perspective camera containing properties to create a perspective projection matrix
  79306. */
  79307. perspective?: ICameraPerspective;
  79308. /**
  79309. * Specifies if the camera uses a perspective or orthographic projection
  79310. */
  79311. type: CameraType;
  79312. }
  79313. /**
  79314. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79315. */
  79316. interface IImage extends IChildRootProperty {
  79317. /**
  79318. * 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
  79319. */
  79320. uri?: string;
  79321. /**
  79322. * The image's MIME type
  79323. */
  79324. mimeType?: ImageMimeType;
  79325. /**
  79326. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79327. */
  79328. bufferView?: number;
  79329. }
  79330. /**
  79331. * Material Normal Texture Info
  79332. */
  79333. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79334. /**
  79335. * The scalar multiplier applied to each normal vector of the normal texture
  79336. */
  79337. scale?: number;
  79338. }
  79339. /**
  79340. * Material Occlusion Texture Info
  79341. */
  79342. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79343. /**
  79344. * A scalar multiplier controlling the amount of occlusion applied
  79345. */
  79346. strength?: number;
  79347. }
  79348. /**
  79349. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79350. */
  79351. interface IMaterialPbrMetallicRoughness {
  79352. /**
  79353. * The material's base color factor
  79354. */
  79355. baseColorFactor?: number[];
  79356. /**
  79357. * The base color texture
  79358. */
  79359. baseColorTexture?: ITextureInfo;
  79360. /**
  79361. * The metalness of the material
  79362. */
  79363. metallicFactor?: number;
  79364. /**
  79365. * The roughness of the material
  79366. */
  79367. roughnessFactor?: number;
  79368. /**
  79369. * The metallic-roughness texture
  79370. */
  79371. metallicRoughnessTexture?: ITextureInfo;
  79372. }
  79373. /**
  79374. * The material appearance of a primitive
  79375. */
  79376. interface IMaterial extends IChildRootProperty {
  79377. /**
  79378. * 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
  79379. */
  79380. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79381. /**
  79382. * The normal map texture
  79383. */
  79384. normalTexture?: IMaterialNormalTextureInfo;
  79385. /**
  79386. * The occlusion map texture
  79387. */
  79388. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79389. /**
  79390. * The emissive map texture
  79391. */
  79392. emissiveTexture?: ITextureInfo;
  79393. /**
  79394. * 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
  79395. */
  79396. emissiveFactor?: number[];
  79397. /**
  79398. * The alpha rendering mode of the material
  79399. */
  79400. alphaMode?: MaterialAlphaMode;
  79401. /**
  79402. * The alpha cutoff value of the material
  79403. */
  79404. alphaCutoff?: number;
  79405. /**
  79406. * Specifies whether the material is double sided
  79407. */
  79408. doubleSided?: boolean;
  79409. }
  79410. /**
  79411. * Geometry to be rendered with the given material
  79412. */
  79413. interface IMeshPrimitive extends IProperty {
  79414. /**
  79415. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79416. */
  79417. attributes: {
  79418. [name: string]: number;
  79419. };
  79420. /**
  79421. * The index of the accessor that contains the indices
  79422. */
  79423. indices?: number;
  79424. /**
  79425. * The index of the material to apply to this primitive when rendering
  79426. */
  79427. material?: number;
  79428. /**
  79429. * The type of primitives to render. All valid values correspond to WebGL enums
  79430. */
  79431. mode?: MeshPrimitiveMode;
  79432. /**
  79433. * 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
  79434. */
  79435. targets?: {
  79436. [name: string]: number;
  79437. }[];
  79438. }
  79439. /**
  79440. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79441. */
  79442. interface IMesh extends IChildRootProperty {
  79443. /**
  79444. * An array of primitives, each defining geometry to be rendered with a material
  79445. */
  79446. primitives: IMeshPrimitive[];
  79447. /**
  79448. * Array of weights to be applied to the Morph Targets
  79449. */
  79450. weights?: number[];
  79451. }
  79452. /**
  79453. * A node in the node hierarchy
  79454. */
  79455. interface INode extends IChildRootProperty {
  79456. /**
  79457. * The index of the camera referenced by this node
  79458. */
  79459. camera?: number;
  79460. /**
  79461. * The indices of this node's children
  79462. */
  79463. children?: number[];
  79464. /**
  79465. * The index of the skin referenced by this node
  79466. */
  79467. skin?: number;
  79468. /**
  79469. * A floating-point 4x4 transformation matrix stored in column-major order
  79470. */
  79471. matrix?: number[];
  79472. /**
  79473. * The index of the mesh in this node
  79474. */
  79475. mesh?: number;
  79476. /**
  79477. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79478. */
  79479. rotation?: number[];
  79480. /**
  79481. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79482. */
  79483. scale?: number[];
  79484. /**
  79485. * The node's translation along the x, y, and z axes
  79486. */
  79487. translation?: number[];
  79488. /**
  79489. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79490. */
  79491. weights?: number[];
  79492. }
  79493. /**
  79494. * Texture sampler properties for filtering and wrapping modes
  79495. */
  79496. interface ISampler extends IChildRootProperty {
  79497. /**
  79498. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79499. */
  79500. magFilter?: TextureMagFilter;
  79501. /**
  79502. * Minification filter. All valid values correspond to WebGL enums
  79503. */
  79504. minFilter?: TextureMinFilter;
  79505. /**
  79506. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79507. */
  79508. wrapS?: TextureWrapMode;
  79509. /**
  79510. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79511. */
  79512. wrapT?: TextureWrapMode;
  79513. }
  79514. /**
  79515. * The root nodes of a scene
  79516. */
  79517. interface IScene extends IChildRootProperty {
  79518. /**
  79519. * The indices of each root node
  79520. */
  79521. nodes: number[];
  79522. }
  79523. /**
  79524. * Joints and matrices defining a skin
  79525. */
  79526. interface ISkin extends IChildRootProperty {
  79527. /**
  79528. * 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
  79529. */
  79530. inverseBindMatrices?: number;
  79531. /**
  79532. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79533. */
  79534. skeleton?: number;
  79535. /**
  79536. * 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)
  79537. */
  79538. joints: number[];
  79539. }
  79540. /**
  79541. * A texture and its sampler
  79542. */
  79543. interface ITexture extends IChildRootProperty {
  79544. /**
  79545. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79546. */
  79547. sampler?: number;
  79548. /**
  79549. * The index of the image used by this texture
  79550. */
  79551. source: number;
  79552. }
  79553. /**
  79554. * Reference to a texture
  79555. */
  79556. interface ITextureInfo extends IProperty {
  79557. /**
  79558. * The index of the texture
  79559. */
  79560. index: number;
  79561. /**
  79562. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79563. */
  79564. texCoord?: number;
  79565. }
  79566. /**
  79567. * The root object for a glTF asset
  79568. */
  79569. interface IGLTF extends IProperty {
  79570. /**
  79571. * An array of accessors. An accessor is a typed view into a bufferView
  79572. */
  79573. accessors?: IAccessor[];
  79574. /**
  79575. * An array of keyframe animations
  79576. */
  79577. animations?: IAnimation[];
  79578. /**
  79579. * Metadata about the glTF asset
  79580. */
  79581. asset: IAsset;
  79582. /**
  79583. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79584. */
  79585. buffers?: IBuffer[];
  79586. /**
  79587. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79588. */
  79589. bufferViews?: IBufferView[];
  79590. /**
  79591. * An array of cameras
  79592. */
  79593. cameras?: ICamera[];
  79594. /**
  79595. * Names of glTF extensions used somewhere in this asset
  79596. */
  79597. extensionsUsed?: string[];
  79598. /**
  79599. * Names of glTF extensions required to properly load this asset
  79600. */
  79601. extensionsRequired?: string[];
  79602. /**
  79603. * An array of images. An image defines data used to create a texture
  79604. */
  79605. images?: IImage[];
  79606. /**
  79607. * An array of materials. A material defines the appearance of a primitive
  79608. */
  79609. materials?: IMaterial[];
  79610. /**
  79611. * An array of meshes. A mesh is a set of primitives to be rendered
  79612. */
  79613. meshes?: IMesh[];
  79614. /**
  79615. * An array of nodes
  79616. */
  79617. nodes?: INode[];
  79618. /**
  79619. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79620. */
  79621. samplers?: ISampler[];
  79622. /**
  79623. * The index of the default scene
  79624. */
  79625. scene?: number;
  79626. /**
  79627. * An array of scenes
  79628. */
  79629. scenes?: IScene[];
  79630. /**
  79631. * An array of skins. A skin is defined by joints and matrices
  79632. */
  79633. skins?: ISkin[];
  79634. /**
  79635. * An array of textures
  79636. */
  79637. textures?: ITexture[];
  79638. }
  79639. /**
  79640. * The glTF validation results
  79641. * @ignore
  79642. */
  79643. interface IGLTFValidationResults {
  79644. info: {
  79645. generator: string;
  79646. hasAnimations: boolean;
  79647. hasDefaultScene: boolean;
  79648. hasMaterials: boolean;
  79649. hasMorphTargets: boolean;
  79650. hasSkins: boolean;
  79651. hasTextures: boolean;
  79652. maxAttributesUsed: number;
  79653. primitivesCount: number
  79654. };
  79655. issues: {
  79656. messages: Array<string>;
  79657. numErrors: number;
  79658. numHints: number;
  79659. numInfos: number;
  79660. numWarnings: number;
  79661. truncated: boolean
  79662. };
  79663. mimeType: string;
  79664. uri: string;
  79665. validatedAt: string;
  79666. validatorVersion: string;
  79667. }
  79668. /**
  79669. * The glTF validation options
  79670. */
  79671. interface IGLTFValidationOptions {
  79672. /** Uri to use */
  79673. uri?: string;
  79674. /** Function used to load external resources */
  79675. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79676. /** Boolean indicating that we need to validate accessor data */
  79677. validateAccessorData?: boolean;
  79678. /** max number of issues allowed */
  79679. maxIssues?: number;
  79680. /** Ignored issues */
  79681. ignoredIssues?: Array<string>;
  79682. /** Value to override severy settings */
  79683. severityOverrides?: Object;
  79684. }
  79685. /**
  79686. * The glTF validator object
  79687. * @ignore
  79688. */
  79689. interface IGLTFValidator {
  79690. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79691. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79692. }
  79693. }
  79694. declare module BABYLON {
  79695. /** @hidden */
  79696. export var cellPixelShader: {
  79697. name: string;
  79698. shader: string;
  79699. };
  79700. }
  79701. declare module BABYLON {
  79702. /** @hidden */
  79703. export var cellVertexShader: {
  79704. name: string;
  79705. shader: string;
  79706. };
  79707. }
  79708. declare module BABYLON {
  79709. export class CellMaterial extends BABYLON.PushMaterial {
  79710. private _diffuseTexture;
  79711. diffuseTexture: BABYLON.BaseTexture;
  79712. diffuseColor: BABYLON.Color3;
  79713. _computeHighLevel: boolean;
  79714. computeHighLevel: boolean;
  79715. private _disableLighting;
  79716. disableLighting: boolean;
  79717. private _maxSimultaneousLights;
  79718. maxSimultaneousLights: number;
  79719. constructor(name: string, scene: BABYLON.Scene);
  79720. needAlphaBlending(): boolean;
  79721. needAlphaTesting(): boolean;
  79722. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79723. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79724. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79725. getAnimatables(): BABYLON.IAnimatable[];
  79726. getActiveTextures(): BABYLON.BaseTexture[];
  79727. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79728. dispose(forceDisposeEffect?: boolean): void;
  79729. getClassName(): string;
  79730. clone(name: string): CellMaterial;
  79731. serialize(): any;
  79732. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79733. }
  79734. }
  79735. declare module BABYLON {
  79736. export class CustomShaderStructure {
  79737. FragmentStore: string;
  79738. VertexStore: string;
  79739. constructor();
  79740. }
  79741. export class ShaderSpecialParts {
  79742. constructor();
  79743. Fragment_Begin: string;
  79744. Fragment_Definitions: string;
  79745. Fragment_MainBegin: string;
  79746. Fragment_Custom_Diffuse: string;
  79747. Fragment_Before_Lights: string;
  79748. Fragment_Before_Fog: string;
  79749. Fragment_Custom_Alpha: string;
  79750. Fragment_Before_FragColor: string;
  79751. Vertex_Begin: string;
  79752. Vertex_Definitions: string;
  79753. Vertex_MainBegin: string;
  79754. Vertex_Before_PositionUpdated: string;
  79755. Vertex_Before_NormalUpdated: string;
  79756. Vertex_After_WorldPosComputed: string;
  79757. Vertex_MainEnd: string;
  79758. }
  79759. export class CustomMaterial extends BABYLON.StandardMaterial {
  79760. static ShaderIndexer: number;
  79761. CustomParts: ShaderSpecialParts;
  79762. _isCreatedShader: boolean;
  79763. _createdShaderName: string;
  79764. _customUniform: string[];
  79765. _newUniforms: string[];
  79766. _newUniformInstances: {
  79767. [name: string]: any;
  79768. };
  79769. _newSamplerInstances: {
  79770. [name: string]: BABYLON.Texture;
  79771. };
  79772. _customAttributes: string[];
  79773. FragmentShader: string;
  79774. VertexShader: string;
  79775. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79776. ReviewUniform(name: string, arr: string[]): string[];
  79777. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79778. constructor(name: string, scene: BABYLON.Scene);
  79779. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79780. AddAttribute(name: string): CustomMaterial;
  79781. Fragment_Begin(shaderPart: string): CustomMaterial;
  79782. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79783. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79784. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79785. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79786. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79787. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79788. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79789. Vertex_Begin(shaderPart: string): CustomMaterial;
  79790. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79791. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79792. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79793. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79794. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  79795. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79796. }
  79797. }
  79798. declare module BABYLON {
  79799. export class ShaderAlebdoParts {
  79800. constructor();
  79801. Fragment_Begin: string;
  79802. Fragment_Definitions: string;
  79803. Fragment_MainBegin: string;
  79804. Fragment_Custom_Albedo: string;
  79805. Fragment_Before_Lights: string;
  79806. Fragment_Custom_MetallicRoughness: string;
  79807. Fragment_Custom_MicroSurface: string;
  79808. Fragment_Before_Fog: string;
  79809. Fragment_Custom_Alpha: string;
  79810. Fragment_Before_FragColor: string;
  79811. Vertex_Begin: string;
  79812. Vertex_Definitions: string;
  79813. Vertex_MainBegin: string;
  79814. Vertex_Before_PositionUpdated: string;
  79815. Vertex_Before_NormalUpdated: string;
  79816. Vertex_After_WorldPosComputed: string;
  79817. Vertex_MainEnd: string;
  79818. }
  79819. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79820. static ShaderIndexer: number;
  79821. CustomParts: ShaderAlebdoParts;
  79822. _isCreatedShader: boolean;
  79823. _createdShaderName: string;
  79824. _customUniform: string[];
  79825. _newUniforms: string[];
  79826. _newUniformInstances: {
  79827. [name: string]: any;
  79828. };
  79829. _newSamplerInstances: {
  79830. [name: string]: BABYLON.Texture;
  79831. };
  79832. _customAttributes: string[];
  79833. FragmentShader: string;
  79834. VertexShader: string;
  79835. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79836. ReviewUniform(name: string, arr: string[]): string[];
  79837. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79838. constructor(name: string, scene: BABYLON.Scene);
  79839. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79840. AddAttribute(name: string): PBRCustomMaterial;
  79841. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79842. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79843. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79844. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79845. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79846. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79847. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79848. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79849. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79850. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79851. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79852. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79853. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79854. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79855. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79856. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  79857. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79858. }
  79859. }
  79860. declare module BABYLON {
  79861. /** @hidden */
  79862. export var firePixelShader: {
  79863. name: string;
  79864. shader: string;
  79865. };
  79866. }
  79867. declare module BABYLON {
  79868. /** @hidden */
  79869. export var fireVertexShader: {
  79870. name: string;
  79871. shader: string;
  79872. };
  79873. }
  79874. declare module BABYLON {
  79875. export class FireMaterial extends BABYLON.PushMaterial {
  79876. private _diffuseTexture;
  79877. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79878. private _distortionTexture;
  79879. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79880. private _opacityTexture;
  79881. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79882. diffuseColor: BABYLON.Color3;
  79883. speed: number;
  79884. private _scaledDiffuse;
  79885. private _lastTime;
  79886. constructor(name: string, scene: BABYLON.Scene);
  79887. needAlphaBlending(): boolean;
  79888. needAlphaTesting(): boolean;
  79889. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79890. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79891. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79892. getAnimatables(): BABYLON.IAnimatable[];
  79893. getActiveTextures(): BABYLON.BaseTexture[];
  79894. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79895. getClassName(): string;
  79896. dispose(forceDisposeEffect?: boolean): void;
  79897. clone(name: string): FireMaterial;
  79898. serialize(): any;
  79899. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79900. }
  79901. }
  79902. declare module BABYLON {
  79903. /** @hidden */
  79904. export var furPixelShader: {
  79905. name: string;
  79906. shader: string;
  79907. };
  79908. }
  79909. declare module BABYLON {
  79910. /** @hidden */
  79911. export var furVertexShader: {
  79912. name: string;
  79913. shader: string;
  79914. };
  79915. }
  79916. declare module BABYLON {
  79917. export class FurMaterial extends BABYLON.PushMaterial {
  79918. private _diffuseTexture;
  79919. diffuseTexture: BABYLON.BaseTexture;
  79920. private _heightTexture;
  79921. heightTexture: BABYLON.BaseTexture;
  79922. diffuseColor: BABYLON.Color3;
  79923. furLength: number;
  79924. furAngle: number;
  79925. furColor: BABYLON.Color3;
  79926. furOffset: number;
  79927. furSpacing: number;
  79928. furGravity: BABYLON.Vector3;
  79929. furSpeed: number;
  79930. furDensity: number;
  79931. furOcclusion: number;
  79932. furTexture: BABYLON.DynamicTexture;
  79933. private _disableLighting;
  79934. disableLighting: boolean;
  79935. private _maxSimultaneousLights;
  79936. maxSimultaneousLights: number;
  79937. highLevelFur: boolean;
  79938. _meshes: BABYLON.AbstractMesh[];
  79939. private _furTime;
  79940. constructor(name: string, scene: BABYLON.Scene);
  79941. get furTime(): number;
  79942. set furTime(furTime: number);
  79943. needAlphaBlending(): boolean;
  79944. needAlphaTesting(): boolean;
  79945. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79946. updateFur(): void;
  79947. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79948. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79949. getAnimatables(): BABYLON.IAnimatable[];
  79950. getActiveTextures(): BABYLON.BaseTexture[];
  79951. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79952. dispose(forceDisposeEffect?: boolean): void;
  79953. clone(name: string): FurMaterial;
  79954. serialize(): any;
  79955. getClassName(): string;
  79956. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79957. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79958. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79959. }
  79960. }
  79961. declare module BABYLON {
  79962. /** @hidden */
  79963. export var gradientPixelShader: {
  79964. name: string;
  79965. shader: string;
  79966. };
  79967. }
  79968. declare module BABYLON {
  79969. /** @hidden */
  79970. export var gradientVertexShader: {
  79971. name: string;
  79972. shader: string;
  79973. };
  79974. }
  79975. declare module BABYLON {
  79976. export class GradientMaterial extends BABYLON.PushMaterial {
  79977. private _maxSimultaneousLights;
  79978. maxSimultaneousLights: number;
  79979. topColor: BABYLON.Color3;
  79980. topColorAlpha: number;
  79981. bottomColor: BABYLON.Color3;
  79982. bottomColorAlpha: number;
  79983. offset: number;
  79984. scale: number;
  79985. smoothness: number;
  79986. private _disableLighting;
  79987. disableLighting: boolean;
  79988. constructor(name: string, scene: BABYLON.Scene);
  79989. needAlphaBlending(): boolean;
  79990. needAlphaTesting(): boolean;
  79991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79992. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79993. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79994. getAnimatables(): BABYLON.IAnimatable[];
  79995. dispose(forceDisposeEffect?: boolean): void;
  79996. clone(name: string): GradientMaterial;
  79997. serialize(): any;
  79998. getClassName(): string;
  79999. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  80000. }
  80001. }
  80002. declare module BABYLON {
  80003. /** @hidden */
  80004. export var gridPixelShader: {
  80005. name: string;
  80006. shader: string;
  80007. };
  80008. }
  80009. declare module BABYLON {
  80010. /** @hidden */
  80011. export var gridVertexShader: {
  80012. name: string;
  80013. shader: string;
  80014. };
  80015. }
  80016. declare module BABYLON {
  80017. /**
  80018. * The grid materials allows you to wrap any shape with a grid.
  80019. * Colors are customizable.
  80020. */
  80021. export class GridMaterial extends BABYLON.PushMaterial {
  80022. /**
  80023. * Main color of the grid (e.g. between lines)
  80024. */
  80025. mainColor: BABYLON.Color3;
  80026. /**
  80027. * Color of the grid lines.
  80028. */
  80029. lineColor: BABYLON.Color3;
  80030. /**
  80031. * The scale of the grid compared to unit.
  80032. */
  80033. gridRatio: number;
  80034. /**
  80035. * Allows setting an offset for the grid lines.
  80036. */
  80037. gridOffset: BABYLON.Vector3;
  80038. /**
  80039. * The frequency of thicker lines.
  80040. */
  80041. majorUnitFrequency: number;
  80042. /**
  80043. * The visibility of minor units in the grid.
  80044. */
  80045. minorUnitVisibility: number;
  80046. /**
  80047. * The grid opacity outside of the lines.
  80048. */
  80049. opacity: number;
  80050. /**
  80051. * Determine RBG output is premultiplied by alpha value.
  80052. */
  80053. preMultiplyAlpha: boolean;
  80054. private _opacityTexture;
  80055. opacityTexture: BABYLON.BaseTexture;
  80056. private _gridControl;
  80057. /**
  80058. * constructor
  80059. * @param name The name given to the material in order to identify it afterwards.
  80060. * @param scene The scene the material is used in.
  80061. */
  80062. constructor(name: string, scene: BABYLON.Scene);
  80063. /**
  80064. * Returns wehter or not the grid requires alpha blending.
  80065. */
  80066. needAlphaBlending(): boolean;
  80067. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80068. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80069. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80070. /**
  80071. * Dispose the material and its associated resources.
  80072. * @param forceDisposeEffect will also dispose the used effect when true
  80073. */
  80074. dispose(forceDisposeEffect?: boolean): void;
  80075. clone(name: string): GridMaterial;
  80076. serialize(): any;
  80077. getClassName(): string;
  80078. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  80079. }
  80080. }
  80081. declare module BABYLON {
  80082. /** @hidden */
  80083. export var lavaPixelShader: {
  80084. name: string;
  80085. shader: string;
  80086. };
  80087. }
  80088. declare module BABYLON {
  80089. /** @hidden */
  80090. export var lavaVertexShader: {
  80091. name: string;
  80092. shader: string;
  80093. };
  80094. }
  80095. declare module BABYLON {
  80096. export class LavaMaterial extends BABYLON.PushMaterial {
  80097. private _diffuseTexture;
  80098. diffuseTexture: BABYLON.BaseTexture;
  80099. noiseTexture: BABYLON.BaseTexture;
  80100. fogColor: BABYLON.Color3;
  80101. speed: number;
  80102. movingSpeed: number;
  80103. lowFrequencySpeed: number;
  80104. fogDensity: number;
  80105. private _lastTime;
  80106. diffuseColor: BABYLON.Color3;
  80107. private _disableLighting;
  80108. disableLighting: boolean;
  80109. private _unlit;
  80110. unlit: boolean;
  80111. private _maxSimultaneousLights;
  80112. maxSimultaneousLights: number;
  80113. private _scaledDiffuse;
  80114. constructor(name: string, scene: BABYLON.Scene);
  80115. needAlphaBlending(): boolean;
  80116. needAlphaTesting(): boolean;
  80117. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80118. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80119. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80120. getAnimatables(): BABYLON.IAnimatable[];
  80121. getActiveTextures(): BABYLON.BaseTexture[];
  80122. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80123. dispose(forceDisposeEffect?: boolean): void;
  80124. clone(name: string): LavaMaterial;
  80125. serialize(): any;
  80126. getClassName(): string;
  80127. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80128. }
  80129. }
  80130. declare module BABYLON {
  80131. /** @hidden */
  80132. export var mixPixelShader: {
  80133. name: string;
  80134. shader: string;
  80135. };
  80136. }
  80137. declare module BABYLON {
  80138. /** @hidden */
  80139. export var mixVertexShader: {
  80140. name: string;
  80141. shader: string;
  80142. };
  80143. }
  80144. declare module BABYLON {
  80145. export class MixMaterial extends BABYLON.PushMaterial {
  80146. /**
  80147. * Mix textures
  80148. */
  80149. private _mixTexture1;
  80150. mixTexture1: BABYLON.BaseTexture;
  80151. private _mixTexture2;
  80152. mixTexture2: BABYLON.BaseTexture;
  80153. /**
  80154. * Diffuse textures
  80155. */
  80156. private _diffuseTexture1;
  80157. diffuseTexture1: BABYLON.Texture;
  80158. private _diffuseTexture2;
  80159. diffuseTexture2: BABYLON.Texture;
  80160. private _diffuseTexture3;
  80161. diffuseTexture3: BABYLON.Texture;
  80162. private _diffuseTexture4;
  80163. diffuseTexture4: BABYLON.Texture;
  80164. private _diffuseTexture5;
  80165. diffuseTexture5: BABYLON.Texture;
  80166. private _diffuseTexture6;
  80167. diffuseTexture6: BABYLON.Texture;
  80168. private _diffuseTexture7;
  80169. diffuseTexture7: BABYLON.Texture;
  80170. private _diffuseTexture8;
  80171. diffuseTexture8: BABYLON.Texture;
  80172. /**
  80173. * Uniforms
  80174. */
  80175. diffuseColor: BABYLON.Color3;
  80176. specularColor: BABYLON.Color3;
  80177. specularPower: number;
  80178. private _disableLighting;
  80179. disableLighting: boolean;
  80180. private _maxSimultaneousLights;
  80181. maxSimultaneousLights: number;
  80182. constructor(name: string, scene: BABYLON.Scene);
  80183. needAlphaBlending(): boolean;
  80184. needAlphaTesting(): boolean;
  80185. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80186. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80187. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80188. getAnimatables(): BABYLON.IAnimatable[];
  80189. getActiveTextures(): BABYLON.BaseTexture[];
  80190. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80191. dispose(forceDisposeEffect?: boolean): void;
  80192. clone(name: string): MixMaterial;
  80193. serialize(): any;
  80194. getClassName(): string;
  80195. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80196. }
  80197. }
  80198. declare module BABYLON {
  80199. /** @hidden */
  80200. export var normalPixelShader: {
  80201. name: string;
  80202. shader: string;
  80203. };
  80204. }
  80205. declare module BABYLON {
  80206. /** @hidden */
  80207. export var normalVertexShader: {
  80208. name: string;
  80209. shader: string;
  80210. };
  80211. }
  80212. declare module BABYLON {
  80213. export class NormalMaterial extends BABYLON.PushMaterial {
  80214. private _diffuseTexture;
  80215. diffuseTexture: BABYLON.BaseTexture;
  80216. diffuseColor: BABYLON.Color3;
  80217. private _disableLighting;
  80218. disableLighting: boolean;
  80219. private _maxSimultaneousLights;
  80220. maxSimultaneousLights: number;
  80221. constructor(name: string, scene: BABYLON.Scene);
  80222. needAlphaBlending(): boolean;
  80223. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80224. needAlphaTesting(): boolean;
  80225. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80226. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80227. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80228. getAnimatables(): BABYLON.IAnimatable[];
  80229. getActiveTextures(): BABYLON.BaseTexture[];
  80230. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80231. dispose(forceDisposeEffect?: boolean): void;
  80232. clone(name: string): NormalMaterial;
  80233. serialize(): any;
  80234. getClassName(): string;
  80235. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80236. }
  80237. }
  80238. declare module BABYLON {
  80239. /** @hidden */
  80240. export var shadowOnlyPixelShader: {
  80241. name: string;
  80242. shader: string;
  80243. };
  80244. }
  80245. declare module BABYLON {
  80246. /** @hidden */
  80247. export var shadowOnlyVertexShader: {
  80248. name: string;
  80249. shader: string;
  80250. };
  80251. }
  80252. declare module BABYLON {
  80253. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80254. private _activeLight;
  80255. constructor(name: string, scene: BABYLON.Scene);
  80256. shadowColor: BABYLON.Color3;
  80257. needAlphaBlending(): boolean;
  80258. needAlphaTesting(): boolean;
  80259. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80260. get activeLight(): BABYLON.IShadowLight;
  80261. set activeLight(light: BABYLON.IShadowLight);
  80262. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80263. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80264. clone(name: string): ShadowOnlyMaterial;
  80265. serialize(): any;
  80266. getClassName(): string;
  80267. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80268. }
  80269. }
  80270. declare module BABYLON {
  80271. /** @hidden */
  80272. export var simplePixelShader: {
  80273. name: string;
  80274. shader: string;
  80275. };
  80276. }
  80277. declare module BABYLON {
  80278. /** @hidden */
  80279. export var simpleVertexShader: {
  80280. name: string;
  80281. shader: string;
  80282. };
  80283. }
  80284. declare module BABYLON {
  80285. export class SimpleMaterial extends BABYLON.PushMaterial {
  80286. private _diffuseTexture;
  80287. diffuseTexture: BABYLON.BaseTexture;
  80288. diffuseColor: BABYLON.Color3;
  80289. private _disableLighting;
  80290. disableLighting: boolean;
  80291. private _maxSimultaneousLights;
  80292. maxSimultaneousLights: number;
  80293. constructor(name: string, scene: BABYLON.Scene);
  80294. needAlphaBlending(): boolean;
  80295. needAlphaTesting(): boolean;
  80296. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80297. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80298. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80299. getAnimatables(): BABYLON.IAnimatable[];
  80300. getActiveTextures(): BABYLON.BaseTexture[];
  80301. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80302. dispose(forceDisposeEffect?: boolean): void;
  80303. clone(name: string): SimpleMaterial;
  80304. serialize(): any;
  80305. getClassName(): string;
  80306. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80307. }
  80308. }
  80309. declare module BABYLON {
  80310. /** @hidden */
  80311. export var skyPixelShader: {
  80312. name: string;
  80313. shader: string;
  80314. };
  80315. }
  80316. declare module BABYLON {
  80317. /** @hidden */
  80318. export var skyVertexShader: {
  80319. name: string;
  80320. shader: string;
  80321. };
  80322. }
  80323. declare module BABYLON {
  80324. /**
  80325. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80326. * @see https://doc.babylonjs.com/extensions/sky
  80327. */
  80328. export class SkyMaterial extends BABYLON.PushMaterial {
  80329. /**
  80330. * Defines the overall luminance of sky in interval ]0, 1[.
  80331. */
  80332. luminance: number;
  80333. /**
  80334. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80335. */
  80336. turbidity: number;
  80337. /**
  80338. * Defines the sky appearance (light intensity).
  80339. */
  80340. rayleigh: number;
  80341. /**
  80342. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80343. */
  80344. mieCoefficient: number;
  80345. /**
  80346. * Defines the amount of haze particles following the Mie scattering theory.
  80347. */
  80348. mieDirectionalG: number;
  80349. /**
  80350. * Defines the distance of the sun according to the active scene camera.
  80351. */
  80352. distance: number;
  80353. /**
  80354. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80355. * "inclined".
  80356. */
  80357. inclination: number;
  80358. /**
  80359. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80360. * an object direction and a reference direction.
  80361. */
  80362. azimuth: number;
  80363. /**
  80364. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80365. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80366. */
  80367. sunPosition: BABYLON.Vector3;
  80368. /**
  80369. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80370. * .sunPosition property.
  80371. */
  80372. useSunPosition: boolean;
  80373. /**
  80374. * Defines an offset vector used to get a horizon offset.
  80375. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80376. */
  80377. cameraOffset: BABYLON.Vector3;
  80378. private _cameraPosition;
  80379. /**
  80380. * Instantiates a new sky material.
  80381. * This material allows to create dynamic and texture free
  80382. * effects for skyboxes by taking care of the atmosphere state.
  80383. * @see https://doc.babylonjs.com/extensions/sky
  80384. * @param name Define the name of the material in the scene
  80385. * @param scene Define the scene the material belong to
  80386. */
  80387. constructor(name: string, scene: BABYLON.Scene);
  80388. /**
  80389. * Specifies if the material will require alpha blending
  80390. * @returns a boolean specifying if alpha blending is needed
  80391. */
  80392. needAlphaBlending(): boolean;
  80393. /**
  80394. * Specifies if this material should be rendered in alpha test mode
  80395. * @returns false as the sky material doesn't need alpha testing.
  80396. */
  80397. needAlphaTesting(): boolean;
  80398. /**
  80399. * Get the texture used for alpha test purpose.
  80400. * @returns null as the sky material has no texture.
  80401. */
  80402. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80403. /**
  80404. * Get if the submesh is ready to be used and all its information available.
  80405. * Child classes can use it to update shaders
  80406. * @param mesh defines the mesh to check
  80407. * @param subMesh defines which submesh to check
  80408. * @param useInstances specifies that instances should be used
  80409. * @returns a boolean indicating that the submesh is ready or not
  80410. */
  80411. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80412. /**
  80413. * Binds the submesh to this material by preparing the effect and shader to draw
  80414. * @param world defines the world transformation matrix
  80415. * @param mesh defines the mesh containing the submesh
  80416. * @param subMesh defines the submesh to bind the material to
  80417. */
  80418. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80419. /**
  80420. * Get the list of animatables in the material.
  80421. * @returns the list of animatables object used in the material
  80422. */
  80423. getAnimatables(): BABYLON.IAnimatable[];
  80424. /**
  80425. * Disposes the material
  80426. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80427. */
  80428. dispose(forceDisposeEffect?: boolean): void;
  80429. /**
  80430. * Makes a duplicate of the material, and gives it a new name
  80431. * @param name defines the new name for the duplicated material
  80432. * @returns the cloned material
  80433. */
  80434. clone(name: string): SkyMaterial;
  80435. /**
  80436. * Serializes this material in a JSON representation
  80437. * @returns the serialized material object
  80438. */
  80439. serialize(): any;
  80440. /**
  80441. * Gets the current class name of the material e.g. "SkyMaterial"
  80442. * Mainly use in serialization.
  80443. * @returns the class name
  80444. */
  80445. getClassName(): string;
  80446. /**
  80447. * Creates a sky material from parsed material data
  80448. * @param source defines the JSON representation of the material
  80449. * @param scene defines the hosting scene
  80450. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80451. * @returns a new sky material
  80452. */
  80453. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80454. }
  80455. }
  80456. declare module BABYLON {
  80457. /** @hidden */
  80458. export var terrainPixelShader: {
  80459. name: string;
  80460. shader: string;
  80461. };
  80462. }
  80463. declare module BABYLON {
  80464. /** @hidden */
  80465. export var terrainVertexShader: {
  80466. name: string;
  80467. shader: string;
  80468. };
  80469. }
  80470. declare module BABYLON {
  80471. export class TerrainMaterial extends BABYLON.PushMaterial {
  80472. private _mixTexture;
  80473. mixTexture: BABYLON.BaseTexture;
  80474. private _diffuseTexture1;
  80475. diffuseTexture1: BABYLON.Texture;
  80476. private _diffuseTexture2;
  80477. diffuseTexture2: BABYLON.Texture;
  80478. private _diffuseTexture3;
  80479. diffuseTexture3: BABYLON.Texture;
  80480. private _bumpTexture1;
  80481. bumpTexture1: BABYLON.Texture;
  80482. private _bumpTexture2;
  80483. bumpTexture2: BABYLON.Texture;
  80484. private _bumpTexture3;
  80485. bumpTexture3: BABYLON.Texture;
  80486. diffuseColor: BABYLON.Color3;
  80487. specularColor: BABYLON.Color3;
  80488. specularPower: number;
  80489. private _disableLighting;
  80490. disableLighting: boolean;
  80491. private _maxSimultaneousLights;
  80492. maxSimultaneousLights: number;
  80493. constructor(name: string, scene: BABYLON.Scene);
  80494. needAlphaBlending(): boolean;
  80495. needAlphaTesting(): boolean;
  80496. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80497. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80498. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80499. getAnimatables(): BABYLON.IAnimatable[];
  80500. getActiveTextures(): BABYLON.BaseTexture[];
  80501. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80502. dispose(forceDisposeEffect?: boolean): void;
  80503. clone(name: string): TerrainMaterial;
  80504. serialize(): any;
  80505. getClassName(): string;
  80506. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80507. }
  80508. }
  80509. declare module BABYLON {
  80510. /** @hidden */
  80511. export var triplanarPixelShader: {
  80512. name: string;
  80513. shader: string;
  80514. };
  80515. }
  80516. declare module BABYLON {
  80517. /** @hidden */
  80518. export var triplanarVertexShader: {
  80519. name: string;
  80520. shader: string;
  80521. };
  80522. }
  80523. declare module BABYLON {
  80524. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80525. mixTexture: BABYLON.BaseTexture;
  80526. private _diffuseTextureX;
  80527. diffuseTextureX: BABYLON.BaseTexture;
  80528. private _diffuseTextureY;
  80529. diffuseTextureY: BABYLON.BaseTexture;
  80530. private _diffuseTextureZ;
  80531. diffuseTextureZ: BABYLON.BaseTexture;
  80532. private _normalTextureX;
  80533. normalTextureX: BABYLON.BaseTexture;
  80534. private _normalTextureY;
  80535. normalTextureY: BABYLON.BaseTexture;
  80536. private _normalTextureZ;
  80537. normalTextureZ: BABYLON.BaseTexture;
  80538. tileSize: number;
  80539. diffuseColor: BABYLON.Color3;
  80540. specularColor: BABYLON.Color3;
  80541. specularPower: number;
  80542. private _disableLighting;
  80543. disableLighting: boolean;
  80544. private _maxSimultaneousLights;
  80545. maxSimultaneousLights: number;
  80546. constructor(name: string, scene: BABYLON.Scene);
  80547. needAlphaBlending(): boolean;
  80548. needAlphaTesting(): boolean;
  80549. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80550. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80551. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80552. getAnimatables(): BABYLON.IAnimatable[];
  80553. getActiveTextures(): BABYLON.BaseTexture[];
  80554. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80555. dispose(forceDisposeEffect?: boolean): void;
  80556. clone(name: string): TriPlanarMaterial;
  80557. serialize(): any;
  80558. getClassName(): string;
  80559. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80560. }
  80561. }
  80562. declare module BABYLON {
  80563. /** @hidden */
  80564. export var waterPixelShader: {
  80565. name: string;
  80566. shader: string;
  80567. };
  80568. }
  80569. declare module BABYLON {
  80570. /** @hidden */
  80571. export var waterVertexShader: {
  80572. name: string;
  80573. shader: string;
  80574. };
  80575. }
  80576. declare module BABYLON {
  80577. export class WaterMaterial extends BABYLON.PushMaterial {
  80578. renderTargetSize: BABYLON.Vector2;
  80579. private _bumpTexture;
  80580. bumpTexture: BABYLON.BaseTexture;
  80581. diffuseColor: BABYLON.Color3;
  80582. specularColor: BABYLON.Color3;
  80583. specularPower: number;
  80584. private _disableLighting;
  80585. disableLighting: boolean;
  80586. private _maxSimultaneousLights;
  80587. maxSimultaneousLights: number;
  80588. /**
  80589. * @param {number}: Represents the wind force
  80590. */
  80591. windForce: number;
  80592. /**
  80593. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80594. */
  80595. windDirection: BABYLON.Vector2;
  80596. /**
  80597. * @param {number}: Wave height, represents the height of the waves
  80598. */
  80599. waveHeight: number;
  80600. /**
  80601. * @param {number}: Bump height, represents the bump height related to the bump map
  80602. */
  80603. bumpHeight: number;
  80604. /**
  80605. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80606. */
  80607. private _bumpSuperimpose;
  80608. bumpSuperimpose: boolean;
  80609. /**
  80610. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80611. */
  80612. private _fresnelSeparate;
  80613. fresnelSeparate: boolean;
  80614. /**
  80615. * @param {boolean}: bump Waves modify the reflection.
  80616. */
  80617. private _bumpAffectsReflection;
  80618. bumpAffectsReflection: boolean;
  80619. /**
  80620. * @param {number}: The water color blended with the refraction (near)
  80621. */
  80622. waterColor: BABYLON.Color3;
  80623. /**
  80624. * @param {number}: The blend factor related to the water color
  80625. */
  80626. colorBlendFactor: number;
  80627. /**
  80628. * @param {number}: The water color blended with the reflection (far)
  80629. */
  80630. waterColor2: BABYLON.Color3;
  80631. /**
  80632. * @param {number}: The blend factor related to the water color (reflection, far)
  80633. */
  80634. colorBlendFactor2: number;
  80635. /**
  80636. * @param {number}: Represents the maximum length of a wave
  80637. */
  80638. waveLength: number;
  80639. /**
  80640. * @param {number}: Defines the waves speed
  80641. */
  80642. waveSpeed: number;
  80643. /**
  80644. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80645. * will avoid calculating useless pixels in the pixel shader of the water material.
  80646. */
  80647. disableClipPlane: boolean;
  80648. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80649. private _mesh;
  80650. private _refractionRTT;
  80651. private _reflectionRTT;
  80652. private _reflectionTransform;
  80653. private _lastTime;
  80654. private _lastDeltaTime;
  80655. private _useLogarithmicDepth;
  80656. private _waitingRenderList;
  80657. private _imageProcessingConfiguration;
  80658. private _imageProcessingObserver;
  80659. /**
  80660. * Gets a boolean indicating that current material needs to register RTT
  80661. */
  80662. get hasRenderTargetTextures(): boolean;
  80663. /**
  80664. * Constructor
  80665. */
  80666. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80667. get useLogarithmicDepth(): boolean;
  80668. set useLogarithmicDepth(value: boolean);
  80669. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80670. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80671. addToRenderList(node: any): void;
  80672. enableRenderTargets(enable: boolean): void;
  80673. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80674. get renderTargetsEnabled(): boolean;
  80675. needAlphaBlending(): boolean;
  80676. needAlphaTesting(): boolean;
  80677. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80678. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80679. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80680. private _createRenderTargets;
  80681. getAnimatables(): BABYLON.IAnimatable[];
  80682. getActiveTextures(): BABYLON.BaseTexture[];
  80683. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80684. dispose(forceDisposeEffect?: boolean): void;
  80685. clone(name: string): WaterMaterial;
  80686. serialize(): any;
  80687. getClassName(): string;
  80688. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80689. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80690. }
  80691. }
  80692. declare module BABYLON {
  80693. /** @hidden */
  80694. export var asciiartPixelShader: {
  80695. name: string;
  80696. shader: string;
  80697. };
  80698. }
  80699. declare module BABYLON {
  80700. /**
  80701. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80702. *
  80703. * It basically takes care rendering the font front the given font size to a texture.
  80704. * This is used later on in the postprocess.
  80705. */
  80706. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80707. private _font;
  80708. private _text;
  80709. private _charSize;
  80710. /**
  80711. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80712. */
  80713. get charSize(): number;
  80714. /**
  80715. * Create a new instance of the Ascii Art FontTexture class
  80716. * @param name the name of the texture
  80717. * @param font the font to use, use the W3C CSS notation
  80718. * @param text the caracter set to use in the rendering.
  80719. * @param scene the scene that owns the texture
  80720. */
  80721. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80722. /**
  80723. * Gets the max char width of a font.
  80724. * @param font the font to use, use the W3C CSS notation
  80725. * @return the max char width
  80726. */
  80727. private getFontWidth;
  80728. /**
  80729. * Gets the max char height of a font.
  80730. * @param font the font to use, use the W3C CSS notation
  80731. * @return the max char height
  80732. */
  80733. private getFontHeight;
  80734. /**
  80735. * Clones the current AsciiArtTexture.
  80736. * @return the clone of the texture.
  80737. */
  80738. clone(): AsciiArtFontTexture;
  80739. /**
  80740. * Parses a json object representing the texture and returns an instance of it.
  80741. * @param source the source JSON representation
  80742. * @param scene the scene to create the texture for
  80743. * @return the parsed texture
  80744. */
  80745. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80746. }
  80747. /**
  80748. * Option available in the Ascii Art Post Process.
  80749. */
  80750. export interface IAsciiArtPostProcessOptions {
  80751. /**
  80752. * The font to use following the w3c font definition.
  80753. */
  80754. font?: string;
  80755. /**
  80756. * The character set to use in the postprocess.
  80757. */
  80758. characterSet?: string;
  80759. /**
  80760. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80761. * This number is defined between 0 and 1;
  80762. */
  80763. mixToTile?: number;
  80764. /**
  80765. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80766. * This number is defined between 0 and 1;
  80767. */
  80768. mixToNormal?: number;
  80769. }
  80770. /**
  80771. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80772. *
  80773. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80774. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80775. */
  80776. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80777. /**
  80778. * The font texture used to render the char in the post process.
  80779. */
  80780. private _asciiArtFontTexture;
  80781. /**
  80782. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80783. * This number is defined between 0 and 1;
  80784. */
  80785. mixToTile: number;
  80786. /**
  80787. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80788. * This number is defined between 0 and 1;
  80789. */
  80790. mixToNormal: number;
  80791. /**
  80792. * Instantiates a new Ascii Art Post Process.
  80793. * @param name the name to give to the postprocess
  80794. * @camera the camera to apply the post process to.
  80795. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80796. */
  80797. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80798. }
  80799. }
  80800. declare module BABYLON {
  80801. /** @hidden */
  80802. export var digitalrainPixelShader: {
  80803. name: string;
  80804. shader: string;
  80805. };
  80806. }
  80807. declare module BABYLON {
  80808. /**
  80809. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80810. *
  80811. * It basically takes care rendering the font front the given font size to a texture.
  80812. * This is used later on in the postprocess.
  80813. */
  80814. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80815. private _font;
  80816. private _text;
  80817. private _charSize;
  80818. /**
  80819. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80820. */
  80821. get charSize(): number;
  80822. /**
  80823. * Create a new instance of the Digital Rain FontTexture class
  80824. * @param name the name of the texture
  80825. * @param font the font to use, use the W3C CSS notation
  80826. * @param text the caracter set to use in the rendering.
  80827. * @param scene the scene that owns the texture
  80828. */
  80829. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80830. /**
  80831. * Gets the max char width of a font.
  80832. * @param font the font to use, use the W3C CSS notation
  80833. * @return the max char width
  80834. */
  80835. private getFontWidth;
  80836. /**
  80837. * Gets the max char height of a font.
  80838. * @param font the font to use, use the W3C CSS notation
  80839. * @return the max char height
  80840. */
  80841. private getFontHeight;
  80842. /**
  80843. * Clones the current DigitalRainFontTexture.
  80844. * @return the clone of the texture.
  80845. */
  80846. clone(): DigitalRainFontTexture;
  80847. /**
  80848. * Parses a json object representing the texture and returns an instance of it.
  80849. * @param source the source JSON representation
  80850. * @param scene the scene to create the texture for
  80851. * @return the parsed texture
  80852. */
  80853. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80854. }
  80855. /**
  80856. * Option available in the Digital Rain Post Process.
  80857. */
  80858. export interface IDigitalRainPostProcessOptions {
  80859. /**
  80860. * The font to use following the w3c font definition.
  80861. */
  80862. font?: string;
  80863. /**
  80864. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80865. * This number is defined between 0 and 1;
  80866. */
  80867. mixToTile?: number;
  80868. /**
  80869. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80870. * This number is defined between 0 and 1;
  80871. */
  80872. mixToNormal?: number;
  80873. }
  80874. /**
  80875. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80876. *
  80877. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80878. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80879. */
  80880. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80881. /**
  80882. * The font texture used to render the char in the post process.
  80883. */
  80884. private _digitalRainFontTexture;
  80885. /**
  80886. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80887. * This number is defined between 0 and 1;
  80888. */
  80889. mixToTile: number;
  80890. /**
  80891. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80892. * This number is defined between 0 and 1;
  80893. */
  80894. mixToNormal: number;
  80895. /**
  80896. * Instantiates a new Digital Rain Post Process.
  80897. * @param name the name to give to the postprocess
  80898. * @camera the camera to apply the post process to.
  80899. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80900. */
  80901. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80902. }
  80903. }
  80904. declare module BABYLON {
  80905. /** @hidden */
  80906. export var brickProceduralTexturePixelShader: {
  80907. name: string;
  80908. shader: string;
  80909. };
  80910. }
  80911. declare module BABYLON {
  80912. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80913. private _numberOfBricksHeight;
  80914. private _numberOfBricksWidth;
  80915. private _jointColor;
  80916. private _brickColor;
  80917. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80918. updateShaderUniforms(): void;
  80919. get numberOfBricksHeight(): number;
  80920. set numberOfBricksHeight(value: number);
  80921. get numberOfBricksWidth(): number;
  80922. set numberOfBricksWidth(value: number);
  80923. get jointColor(): BABYLON.Color3;
  80924. set jointColor(value: BABYLON.Color3);
  80925. get brickColor(): BABYLON.Color3;
  80926. set brickColor(value: BABYLON.Color3);
  80927. /**
  80928. * Serializes this brick procedural texture
  80929. * @returns a serialized brick procedural texture object
  80930. */
  80931. serialize(): any;
  80932. /**
  80933. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80934. * @param parsedTexture defines parsed texture data
  80935. * @param scene defines the current scene
  80936. * @param rootUrl defines the root URL containing brick procedural texture information
  80937. * @returns a parsed Brick Procedural BABYLON.Texture
  80938. */
  80939. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80940. }
  80941. }
  80942. declare module BABYLON {
  80943. /** @hidden */
  80944. export var cloudProceduralTexturePixelShader: {
  80945. name: string;
  80946. shader: string;
  80947. };
  80948. }
  80949. declare module BABYLON {
  80950. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80951. private _skyColor;
  80952. private _cloudColor;
  80953. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80954. updateShaderUniforms(): void;
  80955. get skyColor(): BABYLON.Color4;
  80956. set skyColor(value: BABYLON.Color4);
  80957. get cloudColor(): BABYLON.Color4;
  80958. set cloudColor(value: BABYLON.Color4);
  80959. /**
  80960. * Serializes this cloud procedural texture
  80961. * @returns a serialized cloud procedural texture object
  80962. */
  80963. serialize(): any;
  80964. /**
  80965. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80966. * @param parsedTexture defines parsed texture data
  80967. * @param scene defines the current scene
  80968. * @param rootUrl defines the root URL containing cloud procedural texture information
  80969. * @returns a parsed Cloud Procedural BABYLON.Texture
  80970. */
  80971. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80972. }
  80973. }
  80974. declare module BABYLON {
  80975. /** @hidden */
  80976. export var fireProceduralTexturePixelShader: {
  80977. name: string;
  80978. shader: string;
  80979. };
  80980. }
  80981. declare module BABYLON {
  80982. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80983. private _time;
  80984. private _speed;
  80985. private _autoGenerateTime;
  80986. private _fireColors;
  80987. private _alphaThreshold;
  80988. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80989. updateShaderUniforms(): void;
  80990. render(useCameraPostProcess?: boolean): void;
  80991. static get PurpleFireColors(): BABYLON.Color3[];
  80992. static get GreenFireColors(): BABYLON.Color3[];
  80993. static get RedFireColors(): BABYLON.Color3[];
  80994. static get BlueFireColors(): BABYLON.Color3[];
  80995. get autoGenerateTime(): boolean;
  80996. set autoGenerateTime(value: boolean);
  80997. get fireColors(): BABYLON.Color3[];
  80998. set fireColors(value: BABYLON.Color3[]);
  80999. get time(): number;
  81000. set time(value: number);
  81001. get speed(): BABYLON.Vector2;
  81002. set speed(value: BABYLON.Vector2);
  81003. get alphaThreshold(): number;
  81004. set alphaThreshold(value: number);
  81005. /**
  81006. * Serializes this fire procedural texture
  81007. * @returns a serialized fire procedural texture object
  81008. */
  81009. serialize(): any;
  81010. /**
  81011. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  81012. * @param parsedTexture defines parsed texture data
  81013. * @param scene defines the current scene
  81014. * @param rootUrl defines the root URL containing fire procedural texture information
  81015. * @returns a parsed Fire Procedural BABYLON.Texture
  81016. */
  81017. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  81018. }
  81019. }
  81020. declare module BABYLON {
  81021. /** @hidden */
  81022. export var grassProceduralTexturePixelShader: {
  81023. name: string;
  81024. shader: string;
  81025. };
  81026. }
  81027. declare module BABYLON {
  81028. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  81029. private _grassColors;
  81030. private _groundColor;
  81031. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81032. updateShaderUniforms(): void;
  81033. get grassColors(): BABYLON.Color3[];
  81034. set grassColors(value: BABYLON.Color3[]);
  81035. get groundColor(): BABYLON.Color3;
  81036. set groundColor(value: BABYLON.Color3);
  81037. /**
  81038. * Serializes this grass procedural texture
  81039. * @returns a serialized grass procedural texture object
  81040. */
  81041. serialize(): any;
  81042. /**
  81043. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  81044. * @param parsedTexture defines parsed texture data
  81045. * @param scene defines the current scene
  81046. * @param rootUrl defines the root URL containing grass procedural texture information
  81047. * @returns a parsed Grass Procedural BABYLON.Texture
  81048. */
  81049. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  81050. }
  81051. }
  81052. declare module BABYLON {
  81053. /** @hidden */
  81054. export var marbleProceduralTexturePixelShader: {
  81055. name: string;
  81056. shader: string;
  81057. };
  81058. }
  81059. declare module BABYLON {
  81060. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  81061. private _numberOfTilesHeight;
  81062. private _numberOfTilesWidth;
  81063. private _amplitude;
  81064. private _jointColor;
  81065. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81066. updateShaderUniforms(): void;
  81067. get numberOfTilesHeight(): number;
  81068. set numberOfTilesHeight(value: number);
  81069. get amplitude(): number;
  81070. set amplitude(value: number);
  81071. get numberOfTilesWidth(): number;
  81072. set numberOfTilesWidth(value: number);
  81073. get jointColor(): BABYLON.Color3;
  81074. set jointColor(value: BABYLON.Color3);
  81075. /**
  81076. * Serializes this marble procedural texture
  81077. * @returns a serialized marble procedural texture object
  81078. */
  81079. serialize(): any;
  81080. /**
  81081. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  81082. * @param parsedTexture defines parsed texture data
  81083. * @param scene defines the current scene
  81084. * @param rootUrl defines the root URL containing marble procedural texture information
  81085. * @returns a parsed Marble Procedural BABYLON.Texture
  81086. */
  81087. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /** @hidden */
  81092. export var normalMapProceduralTexturePixelShader: {
  81093. name: string;
  81094. shader: string;
  81095. };
  81096. }
  81097. declare module BABYLON {
  81098. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  81099. private _baseTexture;
  81100. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81101. updateShaderUniforms(): void;
  81102. render(useCameraPostProcess?: boolean): void;
  81103. resize(size: any, generateMipMaps: any): void;
  81104. get baseTexture(): BABYLON.Texture;
  81105. set baseTexture(texture: BABYLON.Texture);
  81106. /**
  81107. * Serializes this normal map procedural texture
  81108. * @returns a serialized normal map procedural texture object
  81109. */
  81110. serialize(): any;
  81111. /**
  81112. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  81113. * @param parsedTexture defines parsed texture data
  81114. * @param scene defines the current scene
  81115. * @param rootUrl defines the root URL containing normal map procedural texture information
  81116. * @returns a parsed Normal Map Procedural BABYLON.Texture
  81117. */
  81118. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  81119. }
  81120. }
  81121. declare module BABYLON {
  81122. /** @hidden */
  81123. export var perlinNoiseProceduralTexturePixelShader: {
  81124. name: string;
  81125. shader: string;
  81126. };
  81127. }
  81128. declare module BABYLON {
  81129. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81130. time: number;
  81131. timeScale: number;
  81132. translationSpeed: number;
  81133. private _currentTranslation;
  81134. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81135. updateShaderUniforms(): void;
  81136. render(useCameraPostProcess?: boolean): void;
  81137. resize(size: any, generateMipMaps: any): void;
  81138. /**
  81139. * Serializes this perlin noise procedural texture
  81140. * @returns a serialized perlin noise procedural texture object
  81141. */
  81142. serialize(): any;
  81143. /**
  81144. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81145. * @param parsedTexture defines parsed texture data
  81146. * @param scene defines the current scene
  81147. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81148. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81149. */
  81150. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81151. }
  81152. }
  81153. declare module BABYLON {
  81154. /** @hidden */
  81155. export var roadProceduralTexturePixelShader: {
  81156. name: string;
  81157. shader: string;
  81158. };
  81159. }
  81160. declare module BABYLON {
  81161. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81162. private _roadColor;
  81163. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81164. updateShaderUniforms(): void;
  81165. get roadColor(): BABYLON.Color3;
  81166. set roadColor(value: BABYLON.Color3);
  81167. /**
  81168. * Serializes this road procedural texture
  81169. * @returns a serialized road procedural texture object
  81170. */
  81171. serialize(): any;
  81172. /**
  81173. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81174. * @param parsedTexture defines parsed texture data
  81175. * @param scene defines the current scene
  81176. * @param rootUrl defines the root URL containing road procedural texture information
  81177. * @returns a parsed Road Procedural BABYLON.Texture
  81178. */
  81179. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81180. }
  81181. }
  81182. declare module BABYLON {
  81183. /** @hidden */
  81184. export var starfieldProceduralTexturePixelShader: {
  81185. name: string;
  81186. shader: string;
  81187. };
  81188. }
  81189. declare module BABYLON {
  81190. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81191. private _time;
  81192. private _alpha;
  81193. private _beta;
  81194. private _zoom;
  81195. private _formuparam;
  81196. private _stepsize;
  81197. private _tile;
  81198. private _brightness;
  81199. private _darkmatter;
  81200. private _distfading;
  81201. private _saturation;
  81202. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81203. updateShaderUniforms(): void;
  81204. get time(): number;
  81205. set time(value: number);
  81206. get alpha(): number;
  81207. set alpha(value: number);
  81208. get beta(): number;
  81209. set beta(value: number);
  81210. get formuparam(): number;
  81211. set formuparam(value: number);
  81212. get stepsize(): number;
  81213. set stepsize(value: number);
  81214. get zoom(): number;
  81215. set zoom(value: number);
  81216. get tile(): number;
  81217. set tile(value: number);
  81218. get brightness(): number;
  81219. set brightness(value: number);
  81220. get darkmatter(): number;
  81221. set darkmatter(value: number);
  81222. get distfading(): number;
  81223. set distfading(value: number);
  81224. get saturation(): number;
  81225. set saturation(value: number);
  81226. /**
  81227. * Serializes this starfield procedural texture
  81228. * @returns a serialized starfield procedural texture object
  81229. */
  81230. serialize(): any;
  81231. /**
  81232. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81233. * @param parsedTexture defines parsed texture data
  81234. * @param scene defines the current scene
  81235. * @param rootUrl defines the root URL containing startfield procedural texture information
  81236. * @returns a parsed Starfield Procedural BABYLON.Texture
  81237. */
  81238. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81239. }
  81240. }
  81241. declare module BABYLON {
  81242. /** @hidden */
  81243. export var woodProceduralTexturePixelShader: {
  81244. name: string;
  81245. shader: string;
  81246. };
  81247. }
  81248. declare module BABYLON {
  81249. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81250. private _ampScale;
  81251. private _woodColor;
  81252. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81253. updateShaderUniforms(): void;
  81254. get ampScale(): number;
  81255. set ampScale(value: number);
  81256. get woodColor(): BABYLON.Color3;
  81257. set woodColor(value: BABYLON.Color3);
  81258. /**
  81259. * Serializes this wood procedural texture
  81260. * @returns a serialized wood procedural texture object
  81261. */
  81262. serialize(): any;
  81263. /**
  81264. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81265. * @param parsedTexture defines parsed texture data
  81266. * @param scene defines the current scene
  81267. * @param rootUrl defines the root URL containing wood procedural texture information
  81268. * @returns a parsed Wood Procedural BABYLON.Texture
  81269. */
  81270. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81271. }
  81272. }